Jump to content

Money save. Searched on wiki


bartje01

Recommended Posts

  • Discord Moderators

I don't think there's a wiki page with this exact purpose, however if you want this to work for dudes with an account only, use setAccountData.

Else use databases to store money amount along with player serial

Link to comment

wiki isn't containing all ready scripts (or solutions) how to solve your every idea..

events:

onPlayerQuit

onPlayerLogout (remember to set player money to zero after logout to avoid bug using!)

onPlayerLogin

functions:

getPlayerMoney

getPlayerAccount

isGuestAccount

getAccountData

setAccountData

setPlayerMoney

btw: isn't such script on community? i can remember several of them..

Link to comment

alright. I'm going to try. I don't think I will succeed. I hope one of you can script it for me but I don't want to ask a to big question :P

edit":

found this somewhere.

Doesn't work though

  
     
     
     
     
     
          function onPlayerQuit ( ) 
      -- when a player leaves, store his current money amount in his account data 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getPlayerMoney ( source ) 
            setAccountData ( playeraccount, "savemoney.money", playermoney ) 
      end 
end 
  
function onPlayerJoin ( ) 
      -- when a player joins, retrieve his money amount from his account data and set it 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "savemoney.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 ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) 
  
  

Edited by Guest
Link to comment

ye I understand.

As in my edit;

I've got this:

  
     
     
     
     
     
          function onPlayerQuit ( ) 
      -- when a player leaves, store his current money amount in his account data 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getPlayerMoney ( source ) 
            setAccountData ( playeraccount, "savemoney.money", playermoney ) 
      end 
end 
  
function onPlayerJoin ( ) 
      -- when a player joins, retrieve his money amount from his account data and set it 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "savemoney.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 ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) 
  

just doesn't work.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...