pa3ck Posted October 10, 2013 Share Posted October 10, 2013 Hello there, I'm learning to use SQLite and I'm not sure about 1,2 things that are written on wiki. function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money setAccountData ( playeraccount, "piraterpg.money", playermoney ) -- save it in his account end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "piraterpg.money" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) This is the example given on the wiki and the line I'm not sure about is this: function onPlayerLogin (_, playeraccount ) -- Whats the "_," for? Also whats the "playeraccount" for? Link to comment
myonlake Posted October 10, 2013 Share Posted October 10, 2013 https://wiki.multitheftauto.com/wiki/OnPlayerLogin Parameters: account thePreviousAccount, account theCurrentAccount, bool autoLogin _ means nothing, but it's used for simply just "skipping" the parameter. It doesn't actually skip it, but just assigns it to the _ variable. It's better than using a long variable name like "oldPlayerAccountName". playeraccount is, like explained in the event parameters, the current account of the player. Link to comment
pa3ck Posted October 10, 2013 Author Share Posted October 10, 2013 Oh, okay, thanks, got it now. 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