kewizzle Posted July 17, 2014 Share Posted July 17, 2014 okay so heres what i have done so far... Server function spawnCarrr() admin = getLocalPlayer() x, y, z = getElementPosition( admin ) createVehicle(411, x+3, y+3, z) end addEvent("spawnCarrr", true) addEventHandler("spawnCarrr", root, spawnCarrr) Client function spawnCarr() triggerServerEvent("spawnCarrr", root) end it all works i just need a way to make getLocalPlayer work on server side it there another Event that can be used or what? Cause if i put the vehicle spawn script client side it works right but non drivable.. Link to comment
12p Posted July 17, 2014 Share Posted July 17, 2014 (edited) getLocalPlayer() is only client-side, it does nothing on your current code. This is a working code. Read the notes I left below, so you learn why is this working: Server function spawnCarrr() local x, y, z = getElementPosition( client ) createVehicle(411, x+3, y+3, z) end addEvent("spawnCarrr", true) addEventHandler("spawnCarrr", root, spawnCarrr) Client function spawnCarr() triggerServerEvent("spawnCarrr", root) end NOTES: "client" is a player element parameter passed by any client-triggered event, read more at https://wiki.multitheftauto.com/wiki/TriggerServerEvent "local x,y,z" is a setup so those 3 variables don't get in the way for other functions that use the same variable names. Read more at http://www.lua.org/pil/4.2.html Edited July 17, 2014 by Guest Link to comment
manawydan Posted July 17, 2014 Share Posted July 17, 2014 try -- server function spawnCarrr() x, y, z = getElementPosition( source ) createVehicle(411, x+3, y+3, z) end addEvent("spawnCarrr", true) addEventHandler("spawnCarrr", root, spawnCarrr) --client function spawnCarr() triggerServerEvent("spawnCarrr", localPlayer) end Link to comment
manawydan Posted July 17, 2014 Share Posted July 17, 2014 or -- server function spawnCarrr(p) x, y, z = getElementPosition( p ) createVehicle(411, x+3, y+3, z) end addEvent("spawnCarrr", true) addEventHandler("spawnCarrr", root, spawnCarrr) --client function spawnCarr() triggerServerEvent("spawnCarrr",root,localPlayer) end or -- server function spawnCarrr(x,y,z) createVehicle(411, x+3, y+3, z) end addEvent("spawnCarrr", true) addEventHandler("spawnCarrr", root, spawnCarrr) --client function spawnCarr() local x, y, z = getElementPosition( localPlayer) triggerServerEvent("spawnCarrr",root,x,y,z) end Link to comment
kewizzle Posted July 17, 2014 Author Share Posted July 17, 2014 cause i mispelled the function in the post its been changed to 3 Rs lol my bad but thanks wow i just learned so much from that client shit u just laid down there lmfao 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