30.12.2011, 16:02
Right Code:
Код:
if(strcmp(cmd, "/givemoney", true) == 0) { new string[128]; new playermoney; new sendername[MAX_PLAYER_NAME]; new giveplayer[MAX_PLAYER_NAME]; new giveplayerid, moneys; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>"); return 1; } giveplayerid = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>"); return 1; } moneys = strval(tmp); if (IsPlayerConnected(giveplayerid) && giveplayerid != INVALID_PLAYER_ID && giveplayerid != playerid) { 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 gave %s(%d), Money Amount: $%d.", giveplayer,giveplayerid, moneys); SendClientMessage(playerid, COLOR_GREEN, string); format(string, sizeof(string), "You got $%d from %s(%d).", moneys, sendername, playerid); SendClientMessage(giveplayerid, COLOR_GREEN, string); PlayerPlaySound(playerid,1084,0.0,0.0,0.0); printf("%s(%d) has transfered %d to %s(%d)",sendername, playerid, moneys, giveplayer, giveplayerid); } else { SendClientMessage(playerid, COLOR_RED, "Invalid amount!"); } } else { format(string, sizeof(string), "ERROR: Player Is Not Connected or Its Yourself!"); SendClientMessage(playerid, COLOR_RED, string); } return 1; }