ghassen14 Posted October 29, 2015 Posted October 29, 2015 Hello guys I need code whene the player die he should press a bind to respawn
Dimos7 Posted October 29, 2015 Posted October 29, 2015 function binds() bindKey(key, state, onWaste) end addEventHandler("onClientResourceStarts", getResourceRootElement(getThisResource()), binds) function onWaste() setElementPosition(localPlayer, x, y, z) end addEventHandler("onClientPlayerWasted", getRootElement(), onWaste) that is more les in client side if you wanrt it in server side just tell me key state and position you choose
ghassen14 Posted October 29, 2015 Author Posted October 29, 2015 function binds() bindKey(key, state, onWaste) end addEventHandler("onClientResourceStarts", getResourceRootElement(getThisResource()), binds) function onWaste() setElementPosition(localPlayer, x, y, z) end addEventHandler("onClientPlayerWasted", getRootElement(), onWaste) that is more les in client side if you wanrt it in server side just tell me key state and position you choose WHAT I WRITE IN CLIENT AND SERVER PLS
Addlibs Posted October 29, 2015 Posted October 29, 2015 WHAT I WRITE IN CLIENT AND SERVER PLSYou can stop writing in capital letters, for a start. The code which Dimos7 sent is client-side but you need to define the position, key & state (see below) beforehand, otherwise it won't work. local x, y, z = --the co-ordinates where you want people to respawn at local key = --the key to press to respawn local state = --whether the above key should be pressed or released, "down" or "up" accordingly. --place before Dimos7's code
ghassen14 Posted October 30, 2015 Author Posted October 30, 2015 WHAT I WRITE IN CLIENT AND SERVER PLSYou can stop writing in capital letters, for a start. Ok Sorry but its in TDM server Deathmatch match so every map have there spawn
brocky Posted October 30, 2015 Posted October 30, 2015 if you meant every team should have their own spawn then use this! use getTeamFromName(). here is the example. function binds() -- Made a bind event bindKey(s, "down", onWaste) -- You made a bind end addEventHandler("onClientResourceStarts", getResourceRootElement(getThisResource()), binds) function onWaste() -- Now this is the main function. team1 = getTeamFromName("tdm1") -- Remember! If you want to specify a team in those parenthesis then the team "should" actually exist else it won't recognize it . team2 = getTeamFromName("tdm2") -- Team2 won't be necessary but I am going to tell you a bit in beginner style. if team1 then setElementPosition(localPlayer, x, y, z ) else setElementPosition(localPlayer, l, m, n ) end end addEventEventHandler("onClientPlayerWasted", getRootElement(), onWaste) I am not too good in Lua, sorry if I made many mistakes.
ghassen14 Posted October 30, 2015 Author Posted October 30, 2015 if you meant every team should have their own spawn then use this!use getTeamFromName(). here is the example. function binds() -- Made a bind event bindKey(s, "down", onWaste) -- You made a bind end addEventHandler("onClientResourceStarts", getResourceRootElement(getThisResource()), binds) function onWaste() -- Now this is the main function. team1 = getTeamFromName("tdm1") -- Remember! If you want to specify a team in those parenthesis then the team "should" actually exist else it won't recognize it . team2 = getTeamFromName("tdm2") -- Team2 won't be necessary but I am going to tell you a bit in beginner style. if team1 then setElementPosition(localPlayer, x, y, z ) else setElementPosition(localPlayer, l, m, n ) end end addEventEventHandler("onClientPlayerWasted", getRootElement(), onWaste) I am not too good in Lua, sorry if I made many mistakes. So can you give me code of a little Messge ( Press a to Respawn )
Noki Posted October 30, 2015 Posted October 30, 2015 Line 5 should be: addEventHandler("onClientResourceStart", resourceRoot, binds)
brocky Posted October 30, 2015 Posted October 30, 2015 Since the script is client sided you can easily use "outputChatBox()" in "onWaste" function and type anything that you want.
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