Sasu Posted April 11, 2013 Share Posted April 11, 2013 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
PaiN^ Posted April 11, 2013 Share Posted April 11, 2013 triggerClientEvent("onDriver", root, conductor) + Put the client file first in the meta.xml .. Link to comment
DiSaMe Posted April 11, 2013 Share Posted April 11, 2013 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
itoko Posted April 12, 2013 Share Posted April 12, 2013 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) Link to comment
DiSaMe Posted April 12, 2013 Share Posted April 12, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now