Learning Sscanf
#1

Guys as Title say i am Learning with Sscanf and i modyfied the Maded code with sscanf on wiki samp but i have problem

this is my OnPlayerCommandText

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(givecash, 8, cmdtext);
	return 0;
}

dcmd_givecash(playerid, params[])
{
  new string[256];
  new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF9900AA, "Usage: /givecash [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF9900AA, "Player Not Found");
	else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF9900AA, "You Don't Have Enough Money!");
	else if (giveplayerid == playerid) SendClientMessage(playerid,0xFF9900AA,"You Can't Give Money To Yourself!");
	{
		GivePlayerMoney(giveplayerid, amount);
		GameTextForPlayer(giveplayerid,"~g~Money Recived",3000,5);
		format(string, sizeof(string), "You Recived $%d From Player %s(%d)",amount,playername,giveplayerid);
		SendClientMessage(giveplayerid,0x33CCFFAA,string);
		
		GivePlayerMoney(playerid, 0 - amount);
		GameTextForPlayer(playerid,"~y~Money Sent",3000,5);
		format(string, sizeof(string), "You Have Sent $%d To Player %s(%d)",amount,playername,playerid);
		SendClientMessage(playerid,0x33CCFFAA,string);
	}
	return 1;
}
But When I Type Just /givecash without any id or amount it says those 2 messages ''You Recived $(0) FromPlayer (myname,myid)''
and this one ''You Have Sent $0 To Player (myname,myid)"

but i want if there is player sending to himself it will say ''You Cant Give Money Your Self''...
and if player just type /givecash there will write ''Usage:/givecash playerid/partname amount''

actualy when i wrote givecash in game, i am missing those ''Error Messages''

so can u help ? mybe copy and paste this code to your code and try and see the problem please i was trying to add return1; but then i get errors .... unreachable code etc ...

Ty For any help i will check forum tomorow now i go watch TV

good night all bb
Reply


Messages In This Thread
Learning Sscanf - by Lajko1 - 11.12.2009, 19:18
Re: Learning Sscanf - by mprofitt - 11.12.2009, 19:29
Re: Learning Sscanf - by DeathOnaStick - 11.12.2009, 19:32
Re: Learning Sscanf - by mprofitt - 11.12.2009, 19:38
Re: Learning Sscanf - by DeathOnaStick - 11.12.2009, 19:50
Re: Learning Sscanf - by dice7 - 11.12.2009, 19:56
Re: Learning Sscanf - by DeathOnaStick - 11.12.2009, 20:00
Re: Learning Sscanf - by dice7 - 11.12.2009, 20:02
Re: Learning Sscanf - by (.Aztec); - 11.12.2009, 20:12
Re: Learning Sscanf - by Malice - 11.12.2009, 23:52

Forum Jump:


Users browsing this thread: 1 Guest(s)