-
Posts
288 -
Joined
-
Last visited
Everything posted by jingzhi
-
I got a clue, thank you
-
Doing this will reset on every frame? So if i set "executed" to true and it will be nil again on the next frame?
-
If I delete "excuted" from this line will it still reset or there will be some other problems?
-
I got confused, why this will make the calculation every frame? But after the first frame the "excuted" will be true and the it won't pass the if statement and won't do the calculations again? Please point out
-
Thank you very much, i will try this out as soon as possible
-
Thank you very much, both of you guys, I will try them out as soon as possible
-
I am trying to make a custom cursor: function drawCursor(status) if status == true then showCursor(true) setCursorAlpha(0) Rx,Ry = guiGetScreenSize() addEventHandler("onClientPreRender",root, function() local cursorX,cursorY = getCursorPosition() posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",_,_,_,_,true) end) elseif status == false then removeEventHandler("onClientPreRender",root, function() local cursorX,cursorY = getCursorPosition() posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",_,_,_,_,true) end) showCursor(false) end end It works, but there is some bug: 1. The cursor is always behind the all the GUI 2. After I hide the cursor using removeEventHandler, it keeps showing error every frame: attempt to perform arithmetic on local "cursorX" (a boolean value) which i think means the removeEventHandler didn't stop the arithmetic action, and I don't know why Please help if you know the problem, thank you very much!
-
But these are the values that are not changing, thats why I put this, and it calculate it once to save CPU. I maybe wrong, please point out if i'm wrong
-
This is the serverside local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) setElementInterior(weaponmarker,1) function showClientGUI(marker) if marker == weaponmarker then if getTeamName(getPlayerTeam(source)) ~= "Criminal" then triggerClientEvent(source,"showweaponGUI",source) else outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) addEvent("giveweapon",true) addEventHandler("giveweapon",getRootElement(), function(buyer,weapon,quantity) giveWeapon(buyer,weapon,quantity) end)
-
Hey guys, I am trying to make a function to draw progress bar: function dxDrawProgressBar(BGW,BGH,PBW,PBH,BGcolor,PBcolor,progress) if BGW > PBW and BGH > PBH then if not executed then local executed = true px,py = guiGetScreenSize() local BGstartx = math.floor((px - BGW) / 2) local BGstarty = math.floor((py - BGH) / 2) local PBstartx = math.floor((px - PBW) / 2) local PBstarty = math.floor((px - PBH) / 2) percent = math.floor(PBW / 100) end local drawprogress = math.floor(progress * percent) dxDrawRectangle(BGstartx,BGstarty,BGW,BGH,BGcolor,true) dxDrawRectangle(PBstartx,PBstarty,drawprogress,PBH,PBcolor,true) end end and I tried to run the function with these parameters addEventHandler("onClientRender",getRootElement(), function() local progress = math.floor((timepast / repairtime) * 100) dxDrawProgressBar(410,51,380,28,tocolor(127, 127, 127, 255),tocolor(233, 254, 0, 255),progress) end) Unfortunately, it is not working, debugscript3 says : Bad argument @ dxDrawRectangle :13: Expected vector-2 at argument 1, got nil Bad argument @ dxDrawRectangle :14: Expected vector-2 at argument 1, got nil Please help, thank you very much!
-
Anyone knows the problem?
-
There is nothing
-
It doesnt take money, and gives wrong weapon and wrong amount of ammo
-
Hey guys, I made this script long time ago, but it didnt work, i tried to fix it but i still cant until today. I want to make a ammunation which store the weapon id, ammo ammount, and money in 3 tables and trigger them together, please help if you see where have i done wrong, or you have better way to do this, thank y'all very much!! weapontable = { } ammotable = { } pricetable = { } function table.size(tab) local length = 0 for _ in pairs(tab) do length = length + 1 end return length end addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) guiWindowSetSizable(AmmoMenu, false) AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) guiEditSetMaxLength(AmmountTextbox, 6) BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) guiSetFont(BuyButton, "default-bold-small") guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) guiSetFont(QuitButton, "default-bold-small") guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu) Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) guiSetFont(Infolabel, "default-bold-small") guiGridListSetSortingEnabled (Cartlist,false) guiSetVisible(AmmoMenu,false) end ) function chooseweapon() if source == TazerImage then WeaponChosen = 23 end if source == PistolImage then WeaponChosen = 22 end if source == DeserteagleImage then WeaponChosen = 24 end if source == Ak47Image then WeaponChosen = 30 end if source == UziImage then WeaponChosen = 28 end if source == Tec9Image then WeaponChosen = 32 end if source == Mp5Image then WeaponChosen = 29 end if source == Spas12Image then WeaponChosen = 27 end if source == M4Image then WeaponChosen = 31 end if source == BuyButton then if guiGridListGetRowCount(Cartlist) > 0 then for i,price in pairs(pricetable) do local totalprice = totalprice + price end if getPlayerMoney(localPlayer) >= totalprice then for index,id in pairs(weapontable) do for i,ammo in pairs(ammotable) do triggerServerEvent("giveweapon",resourceRoot,localPlayer,id,ammo) end end takePlayerMoney(totalprice) else outputChatBox("You don't have enough money!",255,0,0) end else outputChatBox("You don't have anything in your cart!",255,0,0) end end if source == QuitButton then showCursor(false) guiSetVisible(AmmoMenu,false) guiGridListClear (Cartlist) guiSetText (AmmountTextbox,"") for id,weaponid in pairs(weapontable) do weapontable[k]=nil end for id,ammo in pairs(ammotable) do ammotable[k]=nil end for id,price in pairs(pricetable) do pricetable[k]=nil end end if source == AddcartButton then if WeaponChosen then if tonumber(guiGetText(AmmountTextbox)) ~= nil then if tonumber(guiGetText(AmmountTextbox)) > 0 then if tonumber(guiGetText(AmmountTextbox)) == math.floor(guiGetText(AmmountTextbox)) then local row = guiGridListAddRow(Cartlist) table.insert(weapontable,WeaponChosen) table.insert(ammotable,guiGetText(AmmountTextbox)) table.insert(pricetable,math.floor(10 * guiGetText(AmmountTextbox))) guiGridListSetItemText(Cartlist,row,Weaponcolumn,""..getWeaponNameFromID(WeaponChosen),false,false) guiGridListSetItemText(Cartlist,row,Amountcolumn,""..guiGetText(AmmountTextbox),false,false) guiGridListSetItemText(Cartlist,row,Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))),false,false) else outputChatBox("Please enter a integer!",255,0,0) end else outputChatBox("Please enter a positive number!",255,0,0) end else outputChatBox("Please enter a integer as the ammount of ammo",255,0,0) end else outputChatBox("Please choose a weapon by clicking on the icon of it",255,0,0) end end end addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) addEvent("showweaponGUI",true) function showGUI() totalprice = 0 outputChatBox("true") showCursor(true) guiSetVisible(AmmoMenu,true) end addEventHandler("showweaponGUI",getRootElement(),showGUI)
-
I'm not quite sure how it would be, and how to use the onClientGUIClick to make this work, that's where I am confused. Try to use defined variables for windows, buttons , etc
-
what event are you trying to cancel? You can only cancel the events that are handled originally by gta
-
Thank you, problem solved
-
Here is a part of the script but i don't know what line must i change and how. --CLIENT STUFF --detects when a bot changes status and starts the new behaviour function changestatus (dataName) if getElementType ( source ) == "ped" and dataName == "status" and (getElementData (source, "slothbot") == true) then if (getElementData ( source, "status" ) == "chasing" ) then local player = getElementData ( source, "target" ) local oldTx, oldTy, oldTz = getElementPosition( player ) local oldPx, oldPy, oldPz = getElementPosition( source ) setTimer ( chase_aim, 80, 1, source) setTimer ( chase_move, 700, 1, source, oldTx, oldTy, oldTz, oldPx, oldPy, oldPz ) setTimer ( chase_shoot, 1500, 1, source ) elseif (getElementData ( source, "status" ) == "hunting" ) then local oldPx, oldPy, oldPz = getElementPosition( source ) setTimer ( enemy_check, 600 ,1 , source )-- starts scanning for enemies setTimer ( hunt_move, 800, 1, source, oldPx, oldPy, oldPz, oldPx, oldPy, oldPz ) elseif (getElementData ( source, "status" ) == "following" ) then local player = getElementData ( source, "leader" ) local oldTx, oldTy, oldTz = getElementPosition( player ) local oldPx, oldPy, oldPz = getElementPosition( source ) setTimer ( follow_enemy_check, 500 ,1 , source ) setTimer ( follow_move, 800, 1, source, oldPx, oldPy, oldPz, oldPx, oldPy, oldPz ) elseif (getElementData ( source, "status" ) == "waiting" ) then setTimer ( wait_enemy_check, 500 ,1 , source ) elseif (getElementData ( source, "status" ) == "guarding" ) then setTimer ( guard_enemy_check, 800 ,1 , source )-- starts scanning for enemies setTimer ( guard_move, 400 ,1 , source ) end end end addEventHandler( "onClientElementDataChange", getRootElement(), changestatus ) --keeps the bot's aim slightly lagged function chase_aim(ped) if (isElement(ped)) then local player = getElementData ( ped, "target" ) if (getElementData ( ped, "status" ) == "chasing" ) and (isElement(player)) and (getElementData (ped, "slothbot") == true) then if getElementType(player) == "player" then local pedhp = getElementHealth ( ped ) if pedhp > 0 and (isPlayerDead(player) == false) then local x,y,z = getElementPosition( player ) local ex,ey,ez = getElementPosition( ped ) local isclear = isLineOfSightClear (ex, ey, ez+.6, x, y, z+.6, true, false, false, true, false, false, false) if (isclear == true) then -- if the player target is in sight if isPedDucked(player) then setPedAimTarget ( ped, x, y, z-.5 ) else setPedAimTarget ( ped, x, y, z ) end end setTimer ( chase_aim, 80, 1, ped, player ) end elseif getElementType(player) == "ped" then local pedhp = getElementHealth ( ped ) if pedhp > 0 and (getElementHealth(player) > 0) then local x,y,z = getElementPosition( player ) local ex,ey,ez = getElementPosition( ped ) local isclear = isLineOfSightClear (ex, ey, ez+.6, x, y, z+.6, true, false, false, true, false, false, false) if (isclear == true) then -- if the player target is in sight if isPedDucked(player) then setPedAimTarget ( ped, x, y, z-.5 ) else setPedAimTarget ( ped, x, y, z ) end end setTimer ( chase_aim, 80, 1, ped, player ) end end end end end --bot behaviour while in chase mode function chase_move (ped, oldTx, oldTy, oldTz, oldPx, oldPy, oldPz) if (isElement(ped)) then local thetarget = getElementData ( ped, "target" ) if (getElementData ( ped, "status" ) == "chasing" ) and (isElement(thetarget)) and (getElementData (ped, "slothbot") == true) then local pedhp = getElementHealth ( ped ) local tarhp = getElementHealth ( thetarget ) if pedhp > 0 and tarhp > 0 then local tx,ty,tz = getElementPosition( thetarget ) local px,py,pz = getElementPosition( ped ) local isclear = isLineOfSightClear (px, py, pz+.6, tx, ty, tz+.6, true, false, false, true, false, false, false) local angle = ( 360 - math.deg ( math.atan2 ( ( tx - px ), ( ty - py ) ) ) ) % 360 --set the peds angle to the target setPedRotation( ped, angle ) if (isclear == true) then -- if the ped can see the target local angle = ( 360 - math.deg ( math.atan2 ( ( tx - px ), ( ty - py ) ) ) ) % 360 --set the peds angle to the target setPedRotation( ped, angle ) setElementData ( ped, "seestarget", true ) setTimer ( chase_move, 700, 1, ped, tx, ty, tz, px, py, pz) else local angle = ( 360 - math.deg ( math.atan2 ( ( oldTx - px ), ( oldTy - py ) ) ) ) % 360 --set the peds angle to the target setPedRotation( ped, angle ) setElementData ( ped, "seestarget", false ) setTimer ( chase_move, 700, 1, ped, oldTx, oldTy, oldTz, px, py, pz) end end end end end --tells the bot when to fire its gun. (only run by the peds controller) function chase_shoot(ped) if (isElement(ped)) then local player = getElementData ( ped, "target" ) if (isElement(player)) and (getElementData (ped, "slothbot") == true) then if (getElementType(player) == "ped") or (getElementType(player) == "player") then if (getElementData ( ped, "status" ) == "chasing" ) and (isElement(player)) then if (getElementHealth(ped)>0) and (getElementHealth(player)>0) and (getElementData ( ped, "controller" ) == getLocalPlayer()) then local x,y,z = getElementPosition( player ) local ex,ey,ez = getElementPosition( ped ) local isclear = isLineOfSightClear (ex, ey, ez+1, x, y, z+1, true, false, false, true, false, false, false) if isclear == true then -- if the ped can see the local player local distance = (getDistanceBetweenPoints3D (ex, ey, ez, x, y, z)) if (getPedWeapon(ped) < 19) and (getPedWeapon(ped) ~= 9) then -- if its a melee weapon hat isnt a chainsaw if (distance < 2 ) then triggerServerEvent ( "pedShootTrigger", ped, "melee" ) setTimer ( chase_shoot, 2300, 1, ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 9) then -- if it is a chainsaw (watch out, the peds are deadly with these) if (distance < 2 ) then local length = 1500 triggerServerEvent ( "pedShootTrigger", ped, "chainsawA", length ) setTimer ( chase_shoot, 6000, 1, ped, player ) else local length = math.random( 2100, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "chainsawB", length ) setTimer ( chase_shoot, length+900 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 22) then if (distance < 35 ) then local length = math.random( 2100, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+500 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 23) then if (distance < 35 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+400 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 24) then if (distance < 35 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+400 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 25) then if (distance < 27 ) then local length = 300 triggerServerEvent ( "pedShootTrigger", ped, "gun", length) setTimer ( chase_shoot, 1400 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 26) then if (distance < 20 ) then local length = 1200 triggerServerEvent ( "pedShootTrigger", ped, "gun", length) setTimer ( chase_shoot, 800 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 27) then if (distance < 25 ) then local length = 1200 triggerServerEvent ( "pedShootTrigger", ped, "gun", length) setTimer ( chase_shoot, 1800 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 28) then if (distance < 40 ) then local length = math.random( 2100, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+500 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 29) then if (distance < 55 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+1500 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 30) then if (distance < 60 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+1500 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 31) then if (distance < 60 ) then local length = 700 triggerServerEvent ( "pedShootTrigger", ped, "gun", length) setTimer ( chase_shoot, 1200 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 32) then if (distance < 30 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+600 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 33) then if (distance < 75 ) then local length = 400 triggerServerEvent ( "pedShootTrigger", ped, "gun", length) setTimer ( chase_shoot, 1600 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 34) then if (distance < 75 ) then triggerServerEvent ( "pedShootTrigger", ped, "sniper") setTimer ( chase_shoot, 2000 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 37) then if (distance < 15 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+900 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end elseif (getPedWeapon(ped) == 38) then if (distance < 65 ) then local length = math.random( 2000, 5500 ) triggerServerEvent ( "pedShootTrigger", ped, "gun", length ) setTimer ( chase_shoot, length+900 ,1 , ped, player ) else setTimer ( chase_shoot, 1500 ,1 , ped, player ) end
-
function(timerepair,occupiedmarker) repairtime = timerepair brokenveh = getElementData(occupiedmarker,"occupiedby") currenthealth = getElementHealth(brokenveh) keycheck = setTimer(check,60,0) usingmarker = occupiedmarker end ) function check() if getKeyState("1") == true then killTimer(keycheck) addEventHandler("onClientRender",getRootElement(),drawprogress) timepast = 0 elseif getKeyState("2") == true then killTimer(keycheck) setElementFrozen(localPlayer,false) end end function drawprogress() countdowntimer = setTimer(countdown,1000,0) colorchangetimer = setTimer(colorchange,100,0) local progress = math.floor((timepast / repairtime) * 500) dxDrawProgressBar(startpointx,startpointy,800,100,progress,tocolor(colorr,colorg,0),tocolor(160,160,160)) end function countdown() if timepast <= repairtime then timepast = timepast + 1 else finishrepair() end end function colorchange() colordiff = math.floor((255 / repairtime) / 2) colorr = 255 - colordiff colorg = 0 + colordiff end function finishrepair() if isTimer(countdowntimer) then killTimer(countdowntimer) end if isTimer(colorchangetimer) then killTimer(colorchangetimer) end fixVehicle(brokenveh) removeEventHandler("onClientRender",root,drawprogress) setElementFrozen(localPlayer,false) setElementFrozen(brokenveh,false) setElementData(usingmarker,"availiable",true) setElementAlpha(usingmarker,0) setElementData(brokenveh,"repairedstatus",true) setElementData(brokenveh,"repairer",localPlayer) outputChatBox("Drive this vehicle to the original deliver point",255,255,0) end I changed the script to this, but the timer doesnt stop, its keeps going non stop
-
I see, thank you, but this timer is infinite, i must destroy it?
-
Ty, i will try
-
Hey JR10, thank you very much, the problem is fix. But there is a little bug, that if the cop is at the east or west of the arrested criminal, the criminal runs to the opposite direction, can you please help to fix? Thank you ! addEvent("onPlayerArrested",true) addEventHandler("onPlayerArrested",root, function(arrestercop) arrester = arrestercop setCameraTarget(arrester) toggleAllControls(localPlayer,true,true,false) addEventHandler("onClientRender",root,cuffed) end) function cuffed() local copx, copy, copz = getElementPosition (arrester) local x, y, z = getElementPosition (localPlayer) local copangle = ( 360 - math.deg ( math.atan2 ( ( copx - x ), ( copy - y ) ) ) ) % 360 local rx, ry, _ = getElementRotation (localPlayer) setElementRotation(localPlayer,_,_, copangle) local dist = getDistanceBetweenPoints2D (copx, copy, x, y) if dist < 2 then setControlState("forwards", false) setControlState("sprint", false ) else setControlState("forwards", true) setControlState("sprint", true ) end end addEvent("onPlayerJailed",true) addEventHandler("onPlayerJailed",root, function() removeEventHandler("onClientRender",root,cuffed) end)
-
Can you please explain more? I didnt really understand
-
addEvent("buttonpressed",true) addEventHandler("buttonpressed",root, function(timerepair,occupiedmarker) repairtime = timerepair brokenveh = getElementData(occupiedmarker,"occupiedby") currenthealth = getElementHealth(brokenveh) keycheck = setTimer(check,60,0) usingmarker = occupiedmarker end ) function check() if getKeyState("1") == true then killTimer(keycheck) addEventHandler("onClientRender",getRootElement(),drawprogress) timepast = 0 elseif getKeyState("2") == true then killTimer(keycheck) setElementFrozen(localPlayer,false) end end function drawprogress() countdowntimer = setTimer(countdown,1000,0) colorchangetimer = setTimer(colorchange,100,0) local progress = math.floor((timepast / repairtime) * 500) dxDrawProgressBar(startpointx,startpointy,800,100,progress,tocolor(colorr,colorg,0),tocolor(160,160,160)) end function countdown() if timepast <= repairtime then timepast = timepast + 1 else finishrepair() end end function colorchange() colordiff = math.floor((255 / repairtime) / 2) colorr = 255 - colordiff colorg = 0 + colordiff end function finishrepair() killTimer(countdowntimer) killTimer(colorchangetimer) fixVehicle(brokenveh) removeEventHandler("onClientRender",root,drawprogress) setElementFrozen(localPlayer,false) setElementFrozen(brokenveh,false) setElementData(usingmarker,"availiable",true) setElementAlpha(usingmarker,0) setElementData(brokenveh,"repairedstatus",true) setElementData(brokenveh,"repairer",localPlayer) outputChatBox("Drive this vehicle to the original deliver point",255,255,0) end Hey guys I made this script, but there is some problem, when its running killTimer, it doesnt kill the timer and debugscript says "bad argument "killTimer" expected lua-timer element at argument 1" please help! thank you!
-
Here is the new script addEvent("onPlayerArrested",true) addEventHandler("onPlayerArrested",root, function(arrester) arrester = arrester setCameraTarget(arrester) addEventHandler("onClientPreRender",root,cuffed) end) function cuffed(arrester) local copx, copy, copz = getElementPosition (arrester) local x, y, z = getElementPosition (localPlayer) local copangle = ( 360 - math.deg ( math.atan2 ( ( copx - x ), ( copy - y ) ) ) ) % 360 local rx, ry, _ = getElementRotation ( localPlayer ) setElementRotation(localPlayer, rx, ry, copangle) local dist = getDistanceBetweenPoints2D (copx, copy, x, y) if dist < 2 then setControlState("forwards", false) setControlState("sprint", false ) else setControlState("forwards", true) setControlState("sprint", true ) end end addEvent("onPlayerJailed",true) addEventHandler("onPlayerJailed",root, function() removeEventHandler("onClientPreRender",root,cuffed) end) Unfortunately, its still not working
