Jump to content

[help] set and get VehicleEngineState


#RooTs

Recommended Posts

What is wrong ?

I need to do it that way because of triggerClientEvent

function switchEngine ( ) 
    local vehicle = getPedOccupiedVehicle(source) 
        if ( vehicle ) then 
            if getVehicleEngineState ( vehicle ) then 
                setVehicleEngineState ( vehicle, true ) 
                triggerClientEvent ( "motLigado", source ) 
            else 
                setVehicleEngineState ( vehicle, false ) 
                triggerClientEvent ( "motDesligado", source ) 
            end 
        end 
    end 
addEvent("motor", true) 
addEventHandler("motor", root, TrancarVeiculo) 

found other means to make, on / off. evil can not use triggerClientEvent

function switchEngine ( ) 
    local vehicle = getPedOccupiedVehicle(source) 
        if not vehicle then return end 
            local state = getVehicleEngineState ( vehicle ) 
        setVehicleEngineState ( vehicle, not state ) 
    end 
addEvent("motor", true) 
addEventHandler("motor", root, switchEngine)) 

Any solution ?

Link to comment
What is wrong ?

I need to do it that way because of triggerClientEvent

function switchEngine ( ) 
    local vehicle = getPedOccupiedVehicle(source) 
        if ( vehicle ) then 
            if getVehicleEngineState ( vehicle ) then 
                setVehicleEngineState ( vehicle, true ) 
                triggerClientEvent ( "motLigado", source ) 
            else 
                setVehicleEngineState ( vehicle, false ) 
                triggerClientEvent ( "motDesligado", source ) 
            end 
        end 
    end 
addEvent("motor", true) 
addEventHandler("motor", root, TrancarVeiculo) 

found other means to make, on / off. evil can not use triggerClientEvent

function switchEngine ( ) 
    local vehicle = getPedOccupiedVehicle(source) 
        if not vehicle then return end 
            local state = getVehicleEngineState ( vehicle ) 
        setVehicleEngineState ( vehicle, not state ) 
    end 
addEvent("motor", true) 
addEventHandler("motor", root, switchEngine)) 

Any solution ?

What do you mean by not being able to use triggerClientEvent?

You can trigger client events from clientside using triggerEvent.

Same for server.

Bonsai

Link to comment

@Bonsai

my client

function Locked (_,state) 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if theVehicle and getVehicleController(theVehicle) == localPlayer then 
        if painel == true then 
            if state == "down" then 
                if isCursorOnElement (botX+sizeX+735, 240, 42, 16) then -- motor 
                triggerServerEvent ("motor", getLocalPlayer()) 
                end 
            end 
        end 
    end 
end 
addEventHandler ("onClientClick", root, Locked) 

I'm using only 1 button / click. likewise, I can not use 2 Trigger Event

Link to comment
Ignore what I put here, what the hell are you talking about?

:shock:

I just added, "not" in my code. and it was resolved

if not getVehicleEngineState ( vehicle ) then 

function VehicleEngineState ( ) 
    local vehicle = getPedOccupiedVehicle(source) 
        if ( vehicle ) then 
            if not getVehicleEngineState ( vehicle ) then 
                setVehicleEngineState ( vehicle, true ) 
                triggerClientEvent ( "motLigado", source ) 
            else 
                setVehicleEngineState ( vehicle, false ) 
                triggerClientEvent ( "motDesligado", source ) 
            end 
        end 
    end 
addEvent("motor", true) 
addEventHandler("motor", root, VehicleEngineState) 

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...