Jump to content

(executeCommandHandler) What is wrong here? [SOLVED]


KiffShark

Recommended Posts

Hi

I want that the button of a panel turn off/on the vehicle's engine... it works BUT I use a fuel resource that turn off the engine when there is no fuel... this button allows you to turn it on again... -__-

The fuel resource have got the command "engine" that works only if there is fuel in the vehicle so I want that this button executes this command..

This is what I've done: (but it doesn't work)

function engines() 
    local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if (theVehicle) then 
       local state = getVehicleEngineState ( theVehicle ) 
        if (state == true) then 
        executeCommandHandler ( "engine" ) --This command is from other resource 
--      setVehicleEngineState(theVehicle,false) --with this it works, but the command works only if there's fuel in the car 
        outputChatBox("*Motor apagado*",255,0,0) 
    else 
        executeCommandHandler ( "engine" ) --This command is from other resource 
--      setVehicleEngineState(theVehicle,true) --with this it works, but the command works only if there's fuel in the car 
        outputChatBox("*Motor arrancado*",255,0,0) 
      end 
  end 
end 
  

Maybe I can't execute commands from other resources?? :(

thanks!

Edited by Guest
Link to comment
function engines() 
   local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
   if (theVehicle) then 
   local state = getVehicleEngineState ( theVehicle ) 
   if (state == true) then 
 setVehicleEngineState(theVehicle, false) 
   elseif (state == false) then 
 setVehicleEngineState(theVehicle, true) 
end 
end 
end 
addCommandHandler("engine", engines) 

Link to comment

I have done:

server side

  
function engex( ) 
    executeCommandHandler ( "engine",source ) 
end 
addEvent("ex",true); 
addEventHandler("ex",getRootElement(),engex) 
  

client side

  
function engines() 
    local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if (theVehicle) then 
       local state = getVehicleEngineState ( theVehicle ) 
        if (state == true) then 
        triggerServerEvent("ex",localPlayer) 
        outputChatBox("*Motor apagado*",255,0,0) 
    else 
        triggerServerEvent("ex",localPlayer) 
        outputChatBox("*Motor arrancado*",255,0,0) 
      end 
  end 
end 
  

ERROR console:

access denied @ 'executeCommandHandler'
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...