SA-MP Forums Archive
Understanding Sscanf. - 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: Understanding Sscanf. (/showthread.php?tid=335897)



Understanding Sscanf. - HazardGaming - 20.04.2012

Hello,
When I make a command like

Код:
if(sscanf("HERE", targetid)) return ....
How would I find out what to add where it says "HERE"?


Re: Understanding Sscanf. - RollTi - 20.04.2012

Click here to learn about sscanf!


Re: Understanding Sscanf. - ReneG - 20.04.2012

sscanf is responsible for splitting strings up into parameters, not string comparing, which is what it looks like you're wanting to do.


Re: Understanding Sscanf. - Twisted_Insane - 20.04.2012

I don't know what you mean in this case, but your line is incorrect; you forgot the params! Check this out:

pawn Код:
if(sscanf(params, "u", targetid))
We've got the "targetid" included, which probably is a variable you've created. The parameter for an ID is "u", string is "s", and some others. You can find them by searching around in the forums.


Re: Understanding Sscanf. - HazardGaming - 20.04.2012

Thanks all.

@Twisted_Insane,

Thank you, I understood you better.


Re: Understanding Sscanf. - 2KY - 20.04.2012

Quote:
Originally Posted by ******;520110[size=5
Specifiers[/size]

The available specifiers (the letters "u", "i" and "s" in the codes above) are below.
  • Basic specifiers
Код:
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
I believe this is what you're looking for.

E.G:

pawn Код:
new UserID, Float:Height;
if( sscanf( params, "uf", UserID, Height ) )



Re: Understanding Sscanf. - TheArcher - 20.04.2012

Quote:
Originally Posted by 2KY
Посмотреть сообщение
I believe this is what you're looking for.

E.G:

pawn Код:
new UserID, Float:Height;
if( sscanf( params, "uf", UserID, Height ) )
To get him more specified

params = the parameters typed by the player

"uf" = u = integer (e.g 1,2,3,4) which is assigned at the player ID......f=fload (non-integer e.g 12.174)

So "UserID" is assigned to "u" beacause the ID of the player can be only an INTEGER NUMBER (0 - 500)
"Height" assigned to "f" beacuse it could be for example 1.74 .