justn Posted March 14, 2014 Share Posted March 14, 2014 (edited) So, I would like it, so if the player has joined the server and logged in for the first time, then he will be spawned at the position below function assigntheteam () setPlayerTeam ( source, Unemployed ) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setCameraTarget(source, source) end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) otherwise, if he has joined the server before. then, his 'Skin,Team,Money,Position' will save. Edited March 14, 2014 by Guest Link to comment
JR10 Posted March 14, 2014 Share Posted March 14, 2014 You can use onPlayerLogin and accounts data for that. On login set an account data to identify whether he logged in before or not. function onLogin(old, acc) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then --new player, spawn him setAccountData(acc, 'firstTime', 'true') end end Link to comment
justn Posted March 14, 2014 Author Share Posted March 14, 2014 You can use onPlayerLogin and accounts data for that. On login set an account data to identify whether he logged in before or not. function onLogin(old, acc) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then --new player, spawn him setAccountData(acc, 'firstTime', 'true') end end Full code please? Link to comment
Moderators Citizen Posted March 14, 2014 Moderators Share Posted March 14, 2014 You can use onPlayerLogin and accounts data for that. On login set an account data to identify whether he logged in before or not. function onLogin(old, acc) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then --new player, spawn him setAccountData(acc, 'firstTime', 'true') end end Full code please? Just try, you are supposed to work for your server. Link to comment
Anubhav Posted March 14, 2014 Share Posted March 14, 2014 Click on setAccountData. You'll need to create savers. Find at community. There are many examples Link to comment
justn Posted March 14, 2014 Author Share Posted March 14, 2014 Okay , so if the player is new, he will spawn at the XYZ position below. that works but the problem is, so what im trying to do below is when the player quits, i want it to get the player's last position, and when the player logs in again, he will spawn at the last position he was before he had quit the server. function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source, 'playerAcc' ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerXYZ = getElementPosition ( source ) setAccountData ( playeraccount, "playerPosition", playerXYZ ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onLogin (old, acc) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then setPlayerTeam ( source, Unemployed ) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setCameraTarget(source, source) setAccountData(acc, 'firstTime', 'true') else if (playeraccount) then if (firstTime) then local playerXYZ = getAccountData ( playeraccount, "playerPosition" ) if ( playerXYZ ) then setElementPosition ( source, playerXYZ ) end end end end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), onLogin ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onLogin ) Link to comment
Saml1er Posted March 14, 2014 Share Posted March 14, 2014 1# When you use else statement then you can't use if statement again unless you add an "end" statement. 2# its not playerXYZ but in fact its local x,y,z = getElementPosition ( source ) 3# How do you trigger "IfNewPlayerJoin" event? You must use triggerEvent if the player is new 4# This code is a mess, too many errors. I'm on mobile can't help you but I hope someone helps you to fix it. Link to comment
justn Posted March 14, 2014 Author Share Posted March 14, 2014 1# When you use else statement then you can't use if statement again unless you add an "end" statement.2# its not playerXYZ but in fact its local x,y,z = getElementPosition ( source ) 3# How do you trigger "IfNewPlayerJoin" event? You must use triggerEvent if the player is new 4# This code is a mess, too many errors. I'm on mobile can't help you but I hope someone helps you to fix it. Actually, this was just an example to show you guys what I wanted. but nvm, i fixed it, thanks though 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