Understanding Sscanf.
#1

Hello,
When I make a command like

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

Click here to learn about sscanf!
Reply
#3

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

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.
Reply
#5

Thanks all.

@Twisted_Insane,

Thank you, I understood you better.
Reply
#6

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 ) )
Reply
#7

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 .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)