Jump to content

TriggerServerEvent not working (Nil value)


Recommended Posts

I'm very noob at scripting :' (, but i did this: (It's a script for the Imponte Deluxo of GTA Online)

 

Serverside:

function deluxe ( player )
	local vehicle = getPedOccupiedVehicle(player)
	if isElement(vehicle) then
		if getVehicleDoorOpenRatio(vehicle,5) > 0 then
			setVehicleDoorOpenRatio(vehicle,5,0,ms)
			setVehicleDoorOpenRatio(vehicle,4,0,ms)
			setVehicleDoorOpenRatio(vehicle,0,0,ms)
		else
			setVehicleDoorOpenRatio(vehicle,5,1,ms)
			setVehicleDoorOpenRatio(vehicle,4,1,ms)
			setVehicleDoorOpenRatio(vehicle,0,1,ms)
		end
	end
end
addEvent( "deluxo", true )
addEventHandler( "deluxo", resourceRoot, deluxe)

This function puts the Deluxo on flying mode, works fine if i use addCommandHandler instead addEventHandler...

Clientside:

triggerServerEvent ( "deluxo", resourceRoot)

this is the triggerServerEvent that is activated by BindKey (Shift)

but i got at line2 on serverside:

Bad Argument @ ´getPedoccupiedvehicle´ [Expected Ped at Argument 1, got nil]

I need help :( 

Link to comment
  • Moderators
function deluxe (  )
	local player = client

addEventHandler doesn't work the same as the addCommandHandler.

Use the predefined variable `client`, to get the player that did activate the event.

 

  • Like 1
Link to comment
2 minutes ago, IIYAMA said:

function deluxe (  )
	local player = client

addEventHandler doesn't work the same as the addCommandHandler.

Use the predefined variable `client`, to get the player that did activate the event.

 

Thx man!  it has helped me a lot!

  • Like 1
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...