[HELP] /givecash [SOLVED]
#6

Problem not found.. - EDIT : founded you have idxx not idx

This is my givecash cmd :P working fine - only - you can give money to yourself too
Код:
 	if(strcmp(cmd, "/givecash", true) == 0)
	 {
	  	new tmp[256];
		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_5, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_5, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		moneys = strval(tmp);

		//printf("givecash_command: %d %d",giveplayerid,moneys);

		if (IsPlayerConnected(giveplayerid))
		{
			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(player: %d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_GREEN, string);
				format(string, sizeof(string), "You got $%d from %s(player: %d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_GREEN, string);
				PlayerPlaySound(playerid,1084,0.0,0.0,0.0);
				printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
				}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "Jou dont have so much ;)");
			}
		}
		else
		{
			format(string, sizeof(string), "%d not found.", giveplayerid);
			SendClientMessage(playerid, COLOR_RED, string);
		}
		return 1;
	}
Reply


Messages In This Thread
[HELP] /givecash [SOLVED] - by leapfish - 22.02.2010, 23:12
Re: [HELP] /givecash - by leapfish - 23.02.2010, 11:02
Re: [HELP] /givecash - by Torran - 23.02.2010, 11:03
Re: [HELP] /givecash - by GaGlets(R) - 23.02.2010, 11:12
Re: [HELP] /givecash - by Razvann - 23.02.2010, 11:13
Re: [HELP] /givecash - by GaGlets(R) - 23.02.2010, 11:18
Re: [HELP] /givecash - by leapfish - 23.02.2010, 11:23

Forum Jump:


Users browsing this thread: 1 Guest(s)