Saml1er Posted October 11, 2013 Share Posted October 11, 2013 (edited) Hello, I want to learn more about getElementData and so on after spending 5 hours on wiki I made some code but it's not working the way I want it to work. I want it save the player's serial,account info whenever he leaves and joins ( for everyone ) and when I execute this command "/srl" and I want to get the serial and previous account, sadly I can't get the previous account + it's giving me the account details of player who logged in. function onPlayerQuit ( previous_Account, Current_Account ) local playerAccount = getAccountData (source) if (playerAccount) then local playerserial = getPlayerSerial ( source ) local playername = getPlayerName ( source ) local previous = getAccountName ( previous_Account ) local current = getAccountName ( Current_Account ) setAccountData ( playerAccount, "piraterpg.current", current ) setAccountData ( playerAccount, "piraterpg.previous", previous ) setAccountData ( playerAccount, "piraterpg.serial", playerserial ) end end function onPlayerLogin ( ) local playerAccount = getAccountData (source) if (playerAccount) then getAccountData ( playerAccount, "piraterpg.serial" ) getAccountData ( playerAccount, "piraterpg.current" ) getAccountData ( playerAccount, "piraterpg.previous" ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addCommandHandler ("srl", function ( ) local playerAccount = getAccountData(source) if ( playerAccount ) then local serialss = getAccountData ( playerAccount, "piraterpg.serial" ) local currents = getAccountData ( playerAccount, "piraterpg.current" ) local previous = getAccountData ( playerAccount, "piraterpg.previous" ) outputChatBox ( "* "..playeraccount.." found on serial: "..serialss..": "..currents..", "..previous, source, 255, 255, 0, true ) end end ) Edited October 11, 2013 by Guest Link to comment
myonlake Posted October 11, 2013 Share Posted October 11, 2013 The code is a total disaster. addEventHandler("onPlayerQuit", root, function() local account = getPlayerAccount(source) if (not account) then return end setAccountData(account, "player.lastSerial", getPlayerSerial(source)) setAccountData(account, "player.lastNick", getPlayerName(source)) end ) Whenever you want the last serial or nick, use getAccountData() to fetch it. Link to comment
Saml1er Posted October 11, 2013 Author Share Posted October 11, 2013 Thanks. I never used setAccountData so I had no idea how it works. Thank you so much mate. 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