Chris!i! Posted January 17, 2016 Share Posted January 17, 2016 setAccountData(playerAccount, "piraterpg.money", playerMoney) I have read wiki of setAccountData but whats this piraterpg.money i didnt understand it. if u need the code i made i can post it Link to comment
tosfera Posted January 17, 2016 Share Posted January 17, 2016 setAccountData is actually the same construct as setElementData, it just gets saved into the account from the player. The player has to be logged in before this'll work. The parameters are as following: account theAccount, string key, mixed value Meaning that theAccount would be the account gotten with getPlayerAccount, the key is something you made up and the value is the actual value you want to give it. A few examples can be; local playerAccount = getPlayerAccount ( thePlayer ) setAccountData ( playerAccount, "username", "John" ) setAccountData ( playerAccount, "password", "Doe" ) setAccountData ( playerAccount, "email", "[email protected]" ) Link to comment
Chris!i! Posted January 17, 2016 Author Share Posted January 17, 2016 function onPlayerQuit() local playeraccount = getPlayerAccount(source) if (playerAccount) then local walk = getPedWalkingStyle(source) setAccountData(playeraccount, "walkingstyle", walk) end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) -- add an event handler ---------------------------------------------------- ---------------------------------------------------- function onPlayerLogin() local playerAccount = getPlayerAccount(source) -- get his account if (playerAccount) then local walk = getAccountData(playerAccount, "walkingstyle") if (walk) then setPedWalkingStyle(source, walk) end end end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) Ok what should i do know since i didnt understand anything. Link to comment
Addlibs Posted January 17, 2016 Share Posted January 17, 2016 Think of the account data key as a variable or a Lua table key Link to comment
Army@1 Posted January 17, 2016 Share Posted January 17, 2016 (edited) setAccountData(playerAccount, "piraterpg.money", playerMoney) Here, 'piraterpg.money' is a key and 'playerMoney' money is a value. The key can have any name 'acb', '12jsdhi', 'MyMoney', etc.. And the value can have things like player's weapon, money, position, rotation, health state, etc.. You can think of keys as variables and values as definitions. Example:- So lets say a player have $1650 cash when he quit the game. And you want to give player the amount of money he left the game with, which is $1650, when he join the game again. So when he quit, you would save his money by doing playerMoney = getPlayermoney(player) -- player's money which is 1650 playerAccount = getPlayerAccount(player) -- player's account setAccountData(playerAccount,"poorPlayerMoney",playerMoney) -- save player's money to his account with key 'poorPlayerMoney' And when he join, you would load his money by doing playerAccount = getPlayerAccount(player) -- player's account playerMoney = getAccountData(playerAccount,"poorPlayerMoney") -- will return 1650 givePlayerMoney(player, playerMoney) -- will give 1650 to player And I added comments to your last code. function onPlayerQuit_handler() local playerAccount = getPlayerAccount(source) -- get player account if (playerAccount) then -- if player has an account or account exist local walk = getPedWalkingStyle(source) -- get the current walking style of player and set it to variable 'walk'. setAccountData(playerAccount, "walkingstyle", walk) -- save/set player's walking style in player's account [data] with key 'walkingstyle' end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit_handler) -- trigger the function when player quit ---------------------------------------------------- ---------------------------------------------------- function onPlayerLogin_handler() local playerAccount = getPlayerAccount(source) -- get player account if (playerAccount) then -- if player has an an account or account exist local walk = getAccountData(playerAccount, "walkingstyle") -- load/get player's walking style with key 'walkingstyle' which was previously saved in his account if (walk) then -- if player's account data exist with key 'walkingstyle' or succesfully got player's account data with key 'walkingstyle setPedWalkingStyle(source, walk) -- set player's walking style to it(previous one) end end end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin_handler) -- trigger the function when player login Hope it helps. Edited January 17, 2016 by Guest Link to comment
Addlibs Posted January 17, 2016 Share Posted January 17, 2016 setAccountData(playerAccount, "piraterpg.money", playerMoney)Here 'piraterpg.money' is a key and 'playerMoney' money is a variable. I find it more helpful to think of 'piraterpg.money' as a variable and playerMoney as its definition Link to comment
Army@1 Posted January 17, 2016 Share Posted January 17, 2016 setAccountData(playerAccount, "piraterpg.money", playerMoney)Here 'piraterpg.money' is a key and 'playerMoney' money is a variable. I find it more helpful to think of 'piraterpg.money' as a variable and playerMoney as its definition Oops, corrected. Link to comment
Chris!i! Posted January 17, 2016 Author Share Posted January 17, 2016 Okay thanks for letting me understand this so the key can be anything, okay i got it, i will test it after some minutes and tell you the result thank you everyone Link to comment
Chris!i! Posted January 18, 2016 Author Share Posted January 18, 2016 Still doesnt work. 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