WeeD1 Posted January 29, 2019 Share Posted January 29, 2019 Estou com um erro aqui, que após o veículo ser destruído ele aparece esse aviso no debugscript 3 e fica floodando durante algum tempo, teria como me ajudarem nisso pfv? WARNING: LuzesPM\server.lua:66: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got boolean] p_lights = {} p_timer = {} p_lvar = {} function toggleLights(thePlayer, cmd) local veh = getPedOccupiedVehicle(thePlayer) local id = getElementModel(veh) if (id == 523) or (id == 490) or (id == 597) or (id == 599) then if(p_lights[veh] == 0) or(p_lights[veh] == nil) then p_lights[veh] = 1 outputChatBox("#FF0000*ATENÇÃO: #ffffffLuzes da Policia Foram Ativadas.", thePlayer, 0, 200, 100, true) setVehicleOverrideLights ( veh, 2 ) p_timer[veh] = setTimer( function() if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then p_lvar[veh] = 1 setVehicleLightState ( veh, 1, 0) setVehicleLightState ( veh, 2, 0) setVehicleLightState ( veh, 0, 1) setVehicleLightState ( veh, 3, 1) setVehicleHeadLightColor(veh, 0, 0, 255) else setVehicleLightState ( veh, 3, 0) setVehicleLightState ( veh, 0, 0) setVehicleLightState ( veh, 1, 1) setVehicleLightState ( veh, 2, 1) setVehicleHeadLightColor(veh, 255, 0, 0) p_lvar[veh] = 0 end end, 500, 0) else p_lights[veh] = 0 outputChatBox("#FF0000*ATENÇÃO: #ffffffLuzes da Policia Foram Desativadas.", thePlayer, 0, 200, 100, true) killTimer(p_timer[veh]) setVehicleLightState ( veh, 0, 0) setVehicleLightState ( veh, 1, 0) setVehicleLightState ( veh, 2, 0) setVehicleLightState ( veh, 3, 0) setVehicleHeadLightColor(veh, 255, 255, 255) setVehicleOverrideLights ( veh, 1 ) end end end addCommandHandler("alerta", toggleLights) addEventHandler ( "onVehicleExplode", getRootElement(), function() if(p_lights[source] == 1) then killTimer(p_timer[source]) end end ) addEventHandler ( "onVehicleRespawn", getRootElement(), function() if(p_lights[source] == 1) then killTimer(p_timer[source]) end end ) addEventHandler("onElementDestroy", getRootElement(), function () if getElementType(source) == "vehicle" then if(p_lights[source] == 1) then p_timer[source] = false killTimer(p_timer[source]) end end end) Link to comment
zMpyster Posted January 29, 2019 Share Posted January 29, 2019 (edited) tente usar: addEventHandler("onElementDestroy", getRootElement(), function () if getElementType(source) == "vehicle" then if(p_lights[source] == 1) then if isTimer(p_timer[source]) then killTimer(p_timer[source]) end p_timer[source] = nil end end end) Edited January 29, 2019 by zMpyster 1 Link to comment
WeeD1 Posted January 29, 2019 Author Share Posted January 29, 2019 25 minutes ago, zMpyster said: tente usar: addEventHandler("onElementDestroy", getRootElement(), function () if getElementType(source) == "vehicle" then if(p_lights[source] == 1) then if isTimer(p_timer[source]) then killTimer(p_timer[source]) end p_timer[source] = nil end end end) funcionou aqui, valeu ! 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