Jump to content

Triggering server event


Recommended Posts

This is on the client side

local vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
triggerServerEvent ( "invisibility", getLocalPlayer(), vehicle  )

This on server side

function invisibility ()
local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ) --get your current vehicle
   local driver = getVehicleOccupant ( vehicle )						
setElementAlpha ( vehicle, 0 )
   setElementAlpha ( driver, 0 )
   end
   addEvent ( "invisibility", true )
   addEventHandler ( "invisibility", getRootElement(), invisibility )

On debugscript it doesnt show anything and on the server console either

Link to comment

i think it should be like this:

function invisibility ( vehicle )
local driver = getVehicleOccupant ( vehicle )                  
setElementAlpha ( vehicle, 0 )
setElementAlpha ( driver, 0 )
end
 
addEvent ( "invisibility", true )
addEventHandler ( "invisibility", getRootElement(), invisibility )

you are sending 'vehicle' from client side to the server, so..i've added 'vehicle' argument in server side function.

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