SSCANF
#1

It's possible to do ? for example i have this cmd
Код:
dcmd_givecash(playerid, params[])
{
	new giveplayerid;
	new 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;
}
and I want /givecash [giveplayerid] [amount / all] and if if I write 'all' it get my all moneys and gives the id what I type?
Reply
#2

Yes, let me just check what I used for this...

If you use an s instead of a d (string instead of integer), you can then strcmp this integer to see if it is "all". If it isn't, use strval on it to turn the string to a number, and use this number as you currently do.
Reply
#3

But there isnt a other way to not use strval? because its bugged when someone write more [ than 49
Reply
#4

Well you could have something to check if params = all (strcmp) before you get to the sscanf, then sscanf can have the same setup you have at the moment. The only problem I can see is that you have multiple params, and so you'll be looking for the word all amongst other stuff..

i.e if a play wanted to pay money to a guy called overall.. he might accidentally pay everything he owns..
Reply
#5

in that case it would be wise to use ids
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)