Jump to content

Vehicle is broken


Recommended Posts

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)

 

Link to comment
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)

 

Link to comment
  • Other Languages Moderators

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 by Lord Henry
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...