dcmd_givecash < sending wrong message
#1

This is my command givecash and when I sen someone $5000 it shows $2 or $0. Anyway, it's wrong and I don't know what's causing it, the money increases with 5000 but it shows the wrong message.

pawn Код:
dcmd_givecash(playerid, params[])
{
    new amount, str[128];
    if(sscanf(params, "ud", giveplayerid, amount)) return SystemMessage(playerid, "USAGE: /givecash [playername/id] [amount]");
    if(!IsPlayerConnected(giveplayerid) || giveplayerid == playerid) return SystemMessage(playerid, "This player is not active.");
    if(amount < 1 || amount > GetPlayerMoney(playerid)) return SystemMessage(playerid, "Invalid amount.");
    GetName(playerid, playername);
    GetName(giveplayerid, giveplayer);
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    format(str, sizeof(str), "You have given $%d to %s.", amount, giveplayer, giveplayerid);
    SystemMessage(playerid, str);
    format(str, sizeof(str), "%s has given you $%d.", playername, playerid, amount);
    SystemMessage(giveplayerid, str);
    return 1;
}
Reply
#2

Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Put this code on your mode.
Reply
#3

Quote:
Originally Posted by Sebago[X
]
Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Put this code on your mode.
... I already have that one in my script.
Reply
#4

Quote:
Originally Posted by DarkPhoenix
This is my command givecash and when I sen someone $5000 it shows $2 or $0. Anyway, it's wrong and I don't know what's causing it, the money increases with 5000 but it shows the wrong message.

pawn Код:
format(str, sizeof(str), "%s has given you $%d.", playername, playerid, amount);
that's formatting "playername has given you $playerid" which if the playerid is 0 gives you $0 and if the playerid is 2 gives you $2
Reply
#5

Quote:
Originally Posted by cessil
Quote:
Originally Posted by DarkPhoenix
This is my command givecash and when I sen someone $5000 it shows $2 or $0. Anyway, it's wrong and I don't know what's causing it, the money increases with 5000 but it shows the wrong message.

pawn Код:
format(str, sizeof(str), "%s has given you $%d.", playername, playerid, amount);
that's formatting "playername has given you $playerid" which if the playerid is 0 gives you $0 and if the playerid is 2 gives you $2
So it will be fine if I use this?
pawn Код:
format(str, sizeof(str), "%s has given you $%d.", playername, amount);
Reply
#6

Quote:
Originally Posted by DarkPhoenix
So it will be fine if I use this?
pawn Код:
format(str, sizeof(str), "%s has given you $%d.", playername, amount);
Yeah, that will work. (AFAIK).
Reply
#7

Код:
	format(str, sizeof(str), "You have given $%d to %s.", amount, giveplayer);
	SystemMessage(playerid, str);
	format(str, sizeof(str), "%s has given you $%d.", playername, amount);
	SystemMessage(giveplayerid, str);
im sure this is right, test it out
Reply
#8

.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)