PashaBiceps Posted March 26, 2019 Share Posted March 26, 2019 Boas gente, estou com um problema em um meu script. Eu desligo o motor do meu carro e as luzes.. Saio por algum motivo do veículo, quando entro no carro o motor e as luzes já se ligam automaticamente. O que está havendo como posso resolver? Obrigado desde já a toda ajuda addEventHandler("onPlayerLogin", root, function() bindKey(source, "l", "down", lights) bindKey(source, "j", "down", engine) end) addEventHandler("onResourceStart", resourceRoot, function() for _, v in pairs (getElementsByType("player")) do bindKey(v, "l", "down", lights) bindKey(v, "j", "down", engine) end end) --//Engine On / Off function engine (src, cmd) if isPedInVehicle(src) and getPedOccupiedVehicleSeat (src) == 0 then local vehicle = getPedOccupiedVehicle (src) if getVehicleEngineState (vehicle) == false then setVehicleEngineState (vehicle, true) outputChatBox ("Motor ligado!", src, 0, 255, 0) else setVehicleEngineState (vehicle, false) outputChatBox ("Motor desligado!", src, 255, 0, 0) end else return false end end addCommandHandler ("motor", engine) --//-- --//Vehicle Lights function lights (src, cmd) if isPedInVehicle(src) and getPedOccupiedVehicleSeat (src) == 0 then local vehicle = getPedOccupiedVehicle (src) if getVehicleOverrideLights (vehicle) == 1 then setVehicleOverrideLights (vehicle, 2) outputChatBox ("Luzes ligadas!", src, 0, 255, 0) else setVehicleOverrideLights (vehicle, 1) outputChatBox ("Luzes desligadas!", src, 255, 0, 0) end else return false end end addCommandHandler ("luzes", lights) Link to comment
Other Languages Moderators Lord Henry Posted March 26, 2019 Other Languages Moderators Share Posted March 26, 2019 Isso é automático do próprio GTA. Crie uma função com onVehicleEnter e desligue as luzes e motor. 1 Link to comment
PashaBiceps Posted March 26, 2019 Author Share Posted March 26, 2019 (edited) 32 minutes ago, Lord Henry said: Isso é automático do próprio GTA. Crie uma função com onVehicleEnter e desligue as luzes e motor. Eu tentei isso, mas não funcionou function enterVehicle ( theVehicle, seat, jacked ) if getVehicleEngineState (theVehicle) == true then setTimer(setVehicleEngineState,500,1, theVehicle,true) else setTimer(setVehicleEngineState,500,1, theVehicle,false) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) Edited March 26, 2019 by GodKraken Link to comment
Other Languages Moderators Lord Henry Posted March 26, 2019 Other Languages Moderators Share Posted March 26, 2019 Remova as linhas 2, 3, 4 e 6. 1 Link to comment
PashaBiceps Posted March 26, 2019 Author Share Posted March 26, 2019 2 hours ago, Lord Henry said: Remova as linhas 2, 3, 4 e 6. Sim funciona, o problema é que sempre vai estar desligado quando entrar. O que eu gostaria era se o jogador deixar o carro ligado ele continuar ligado e se ele desligar o carro ficar desligado e ele ter de o ligar. Link to comment
Other Languages Moderators Lord Henry Posted March 26, 2019 Other Languages Moderators Share Posted March 26, 2019 Dai sete uma elementData no carro quando liga/desliga o motor e farol. Dai verifique essa data ao entrar no veículo, se tiver a data, mantenha o motor/farol ligado. Link to comment
PashaBiceps Posted March 27, 2019 Author Share Posted March 27, 2019 10 hours ago, Lord Henry said: Dai sete uma elementData no carro quando liga/desliga o motor e farol. Dai verifique essa data ao entrar no veículo, se tiver a data, mantenha o motor/farol ligado. Tentei mas não funcionou, infelizmente function enterVehicle ( theVehicle, seat, jacked ) if getElementData ( theVehicle, "engineon" ) then setVehicleEngineState (vehicle, true) elseif getElementData ( theVehicle, "engineoff" ) then setVehicleEngineState (vehicle, false) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) function enterVehicle1 ( theVehicle, seat, jacked ) if getElementData ( theVehicle, "lightson" ) then setVehicleOverrideLights (vehicle, 2) elseif getElementData ( theVehicle, "lightsoff" ) then setVehicleOverrideLights (vehicle, 1) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle1 ) --//Engine On / Off function engine (src, cmd) if isPedInVehicle(src) and getPedOccupiedVehicleSeat (src) == 0 then local vehicle = getPedOccupiedVehicle (src) if getVehicleEngineState (vehicle) == false then setVehicleEngineState (vehicle, true) outputChatBox ("Motor ligado!", src, 0, 255, 0) setElementData(vehicle,"engineon") else setVehicleEngineState (vehicle, false) outputChatBox ("Motor desligado!", src, 255, 0, 0) setElementData(vehicle,"engineoff") end else return false end end addCommandHandler ("motor", engine) --//-- --//Vehicle Lights function lights (src, cmd) if isPedInVehicle(src) and getPedOccupiedVehicleSeat (src) == 0 then local vehicle = getPedOccupiedVehicle (src) if getVehicleOverrideLights (vehicle) == 1 then setVehicleOverrideLights (vehicle, 2) outputChatBox ("Luzes ligadas!", src, 0, 255, 0) setElementData(vehicle,"lightson") else setVehicleOverrideLights (vehicle, 1) outputChatBox ("Luzes desligadas!", src, 255, 0, 0) setElementData(vehicle,"lightsoff") end else return false end end addCommandHandler ("luzes", lights) 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