justn Posted March 14, 2014 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 Datastore - Store data to a database quickly. (Useful for saving scripted tables)
JR10 Posted March 14, 2014 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 Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
justn Posted March 14, 2014 Author 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? Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Moderators Citizen Posted March 14, 2014 Moderators 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. The rEvolution is coming ...
Anubhav Posted March 14, 2014 Posted March 14, 2014 Click on setAccountData. You'll need to create savers. Find at community. There are many examples See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
justn Posted March 14, 2014 Author 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 ) Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Saml1er Posted March 14, 2014 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.
justn Posted March 14, 2014 Author 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 Datastore - Store data to a database quickly. (Useful for saving scripted tables)
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