DarkRP.PlayerWalletChanged

From Official DarkRP Wiki
Jump to: navigation, search
This page refers to DarkRP 2.4.3. This information may be incorrect as of later versions.
Check here for a up-to-date list of hooks.

Syntax

DescriptionCalled when someone's wallet changes
Syntax
GAMEMODE:PlayerWalletChanged(Player ply, number amount, number total)
Returnsmoney_amount (number): override for money amount after the transaction (see examples)

Arguments

  • ply (Player)
  • The player whose money changed

  • amount (number)
  • How much money was ADDED to the wallet (it's a negative number when money was REMOVED)

  • total (number)
  • How much money the player had BEFORE the transaction

    Examples

    Descriptionlogs money
    Code
    hook.Add( "PlayerWalletChanged", "example", function(ply, amount)
    	ply:ChatPrint(ply:Nick() .. " got $" .. amount)
    end)
    OutputA print message


    DescriptionPeople's money can't be more than the given limit . Put in a serverside Lua file to make it work.
    Code
    local limit = 200000
    hook.Add("PlayerWalletChanged", "WalletCap", function(ply, amount, total) 
        return math.Min(total + amount, limit) -- Return the minimum between the changed total and the limit
    end)
    OutputPeople never getting more than $200,000 in their wallets