How can I store someones cash and then give it back?
#1

I'm trying to do a command where, when activated, it'll get the amount of money the victim has and store it before reseting his cash. Then there will be another command to regive the victims it's stored money back.

How can I do such thing? I couldn't find a way to do it with GetPlayerMoney...
Reply
#2

Make a function for SetPlayerMoney:
PHP код:
new moneyfirst[MAX_PLAYERS];
stock SetPlayerMoney(playerid,moneyafter) {
 
moneyfirst[playerid]=moneyafter;
 
GivePlayerMoney(playerid,moneyafter-GetPlayerMoney(playerid));

Credits to DracoBlue^

Then make the command with: targetid & amount.
Reply
#3

Quote:
Originally Posted by Deroxi
Посмотреть сообщение
Make a function for SetPlayerMoney:
PHP код:
new moneyfirst[MAX_PLAYERS];
stock SetPlayerMoney(playerid,moneyafter) {
 
moneyfirst[playerid]=moneyafter;
 
GivePlayerMoney(playerid,moneyafter-GetPlayerMoney(playerid));

Credits to DracoBlue^

Then make the command with: targetid & amount.
What..? I don't think thats what I'm looking for.
What I want is to do something like this:

Код:
cmd:dosomething(playerid)
{
    command lines and stuff here...
    something to get and store the victim's ID current money here...
    ResetPlayerMoney(ID);
    return 1;
}

cmd:undosomething(playerid)
{
    command lines and stuff here...
    something to give the stored money from the other command back to the victim's ID here...
    return 1;
}
Reply
#4

Код:
new storedcash[MAX_PLAYERS];
cmd:dosomething(playerid)
{
    command lines and stuff here...
    something to get and store the victim's ID current money here...
    GetPlayerCash(playerid, storedcash[playerid]); playerid or whatever you want.
    ResetPlayerMoney(playerid);
    return 1;
}

cmd:undosomething(playerid)
{
    command lines and stuff here...
    something to give the stored money from the other command back to the victim's ID here...
    GivePlayerCash(playerid, storedcash[playerid]); //playerid or whatever it is.
    return 1;
}
Reply
#5

Quote:
Originally Posted by coool
Посмотреть сообщение
Код:
new storedcash[MAX_PLAYERS];
cmd:dosomething(playerid)
{
    command lines and stuff here...
    something to get and store the victim's ID current money here...
    GetPlayerCash(playerid, storedcash[playerid]); playerid or whatever you want.
    ResetPlayerMoney(playerid);
    return 1;
}

cmd:undosomething(playerid)
{
    command lines and stuff here...
    something to give the stored money from the other command back to the victim's ID here...
    GivePlayerCash(playerid, storedcash[playerid]); //playerid or whatever it is.
    return 1;
}
Didn't work, the victim's cash doesn't return...
Reply
#6

PHP код:

new OldMoney[MAX_PLAYERS];

CMD:reset(playeridparams[])
{
    
//code
    
OldMoney[playerid] = GetPlayerMoney(playerid);
    
ResetPlayerMoney(playerid);
    return 
1;
}

CMD:giveback(playeridparams[])
{
    
GivePlayerMoney(playeridOldMoney[playerid]);
    return 
1;

Reply
#7

Quote:
Originally Posted by Whatname
Посмотреть сообщение
PHP код:

new OldMoney[MAX_PLAYERS];
CMD:reset(playeridparams[])
{
    
//code
    
OldMoney[playerid] = GetPlayerMoney(playerid);
    
ResetPlayerMoney(playerid);
    return 
1;
}
CMD:giveback(playeridparams[])
{
    
GivePlayerMoney(playeridOldMoney[playerid]);
    return 
1;

Worked like a charm! Thanks Whatname
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)