Why this command no works?
#5

try this:

Код:
dcmd_givecash(playerid, params[])
{
	new tmp[256], tmp2[256],Index;
	tmp = strtok(params,Index);
	tmp2 = strtok(params,Index);
	
	new otherid = strval(tmp);
	new amount = strval(tmp2);
	
	if (strlen(tmp) && strlen(tmp2))
	{
		if (IsPlayerConnected(otherid))
		{
			if (GetPlayerMoney(playerid) >= amount)
			{
				new string[256], string2[256], name[MAX_PLAYER_NAME], oname[MAX_PLAYER_NAME];
				
				GetPlayerName(playerid, name, sizeof(name));
				GetPlayerName(otherid, oname, sizeof(oname));
				
				GivePlayerMoney(playerid, GetPlayerMoney(playerid)-amount);
				GivePlayerMoney(otherid, amount);		
				
				format(string, sizeof(string), "You have sent %s $%d.", oname, amount);
				format(string2, sizeof(string2), "%s has sent you $%d.", name, amount);
				
				SendClientMessage(playerid, COLOR, string);
				SendClientMessage(otherid, COLOR, string2);
			}
			else
			{
				SendClientMessage(playerid, COLOR, "You dont have that amount of cash.");
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR, "Invalid player id.");
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR, "USAGE: /givecash [playerid] [amount]");
	}
}
Untested.
Reply


Messages In This Thread
Why this command no works? - by _ERO_ - 30.08.2009, 12:53
Re: Why this command no works? - by _ERO_ - 30.08.2009, 13:46
Re: Why this command no works? - by _Vortex - 30.08.2009, 13:50
Re: Why this command no works? - by _ERO_ - 30.08.2009, 13:54
Re: Why this command no works? - by Anwix - 30.08.2009, 17:23

Forum Jump:


Users browsing this thread: 2 Guest(s)