12.04.2009, 17:54
Ok this code does work but i wondering if this is fully optimised... If not pls tell me woot I can make better. I try to learn dcmd 

Код:
dcmd_givecash(playerid, params[]) { new sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], giveplayerid, playermoney, string[128], moneys; if (sscanf(params, "dd", giveplayerid, moneys)) { SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid] [amount]"); return 1; } 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); printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid); } else { SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount."); } } else { format(string, sizeof(string), "%d is not an active player!", giveplayerid); SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; }