Jump to content

Help in setEngineState y getVehicleID.


DaaNN

Recommended Posts

Hello everyone, sorry for my basic English.
Basically I am trying to "start" a vehicle, checking if the user belongs to "Basurero" and the vehicle is the ID 408 (garbage truck).

 

addCommandHandler("motor", function(player)
    if not notIsGuest(player) then
        local veh = player:getOccupiedVehicle()
        local seat = player:getOccupiedVehicleSeat()
        if veh and seat == 0 then
if getElementData(player, "Roleplay:trabajo") == "Basurero" && getVehicleID(id_vehicle) == 408 then
            local gas = getElementData(veh, "Fuel") or 0
            if gas >= 1 then 
                if not player:getData("EnGasolinera") then
                    if veh:getHealth() >= 300 then
                        if veh:getData('Motor') == 'apagado' then
                            MensajeRol(player, " esta encendiendo el motor del vehículo")
                            setTimer(function(player, veh)
                                veh:setEngineState(true)
                                veh:setData('Motor','encendido',false)
                                veh:setFrozen(false)
                            end, 2000, 1, player, veh)
                            for i,v in ipairs(getPlayersOverArea(player,13)) do
                                v:triggerEvent('SonidoEncenderVeh',v,'auto')
                            end
                        else
                            MensajeRol(player, " apago el motor del vehículo")
                            setTimer(function(player, veh)
                                veh:setEngineState(false)
                            --    veh:setFrozen(true)
                                veh:setData('Motor','apagado')
                            end, 200, 1, player, veh)
                        end
                     end
                end
            end
        end
    end
    end
end)

The problem is that if I run it that way, trying to "turn it on" shows me: ( bad argument @ "getVehicleID" [expected element at argument 1 got nil] ).
PS: I tried to change it to getElementModel, and so on and it keeps giving the same problem, any solution? Thanks.

I tried to seek help in the Spanish forums but I see that they are very inactive and I have tried several options and I cannot find a solution, sorry for the inconvenience.

Link to comment

Hello DaaNN,

you have posted in the Spanish forums just 8 hours ago. Next time try waiting a little longer before double-posting, okay?

To answer your question, the variable "id_vehicle" does not appear to be defined in your script. Try using getElementModel(veh) instead.

Edited by The_GTA
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...