Jump to content

Giving money to players


DakiLLa

Recommended Posts

in example what is "piraterpg.money" in setaccountdata and getaccountdata ? it's current file in which saves information of players or not ?
Example

For a pirate roleplaying gametype, the amount of money a player has is made persistent by storing it in his account. Note the code uses "piraterpg.money" as key instead of just "money", as the player may be participating in other gametypes that also save his money amount to his account. If both gametypes would use "money" as the account key, they'd overwrite each other's data.

Link to comment

Function setAccountData doesn't work as it should. Some people say it does work but I've never managed to make it work (even the way they said).

setAccountData removes all the accounts from accounts.xml file when server stops.

Link to comment
  • 1 month later...

Just in case you didn't already notice - the script provided above will make that command available on the server - and unless you restrict it in the ACL, it'll be available to all players. So anybody could give themselves money, thus defeating the purpose of having money on most servers. We could all be chairmen of the Federal Reserve.

Link to comment
  • 2 weeks later...
function onJoin(thePlayer) 
        local account = getClientAccount(thePlayer) 
        local money = getAccountData(account, "players/Player.money") 
        setPlayerMoney(thePlayer, money) 
end 
  
function giveCash(thePlayer, commandName, amount) 
        local account = getClientAccount(source) 
        local admin = getAccountData(account, "players/Player.admin") 
        if(admin >= 1) 
            local name1 = getClientName(source) 
            local name2 = getClientName(thePlayer) 
            givePlayerMoney(thePlayer, amount) 
            outputChatBox("Admin "..name1.." has given you $"..amount, thePlayer,0,255,255) 
            outputChatBox("You have given "..name2.." $"..amount, thePlayer,0,255,255) 
end 
  
addCommandHandler("givecash", giveCash) 

Of course you still need to use setAccountData when the player joins. So, that script doesn't entirely work yet.

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...