SA-MP Forums Archive
Why this command no works? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why this command no works? (/showthread.php?tid=94515)



Why this command no works? - _ERO_ - 30.08.2009

I try make command givecash with dcmd, the command and all the script in give error, but ingame no see the money, when i write /givecash say "Money send" But when i write /givecash (id) (ammont) say me "Usage: /givecas [playerid/name] [ammount]

can someone help me?

Код:
dcmd_givecash(playerid, params[])
{
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds");
	else
	{
		GivePlayerMoney(giveplayerid, amount);
		GivePlayerMoney(playerid, 0 - amount);
		SendClientMessage(playerid, 0x00FF00AA, "Money sent");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Money recieved");
	}
	return 1;
}



Re: Why this command no works? - _ERO_ - 30.08.2009

Sorro for the double post, but i search this about 2 weeks, and i are crazy, i need command /givecash player to player

someone have one?

If is in dcmd better

Thanks


Re: Why this command no works? - _Vortex - 30.08.2009

You didn't make it.

https://sampwiki.blast.hk/wiki/Dcmd


Re: Why this command no works? - _ERO_ - 30.08.2009

Quote:
Originally Posted by [B
Vortex ]
You didn't make it.

https://sampwiki.blast.hk/wiki/Dcmd
I try with this command... but no is works, i think someone edit that for cant send money


Re: Why this command no works? - Anwix - 30.08.2009

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.