31.10.2015, 14:10
PHP код:
ReturnName(playerid, underscore=1) // by Emmet_
{
static
name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
if (!underscore) {
for (new i = 0, len = strlen(name); i < len; i ++) {
if (name[i] == '_') name[i] = ' ';
}
}
return name;
}
CMD:givecash(playerid, params[])
{
new userid, amount, str[128];
if (!sscanf(params, "ui", userid, armount))
return SendClientMessage(playerid, -1, "usage: /givecash [playerid/name] [amount]");
if (userid == playerid || !IsPlayerConnected(userid) || !IsPlayerConnected(playerid))
return SendClientMessage(playerid, -1, "error: You have entered an invalid playerid/name!");
if (amount < 0 || amount > GetPlayerMoney(playerid))
return SendClientMessage(playerid, -1, "error: You have entered an invalid amount!");
GivePlayerMoney(playerid, -amount);
GivePlayerMoney(userid, amount);
format(str, sizeof(str), "info: You have received $%i from %s.", amount, ReturnName(playerid, 0));
SendClientMessage(userid, -1, str);
format(str, sizeof(str), "info: You have given $%i from %s.", amount, ReturnName(userid, 0));
SendClientMessage(playerid, -1, str);
retrun 1;
}