Jump to content

TakeAccountMoney when he is offline


Annas

Recommended Posts

the money data name: money

can anyone state the client or server side script please?

i need it with command handler

I will show you my exemple , but i wanna fixed one ; and one working..

Wish you understand..

function something(player)

local amount = getaccountdata(player, "money")

if player(player=who will type the command) in team named "Staff" then

setAccountData(player, ..amount.., -THEMONEY)

end

addcommandhandler("setmoney", something)

the command must be (./takemoney ACCOUNT AMOUNT)

Link to comment

I understand what you want but you should do it by yourself because there is some stuff which should be set already on your server (like stored player team, money, etc.). You can set it with the functions I meant above. Moreover on the wiki page of those functions there is an example of storing a player's money.

Link to comment

Ok , this is good exemple, and 100% will be working

function something(player)

local amount = getaccountdata(player, "money")

if player(player=who will type the command) in team named "Staff" then

setAccountData(player, ..amount.., -THEMONEY)

end

addcommandhandler("setmoney", something)

(i know , i'll replace the team and others..)

but what about (-TheMoney) , i wont set money to him

i wanna take from him the money..

oh , wait ..

takePlayerMoney(player, amount)

i can make it

local acc = getaccountdata(player, "money")

takePlayerMoney(acc, amount)

? , it will work if he is offline right?

Link to comment

I can tell you that you should get player account at first. Then you have to retrieve the data you need. And after that you can set it to whatever you want. And yes, it will work offline. This is a simple example:

local account = getAccount("NAME_OF_THE_ACCOUNT") 
local money = getAccountData(account,"NAME_OF_THE_DATA") 
local newmoney = tonumber(money)-5000 
setAccountData(account,newmoney) 

Link to comment
addCommandHandler("takeaccmoney", function(player, cmd, account, moneyToTake) 
    if isObjectInACLGroup("user."..getAccountName(player), aclGetGroup("Admin")) then 
        local acc = getAccount(tostring(account)); 
        if (acc) then 
            setAccountData(acc, "YOUR.KEY", getAccountData(acc, "YOUR.KEY")-tonumber(moneyToTake)); 
            outputChatBox("Done!", player, 0, 255, 2); 
        end 
    end 
end); 

Replace "YOUR.KEY"!

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