This code don't send money
#2

Right Code:

Код:
if(strcmp(cmd, "/givemoney", true) == 0)
	{
		new string[128];
		new playermoney;
		new sendername[MAX_PLAYER_NAME];
		new giveplayer[MAX_PLAYER_NAME];
 		new giveplayerid, moneys;
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash <playerid/playername> <amount>");
			return 1;
		}
		moneys = strval(tmp);

		if (IsPlayerConnected(giveplayerid) && giveplayerid != INVALID_PLAYER_ID && giveplayerid != playerid)
		{
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			playermoney = GetPlayerMoney(playerid);

			if (moneys > 0 && playermoney >= moneys)
			{
				GivePlayerMoney(playerid, (0 - moneys));
				GivePlayerMoney(giveplayerid, moneys);
				format(string, sizeof(string), "You gave %s(%d), Money Amount: $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_GREEN, string);
				format(string, sizeof(string), "You got $%d from %s(%d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_GREEN, string);
				PlayerPlaySound(playerid,1084,0.0,0.0,0.0);
				printf("%s(%d) has transfered %d to %s(%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
				}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "Invalid amount!");
			}
		}
		else
		{
			format(string, sizeof(string), "ERROR: Player Is Not Connected or Its Yourself!");
			SendClientMessage(playerid, COLOR_RED, string);
		}
		return 1;
	}
Reply


Messages In This Thread
This code don't send money - by Face9000 - 30.12.2011, 16:01
Re: This code don't send money - by James Coral - 30.12.2011, 16:02
Re: This code don't send money - by James Coral - 30.12.2011, 16:05
Re: This code don't send money - by Face9000 - 30.12.2011, 16:14
Re: This code don't send money - by Ash. - 30.12.2011, 16:17
Re: This code don't send money - by James Coral - 30.12.2011, 16:20
Re: This code don't send money - by James Coral - 30.12.2011, 16:22
Re: This code don't send money - by Face9000 - 30.12.2011, 16:26
Re: This code don't send money - by Ash. - 30.12.2011, 16:36
Re: This code don't send money - by Face9000 - 30.12.2011, 16:42

Forum Jump:


Users browsing this thread: 4 Guest(s)