Brad96 Posted June 12, 2015 Share Posted June 12, 2015 hi ,i want to explainme how i am use the bindKey function in server-side this is my script ,i want to create a vehicle when i press the key ,thanks function cas(player,key) x, y, z = getElementPosition(player) cs = createVehicle (411 ,x+5 ,y, z) css = createObject (359, x, y, z) css2 = createObject (359, x, y, z) x, y, z = getElementRotation ( cs ) attachElements ( css, cs, 1, 2, 0.20, 0, 0, 90) attachElements ( css2, cs, -1, 2, 0.20, 0, 0, 90) end addEventHandler("onResourceStart",getRootElement(),function () bindKey(player,"2","down",cas) end) Link to comment
Walid Posted June 12, 2015 Share Posted June 12, 2015 function FunctionName() for index, player in pairs(getElementsByType("player")) do bindKey(player,"2","down",cas) end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), FunctionName ) Link to comment
Brad96 Posted June 12, 2015 Author Share Posted June 12, 2015 thanks ,but with a simple functions ? Link to comment
Walid Posted June 12, 2015 Share Posted June 12, 2015 thanks ,but with a simple functions ? i think it's very simple Link to comment
Brad96 Posted June 12, 2015 Author Share Posted June 12, 2015 is this? function cas(player) x, y, z = getElementPosition(player) cs = createVehicle (411 ,x+5 ,y, z) css = createObject (359, x, y, z) css2 = createObject (359, x, y, z) x, y, z = getElementRotation ( cs ) attachElements ( css, cs, 1, 2, 0.20, 0, 0, 90) attachElements ( css2, cs, -1, 2, 0.20, 0, 0, 90) end function FunctionName() for index, player in pairs(getElementsByType("player")) do bindKey(player,"2","down",cas) end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), FunctionName ) Link to comment
Brad96 Posted June 12, 2015 Author Share Posted June 12, 2015 thanks so mucho but i dont understand this line for index, player in pairs(getElementsByType("player")) do you can explainme? pls Link to comment
Walid Posted June 12, 2015 Share Posted June 12, 2015 getElementsByType("player"): retrieves a table of the players in the server Link to comment
Brad96 Posted June 13, 2015 Author Share Posted June 13, 2015 and how i did the script whitout that line ,that function is complicated for me Link to comment
Tekken Posted June 13, 2015 Share Posted June 13, 2015 Try this: function FunctionName() bindKey(source, "2", "down", cas) end addEventHandler("onPlayerJoin", root, FunctionName) 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