if((strcmp("/givecash", cmdtext, true) == 0) || (strcmp("/gc", cmdtext, true) == 0))
{
new id, pos, pname[MAX_PLAYER_NAME], string[128];
if(strlen(cmdtext[10]) == 0) return SendClientMessage(playerid, red, "Use: /givecash [playerid] [ammount]");
if((pos = strfind(cmdtext, " ", true, 10)) != -1) return SendClientMessage(playerid, red, "Use: /givecash [playerid] [ammount]");
if(strval(cmdtext[10]) == 0)
{
for(new i; i < MAX_PLAYERS; i++)
{
GetPlayerName(i, pname, sizeof(pname));
if(strfind(pname, cmdtext[10], true) != -1)
{
id = i;
goto next;
}
}
return SendClientMessage(playerid, red, "Error: player not connected");
}
else
{
id = strval(cmdtext[10]);
}
next:
if(IsPlayerConnected(id) == 0) return SendClientMessage(playerid, red, "Error: player not connected");
if(strval(cmdtext[pos + 1]) < 0 || strval(cmdtext[pos + 1]) > 1000000) return SendClientMessage(playerid, red, "Error: Invalid amount");
GivePlayerMoney(id, strval(cmdtext[pos + 1]));
GetPlayerName(id, pname, sizeof(pname));
format(string, sizeof(string), "You have given %s (%d) $%d", pname, id, strval(cmdtext[pos + 1]));
SendClientMessage(playerid, yellow, string);
GivePlayerMoney(playerid, -strval(cmdtext[pos + 1]));
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s (%d) has given you $%d", pname, playerid, strval(cmdtext[pos + 1]));
SendClientMessage(id, yellow, string);
return 1;
}
new giveplayerid, moneys, idx;
new playermoney;
if(strcmp(cmd, "/givecash", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
if (IsPlayerConnected(giveplayerid))
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys)
{
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Invalid amount.");
}
}
else
{
format(string, sizeof(string), "%d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}
CMD:givemoney(playerid,params[]) { new moneys,giveplayerid,giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],playermoney[MAX_PLAYERS],string[64]; if (sscanf(params, "ud",giveplayerid, moneys)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /givemoney [playerid] [amount]"); if (IsPlayerConnected(giveplayerid)) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); playermoney[playerid] = GetPlayerMoney(playerid); if (moneys > 0 && playermoney[playerid] >= moneys) { GivePlayerMoney(playerid, (-moneys)); GivePlayerMoney(giveplayerid, moneys); format(string, sizeof(string), "You have sent %s (id: %d), $%d.", giveplayer,giveplayerid, moneys); SendClientMessage(playerid, COLOR_GREEN, string); format(string, sizeof(string), "You have recieved $%d from %s (id: %d).", moneys, sendername, playerid); SendClientMessage(giveplayerid, COLOR_GREEN, string); printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid); } else { SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid transaction amount."); } } else { format(string, sizeof(string), "ID:%d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_BRIGHTRED, string); } return 1; } |
Try This
Or Code: if(strcmp(cmd, "/givecash", true) == 0) { new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]"); return 1; } giveplayerid = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]"); return 1; } moneys = strval(tmp); if (IsPlayerConnected(giveplayerid)) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); playermoney = GetPlayerMoney(playerid); if (moneys > 0 && playermoney >= moneys) { GivePlayerMoney(playerid, (0 - moneys)); GivePlayerMoney(giveplayerid, moneys); format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys); SendClientMessage(playerid, COLOR_YELLOW, string); format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid); SendClientMessage(giveplayerid, COLOR_YELLOW, string); } else { SendClientMessage(playerid, COLOR_YELLOW, "Invalid amount."); } } else { format(string, sizeof(string), "%d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; } |
pawn Код:
pawn Код:
|
if (strcmp("/gc", cmdtext, true, 10) == 0)
{