SA-MP Forums Archive
how to check for number - 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)
+--- Thread: how to check for number (/showthread.php?tid=425858)



how to check for number - horsemeat - 27.03.2013

how to check for numbers
need some help here is the command

Код:
//in some command
new id,input[128],choice[128];
if(sscanf(params,"ss",input,choice)
{
    return SendClientMessge(playerid, RED, "SYNTAX /setplayerlabelstate [playerid/all] [yes/no]");
}
if(strcmp(input,"all",true,64)==0)
{
	
}
else
{
    id = strval(input);
}
now I would like it so the player can enter id 0 but I would also like it to return if player enter anything besides 'all' but I don't want it to run the rest of the code as id 0 when it does not find anything

how do I do this ?


Re: how to check for number - Gamer_007 - 27.03.2013

Код:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42
Copied from ****** Sscanf Topic.d is used for integer values.You must use "ds" according to me.


Re: how to check for number - horsemeat - 27.03.2013

Quote:
Originally Posted by Gamer_007
Посмотреть сообщение
Copied from ****** Sscanf Topic.d is used for integer values.You must use "ds" according to me.
one of my options is a string so I can let sscanf look for a diget I need it do scan for a string then check if the string is equal to the one and if not convert what ever number there are into id I would like to check if the player enter 0 or if stval just made a 0


Re: how to check for number - Gamer_007 - 27.03.2013

I cant get what you wanna say.Explain me a bit clear


Re: how to check for number - horsemeat - 27.03.2013

alright I basically want to check if the player enters all if they did not then I would like to convert it into numbers the problem is how do I check if a player enters a different string like 'bob,cat' it will automatically make id = 0 I don't want that