Mec.Love Posted July 23, 2022 Share Posted July 23, 2022 (edited) Então, estou com um script para falha de motores, quanto mais o estado de vida do veículo para decaindo ou motor falhar com mais frequência, porém eu queria que quando esse nível de vida não ligasse mais. Lado do cliente function vehiclefailures() failede = true local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and (getVehicleType(vehicle) == "Automobile")) then if getElementHealth(vehicle) < 550 then triggerServerEvent("Caroff", getRootElement(), vehicle) setTimer ( function() triggerServerEvent("Caron", getRootElement(), vehicle) end, 3000, 1 ) end end end addEventHandler("onClientVehicleDamage", root, vehiclefailures) addEventHandler("onClientVehicleEnter", root, vehiclefailures) function enginefailures() local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and (getVehicleType(vehicle) == "Automobile")) then if getElementHealth(vehicle) < 550 then if not failede then return end setTimer( function() if not failede then return end triggerServerEvent("failurex", getRootElement(), vehicle) triggerServerEvent("Caroff", getRootElement(), vehicle) local sound = playSound("failure.wav") setTimer ( function() triggerServerEvent("Caron", getRootElement(), vehicle) end, 3000, 1 ) failede = false setTimer( function() failede = true end, 25000, 1 ) end, 10, 1 ) end end end addEventHandler ( "onClientPreRender", root, enginefailures ) function enginesoundf() if not sounding then sound=playSound("failure.wav") setSoundVolume(sound, 0.5) setTimer ( function() sounding = true end, 5000, 1 ) end end addEvent ( "failureclient", true ) addEventHandler ( "failureclient", getRootElement ( ), enginesoundf ) Lado do servidor function turnEngineOff (vehicle) setVehicleEngineState ( vehicle, false ) end addEvent("Caroff", true) addEventHandler("Caroff", getRootElement(), turnEngineOff) function turnEngineOn (vehicle) setVehicleEngineState ( vehicle, true ) end addEvent("Caron", true) addEventHandler("Caron", getRootElement(), turnEngineOn) function carfailure (vehicle) if getElementHealth(vehicle) < 360 then return end setElementHealth(vehicle, getElementHealth(vehicle) - 10 ) end addEvent("failurex", true) addEventHandler("failurex", getRootElement(), carfailure) Edited July 23, 2022 by Mec.Love Link to comment
Other Languages Moderators Lord Henry Posted July 23, 2022 Other Languages Moderators Share Posted July 23, 2022 Pra começar, você precisa corrigir a indentação do seu código. Veja aqui como fazer isso: 1 Link to comment
Mec.Love Posted July 23, 2022 Author Share Posted July 23, 2022 (edited) Fiz, verifique para mim Lord se está correto. Cliente-side function vehiclefailures() failede = true local vehicle = getPedOccupiedVehicle(localPlayer) if (vehicle and (getVehicleType(vehicle) == "Automobile")) then if getElementHealth(vehicle) < 550 then triggerServerEvent("Caroff", getRootElement(), vehicle) setTimer(function() triggerServerEvent("Caron", getRootElement(), vehicle) end, 3000, 1) end end end addEventHandler("onClientVehicleDamage", root, vehiclefailures) addEventHandler("onClientVehicleEnter", root, vehiclefailures) function enginefailures() local vehicle = getPedOccupiedVehicle(localPlayer) if (vehicle and (getVehicleType(vehicle) == "Automobile")) then if getElementHealth(vehicle) < 550 then if not failede then return end setTimer(function() if not failede then return end triggerServerEvent("failurex", getRootElement(), vehicle) triggerServerEvent("Caroff", getRootElement(), vehicle) local sound = playSound("failure.wav") setTimer(function() triggerServerEvent("Caron", getRootElement(), vehicle) end, 3000, 1) failede = false setTimer(function() failede = true end, 25000, 1) end, 10, 1) end end end addEventHandler("onClientPreRender", root, enginefailures) function enginesoundf() if not sounding then sound = playSound("failure.wav") setSoundVolume(sound, 0.5) setTimer(function() sounding = true end, 5000, 1) end end addEvent("failureclient", true) addEventHandler("failureclient", getRootElement(), enginesoundf) Server-side function turnEngineOff(vehicle) setVehicleEngineState(vehicle, false) end addEvent("Caroff", true) addEventHandler("Caroff", getRootElement(), turnEngineOff) function turnEngineOn(vehicle) setVehicleEngineState(vehicle, true) end addEvent("Caron", true) addEventHandler("Caron", getRootElement(), turnEngineOn) function carfailure(vehicle) if getElementHealth(vehicle) < 360 then return end setElementHealth(vehicle, getElementHealth(vehicle) - 10) end addEvent("failurex", true) addEventHandler("failurex", getRootElement(), carfailure) Edited July 25, 2022 by Lord Henry server-side convertido de HTML para Lua Link to comment
Other Languages Moderators Lord Henry Posted July 25, 2022 Other Languages Moderators Share Posted July 25, 2022 Agora está certinha a indentação. Mais uma dica: Você pode trocar todos os getRootElement() por root 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