10.04.2016, 13:14
PHP код:
dcmd_givemoney(playerid,params[])
{
new string[128];
new ID, amount;
if(sscanf(params, "ui", ID, amount))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /givecash (Player Name/ID) (Amount)");
return 1;
}
if(pInfo[playerid][Spawned] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The Player ID [%d] is not connected to the server. You cannot give money to them.",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(ID == playerid)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot give money to yourself!!");
return 1;
}
if(GetPlayerMoney(playerid) < amount)
{
SendClientMessage(playerid,COLOR_ERROR,"You do not have that amount of money in order to give it to someone.");
return 1;
}
if(amount > 200000 || amount < 500)
{
SendClientMessage(playerid,COLOR_ERROR,"Please enter an amount between $500 and $200000.");
return 1;
}
format(string,sizeof(string),"You have given $%d of your own money to %s[%d].",amount,GetName(ID),ID);
SendClientMessage(playerid,COLOR_YELLOW,string);
GivePlayerMoney(playerid,-amount);
format(string,sizeof(string),"You have been given $%d by %s[%d]. Make sure you thank them.",amount,GetName(playerid),playerid);
SendClientMessage(ID,COLOR_YELLOW,string);
GivePlayerMoney(ID,amount);
//+rep me
return 1;
}