bandi94 Posted August 6, 2011 Share Posted August 6, 2011 i am whit this script server side function spawn() local repulo1 = createVehicle(519,1949.039,-2494.000,14.539,0,0,90) local pilota1 = createPed(61,0,0,0) warpPedIntoVehicle(pilota1,repulo1) triggerClientEvent ( "fly", getRootElement(),pilota1) end addEventHandler("onResourceStart",root,spawn) client side function go(pilota1) setPedControlState(pilota1,"accelerate",true) setTimer(setPedControlState,4000,1,pilota1,"steer_back",true) setTimer(setPedControlState,10000,1,pilota1,"steer_back",false) end addEvent( "fly", true ) addEventHandler("fly",root,go) meta <meta> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> </meta> and i get " Server triggered clientside event fly, but event is not added clientside" hmm where I wrong Link to comment
BinSlayer1 Posted August 6, 2011 Share Posted August 6, 2011 the problem is that onResourceStart is fired before the client finishes up downloading. the clientside code will only exist after the download has completed. So when you run your script, the client doesn't know about the client data yet Change the event/handler to something you'll know the client had downloaded when you run it. Link to comment
JR10 Posted August 6, 2011 Share Posted August 6, 2011 Try: server side: function spawn() local repulo1 = createVehicle(519,1949.039,-2494.000,14.539,0,0,90) local pilota1 = createPed(61,0,0,0) warpPedIntoVehicle(pilota1,repulo1) triggerClientEvent ( "fly", getRootElement(),pilota1) end addEvent("onResourceDownloaded",true) addEventHandler("onResourceDownloaded",root,spawn) client side: addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent("onResourceDownloaded",getLocalPlayer()) end) function go(pilota1) setPedControlState(pilota1,"accelerate",true) setTimer(setPedControlState,4000,1,pilota1,"steer_back",true) setTimer(setPedControlState,10000,1,pilota1,"steer_back",false) end addEvent( "fly", true ) addEventHandler("fly",root,go) Not tested, but should work. Link to comment
DiSaMe Posted August 6, 2011 Share Posted August 6, 2011 There's no need to trigger events at all. It's much easier to do with setElementID and getElementByID. For example change triggerClientEvent line into something like: setElementID(pilota1,"pilot") Then in go function: local pilota1 = getElementByID("pilot") And attach go function to onClientResourceStart. Link to comment
BinSlayer1 Posted August 6, 2011 Share Posted August 6, 2011 @JR10 For every player in the server who finishes downloading, the serverside will be called (that means creating a bunch of unnecessary vehicles and peds) Link to comment
bandi94 Posted August 6, 2011 Author Share Posted August 6, 2011 ohhh thx for all and now I realized that i make a s**t bk the server side make's a plane whit a pilot and the client side script moves the planeand its visible to everyone but if i have 2 players each client side script it will control it in difrent sync and it will make a big s**t however i wana make 1 NPC plane but whit SetControlState i can't make it bk its only for player not work for created ped somebody some ideas how can i make it ( 1 plane controled by script visible to everyone in same time (sync for all player) takeoff fly land and back .....) 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