rublisk19 Posted January 3, 2012 Share Posted January 3, 2012 (edited) Hi i need help to save ,load player position and spawn him. my scripts: function onLogin (_,account) setElementData(source, "MONEY", getAccountData(account, "money") or "1000") setElementData(source, "EXP", getAccountData(account, "exp") or "50") setElementData(source, "JOB", getAccountData(account, "job") or "BEDARBIS") local x, y, z = getAccountData(account, "x, y, z" or "196, -107, 1.5") setElementPosition ( source, x, y, z ) end addEventHandler ("onPlayerLogin", root, onLogin) function onQuit() local account = getPlayerAccount(source) if not account then return end if not isGuestAccount(account) then local x, y, z = getElementPosition (source) -- retrive the player's position setAccountData (account, "money", getElementData(source, "MONEY")) setAccountData (account, "exp", getElementData(source, "EXP")) setAccountData (account, "job", getElementData(source, "JOB")) setAccountData (account, "x, y, z", getElementPosition( source )) end end addEventHandler ("onPlayerQuit", root, onQuit) function spawnOnLogin (prevA, curA, autoLogin) local x, y, z = getElementData(source, "x, y, z") outputChatBox ("Sveikas atvykes y Lithuanian RPG serveri!!!", source, 255, 0, 0, false) local H = getElementData(source, "JOB") if tostring(H) == "BEDARBIS" then spawnPlayer (source, x, y, z) -- spawns player with turist skin fadeCamera (source, true) setCameraTarget (source, source) elseif tostring(H) == "POLICININKAS" then spawnPlayer (source, x, y, z) -- spawns player with police skin fadeCamera (source, true) setCameraTarget (source, source) elseif tostring(H) == "GAISRININKAS" then spawnPlayer (source, x, y, z) -- spawns player with police skin fadeCamera (source, true) setCameraTarget (source, source) elseif tostring(H) == "MEDIKAS" then spawnPlayer (source, x, y, z) -- spawns player with police skin fadeCamera (source, true) setCameraTarget (source, source) end end addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin) waiting for help ;] Edited January 3, 2012 by Guest Link to comment
FatalTerror Posted January 3, 2012 Share Posted January 3, 2012 Hi Try that: addEventHandler("onPlayerLogin", getRootElement(), function() local account = getPlayerAccount(source) if not isGuestAccount(account) then local x = getAccountData(account, "player-x") local y = getAccountData(account, "player-y") local z = getAccountData(account, "player-z") if x and y and z then spawnPlayer(source, x, y, z) outputChatBox("Welcome to our server !", source, 255, 255, 255, true) end end end) addEventHandler("onPlayerQuit", getRootElement(), function() local account = getPlayerAccount(source) if not isGuestAccount(account) then local x, y, z = getElementPosition(source) if x and y and z then setAccountData(account, "player-x", x) setAccountData(account, "player-y", y) setAccountData(account, "player-z", z) end end end) Link to comment
rublisk19 Posted January 3, 2012 Author Share Posted January 3, 2012 ok thanks everything works 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