ODutii Posted August 3, 2019 Posted August 3, 2019 Não sei o que está dando errado, no console diz que carrovida <= 256 não se compara com o numero. function desligarcar() local theVehicle = getPedOccupiedVehicle(source) local carrovida = getElementHealth(theVehicle) if carrovida < 256 then setVehicleEngineState ( theVehicle, false ) outputChatBox("#BDBDBDVeículo quebrado, chame um mecânico.",source,0,255,0,true) setVehicleEngineState ( theVehicle, true ) end end addEventHandler("onVehicleDamage", root, desligarcar)
Eficiencia Posted August 3, 2019 Posted August 3, 2019 function desligarcar() local theVehicle = getPedOccupiedVehicle(source) local carrovida = getElementHealth(theVehicle) if carrovida <= 256 then setVehicleEngineState ( theVehicle, false ) outputChatBox("#BDBDBDVeículo quebrado, chame um mecânico.",source,0,255,0,true) setVehicleEngineState ( theVehicle, true ) end end addEventHandler("onVehicleDamage", root, desligarcar) Uma vida sem desafios não vale a pena ser vivida. Sócrates
Moderators Lord Henry Posted August 3, 2019 Moderators Posted August 3, 2019 (edited) Isso acontece pois source não é um jogador no evento onVehicleDamage e sim o veículo que recebeu o dano. Isso significa que getPedOccupiedVehicle está retornando false. E getElementHealth (false) nunca vai retornar algo também. Ele está reclamando que não tem como fazer a comparação if false < 256 then. function desligarcar () local carrovida = getElementHealth (source) local thePlayer = getVehicleController (source) if (carrovida < 256) then setVehicleEngineState (source, false) if (isElement (thePlayer)) then outputChatBox ("Seu veículo quebrou, chame um mecânico.", thePlayer, 189, 189, 189) end end end addEventHandler ("onVehicleDamage", root, desligarcar) Edited August 3, 2019 by Lord Henry Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
DNL291 Posted August 3, 2019 Posted August 3, 2019 Você já havia postado o mesmo tópico aqui: @ODutii Não precisa criar outro tópico, só postar no primeiro. Please do not PM me with scripting related question nor support, use the forums instead.
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