EW1611 Posted October 28, 2019 Share Posted October 28, 2019 fiz o seguinte script, porém da erro no getPedOccupiedVehicle, no getElementData e no removeEventHandler. Alguém sabe dizer qual o erro? function entrega2(hitElement, matchingDimension ) local v = getPedOccupiedVehicle(hitElement) if getElementData(v,"Carregado") == true then setElementFrozen(v,true) outputChatBox("Espere o veículo ser descarregado!",hitElement,0,0,150) setElementData(v,"Carregado",false) destroyElement(finalm2) destroyElement(blip2) setTimer(function (hitElement, matchingDimension ) if isElementFrozen(hitElement) == true then setElementFrozen(hitElement,false) givePlayerMoney(hitElement,math.random(1500,3500)) removeEventHandler("onVehicleExit",source,remove2) end end,3500,1,hitElement) removeEventHandler("onMarkerHit",source,entrega2) end end Link to comment
Other Languages Moderators Lord Henry Posted October 28, 2019 Other Languages Moderators Share Posted October 28, 2019 Faltou verificar se hitElement é um jogador. function entrega2 (hitElement, matchingDimension) if (hitElement and getElementType (hitElement) == "player") then local v = getPedOccupiedVehicle (hitElement) if getElementData (v, "Carregado") == true then setElementFrozen (v, true) outputChatBox ("Espere o veículo ser descarregado!", hitElement, 0, 0, 150) setElementData (v, "Carregado", false) destroyElement (finalm2) destroyElement (blip2) setTimer (function (theHitElement, theSource) if isElementFrozen (theHitElement) then setElementFrozen (theHitElement, false) givePlayerMoney (theHitElement, math.random (1500,3500)) removeEventHandler ("onVehicleExit", theSource, remove2) end end, 3500, 1, hitElement, source) removeEventHandler ("onMarkerHit", source, entrega2) end end end 1 Link to comment
EW1611 Posted October 28, 2019 Author Share Posted October 28, 2019 a parte do getPedOccupiedVehicle e getElementData funcionou, obrigado, porém continua com o mesmo erro no removeEventHandler Link to comment
DNL291 Posted October 28, 2019 Share Posted October 28, 2019 Tente: function entrega2(hitElement, matchingDimension ) if getElementType(hitElement) ~= "player" then return end local v = getPedOccupiedVehicle(hitElement) if v and getElementData(v,"Carregado") == true then setElementFrozen(v,true) outputChatBox("Espere o veículo ser descarregado!",hitElement,0,0,150) setElementData(v,"Carregado",false) destroyElement(finalm2) -- se "finalm2" for a marker deste evento source vai causar erro destroyElement(blip2) setTimer(function (marker) if not (isElement(hitElement)) then return end if isElementFrozen(v) then setElementFrozen(v,false) givePlayerMoney(hitElement,math.random(1500,3500)) removeEventHandler("onVehicleExit",marker,remove2) -- certifique-se que a função 'remove2' esteja definida end end,3500,1,source) removeEventHandler("onMarkerHit",source,entrega2) end end Link to comment
EW1611 Posted October 28, 2019 Author Share Posted October 28, 2019 (edited) da o seguinte erro, nos dois: Bad argument @ 'removeEventHandler' [Expected element at argument 2] Edited October 28, 2019 by EW1611 Link to comment
DNL291 Posted October 28, 2019 Share Posted October 28, 2019 Veja o comentário que deixei na linha 8. Mova destroyElement(finalm2) para o timer depois do removeEventHandler. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now