Script to get the player´s cash and bank money

Hi guys

I am looking for a script for admins or for the team to see the cash or money in the bank from players.

The best way is to enter the command “/showmoney [playerid]” as admin and then you can see the cash and money in the bank.

Is there such a script or is it hard to code one?
Thanks for your help!

1 Like

Hi. Not sure what framework you want this command to work for, but here’s an ESX, server sided example.

RegisterCommand('showmoney', function (source, args, rawCommand)
    if args[1] and tonumber(args[1]) then -- args[1] being the <id> in /showmoney <id>
        xTarget = ESX.GetPlayerFromId(args[1])
        local cash = xTarget.getMoney()
        local bank = xTarget.getAccount('bank').getMoney
        if cash and bank then
            -- change this trigger to whatever script displays your notifications
            TriggerClientEvent('yournotify:notify', source, "ID: "..args[1].." currently has $"..cash.." Cash and $"..bank.." on his bank account.")
        end
    else
        print('invalid input')
    end
end, true)

Wow, thank you very much. Im gonna try it soon :slight_smile:

But is it for a specific user group? only for admins?

If you use ESX, yes.

See, if you create a command server side, you can enter either true or false after the last end statement.

RegisterCommand('showmoney', function (source, args, rawCommand)
     -- do stuff
end, true) <----

True means only players with group.admin (the database entry, see photo, or the group.admin ace permission) can use the command.

image

You could also do it with ace permissions using;

if IsPlayerAceAllowed(source, 'ace_perm_name' then
    -- command
end

Many possibilities :wink:

Wow thats cool :slight_smile: Maybe I‘m starting with lua soon. Thank you very very much!