Jump to content

TakeAccountMoney when he is offline


Annas

Recommended Posts

Posted

How can i take player money when he is offline?

i dont know if there is a function named

Take Account Money or something like that

i just wanna take a player money from his account when he is offline..

please help me , and thx.

Posted

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)

Posted

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.

Posted

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?

Posted

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) 

Posted

Fully code please, i do not understand anything!

command : /takemoney ACCname AMOUNT

please understand and help me ,kiss your hands!

Posted

We don't write code for you here. AMARANT already gave you an example. You seem to have already wrote part of your desired code anyway in your previous posts.

Posted
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"!

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