01.11.2015, 05:55
this should work
PHP код:
CMD:givemoney(playerid,params[]) {
new moneys,giveplayerid,giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],string[128];
if (sscanf(params, "ud",giveplayerid, moneys)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "{FF9900}[USAGE]:- {FFFFFF}/givemoney {FFFF00}[playerid] [amount]");
// if (!IsNumeric(giveplayerid)) giveplayerid = ReturnPlayerID(giveplayerid);
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername));
new cash[2]; cash[0] = GetPlayerMoney(playerid); cash[1] = GetPlayerMoney(giveplayerid);
if (moneys > 0 && cash[0] >= moneys) {
GivePlayerMoney(playerid, cash[0]-moneys);
GivePlayerMoney(giveplayerid,cash[1]+moneys);
format(string, sizeof(string), "{FFFFFF}You Have Sent {FFFF00}%s [%d], {33CC33}$%d", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "{FFFFFF}You have received {33CC33}$%d {FFFFFF}From {FFFF00}%s [%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, "{FF9900}[BANK]:- {FFFFFF}Invalid transaction amount");
}
}
else {
format(string, sizeof(string), "{FFFF00}[ID:%d] {FFFFFF}Player not connected!", giveplayerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, string);
}
return 1;
}