Jump to content

Event is not added :/


Sasu

Recommended Posts

Server:

avion = createVehicle(592, -1673, -182, 15) 
conductor = createPed(1, -1673, -182, 15) 
  
function warpearped() 
setElementRotation(avion, 0, 0, 317.08401489258) 
warpPedIntoVehicle(conductor, avion) 
triggerClientEvent("onDriver", resourceRoot, conductor) 
end 
addEventHandler("onResourceStart", resourceRoot, warpearped) 
  

Client:

function ped(conductor) 
setPedControlState ( conductor, "special_control_down", true ) 
end 
addEvent("onDriver", true) 
addEventHandler("onDriver", resourceRoot, ped) 
  

And on debug appears: Server triggered clientside event onDriver, but event is not added clientside

Any help? :/

Link to comment

When resource starts on the server, there's no way for it to have started and added an event on the client. You have to make sure that script is already running on the client when you trigger an event. There are easier ways to pass the element, such as using element ID functions:

setElementID 
getElementByID 

It's simple, you set the element ID server-side and get the element from ID on the client. Then you can use setPedControlState on it.

Link to comment
Add a little timer in server to let the client add the event before triggering it
setTimer(function() triggerClientEvent("onDriver", resourceRoot, conductor) end,100,1) 

No, don't do this. Doing this means assuming that the client-side script is guaranteed to start in 100 ms. This assumption is incorrect.

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