Jump to content

executeCommandHandler with an event, on server-side.


Danii.-

Recommended Posts

Hello guys! I have another problem. (/question) 

I am begginer in scripting, so sorry if it's a stup1d question... :D Is it possible to connect executeCommandHandler with an Event? Or if not do you have any ideas how to do it?

It always gives me this error code: Bad argument @ 'executeCommandHandler' [Expected element  at argument 2, got nil ] 

( I am triggering the "fwheelset" event from the client-side with triggerServerEvent. )

function elsokerek( localPlayer, theVehicle ) 
    local veh = getPedOccupiedVehicle ( localPlayer )   
    if veh then  -- If valid vehicle
        local success = setVehicleHandling ( veh, "driveType", "fwd" )  -- Set the vehicle's drivetype
        
        if success then -- If it was succesful
           outputChatBox ( "oksa", source )
end 
end
end
addCommandHandler("fwd", elsokerek)

addEvent("fwheelset",true) 
function setf ( playerSource )
  executeCommandHandler ( "fwd", playerSource, "" )
end 
addEventHandler("fwheelset", root, setf) 
Link to comment
  • Moderators
30 minutes ago, Danii.- said:
addEvent("fwheelset",true) 
function setf ( playerSource )
  executeCommandHandler ( "fwd", playerSource, "" )
end 
addEventHandler("fwheelset", root, setf) 

According to the warning, playerSource is nil.

Try this:

addEvent("fwheelset",true) 
function setf ( )
  executeCommandHandler ( "fwd", client, "" )
end 
addEventHandler("fwheelset", root, setf) 

 

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