SA-MP Forums Archive
[HELP] Money command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Money command (/showthread.php?tid=300292)



[HELP] Money command - V4at - 29.11.2011

I need a command that takes the money, the amount of typing.


Re: [HELP] Money command - BoboRi - 29.11.2011

you wan't that someone writes a command for you?

this is a place where you can try to write, post us your trying and then we try to help you


Re : [HELP] Money command - V4at - 29.11.2011

example: /money [playerid] [money]


Re : [HELP] Money command - V4at - 29.11.2011

And takes the money, not give.


Re: [HELP] Money command - Kostas' - 29.11.2011

pawn Code:
#define COLOR_RED 0xFF0000AA

CMD:pay(playerid,params[])
{
    new
        ID,
        amount,
        name[MAX_PLAYERS],
        string7[200],
        name2[MAX_PLAYERS],
        string8[200];
    if(sscanf(params, "ui", ID,amount)) return SendClientMessage(playerid, -1, "Usage: /pay [playerid] [amount]");
    if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "[ERROR]: You do not have enough money to pay that player!");
    if(amount <= 0) return SendClientMessage(playerid, -1, "[ERROR]: You cannot pay less than $1!");
    if(playerid == ID) return SendClientMessage(playerid, -1, "[ERROR]: You can't pay yourselve!");
    GetPlayerName(ID, name2, sizeof(name2));
    format(string8, sizeof(string8),"You have paid %s $%i", name2, amount);
    SendClientMessage(playerid, COLOR_RED, string8);
    GetPlayerName(playerid, name, sizeof(name));
    format(string7, sizeof(string7), "%s(%d) Has paid you: $%i", name, playerid, amount);
    SendClientMessage(ID, COLOR_RED, string7);
    GivePlayerMoney(ID, amount);
    GivePlayerMoney(playerid, -amount);
    return 1;
}



Re: [HELP] Money command - BoboRi - 29.11.2011

bro, you have to program the command...:

you should go to the http://wiki.sa-mp.com and learn the basics....

the things you need for this command is GivePlayerMoney https://sampwiki.blast.hk/wiki/GivePlayerMoney
and the ZCMD command processor becouse it is faster then strcmp

CMD:givemoney(playerid, params[])
{
GivePlayerMoney(ID_OF_THE_PLAYER, MONEY_TO_GIVE);
}


Re: [HELP] Money command - English-Conceptz - 29.11.2011

if its just in the script then this is fine, obviously replace 5000 with what ever number you wish to take from them.

GivePlayerMoney(playerid, -5000);

if you want to type how much to take use:

CMD:cashfrom(playerid, params[])
{
if ( sscanf( params, "ui", giveplayerid, level ) ) return SendClientMessage( playerid, RED, "USAGE: {FFFF00}/cashfrom [playerid] [cashamount" );
if ( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, RED, "Player Is Not Connected!" );
GivePlayerMoney(giveplayerid, -cashamount);
}



im not guna do it all for you else il get hated on but thats the basics of it. theres errors in the there and better ways to do it but thats off the top of my head


Re : [HELP] Money command - V4at - 29.11.2011

Thanks.


Re: [HELP] Money command - Kostas' - 29.11.2011

Quote:
Originally Posted by English-Conceptz
View Post
if its just in the script then this is fine, obviously replace 5000 with what ever number you wish to take from them.

GivePlayerMoney(playerid, -5000);

if you want to type how much to take use:

CMD:cashfrom(playerid, params[])
{
if ( sscanf( params, "ui", giveplayerid, level ) ) return SendClientMessage( playerid, RED, "USAGE: {FFFF00}/cashfrom [playerid] [cashamount" );
if ( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, RED, "Player Is Not Connected!" );
GivePlayerMoney(giveplayerid, -cashamount);
}



im not guna do it all for you else il get hated on but thats the basics of it. theres errors in the there and better ways to do it but thats off the top of my head
To paste someone code is a litlle...
Define the giveplayer etc.


Re : [HELP] Money command - V4at - 30.11.2011

This command is good, but throws an error, fixing that.

Code:
CMD:cashfrom(playerid, params[])
{
if ( sscanf( params, "ui", giveplayerid, level ) ) return SendClientMessage( playerid, RED, "USAGE: {FFFF00}/cashfrom [playerid] [cashamount" );
if ( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, RED, "Player Is Not Connected!" );
GivePlayerMoney(giveplayerid, -cashamount);
}