SSCANF
#1

These is starting to freaking me out
How the fuck i can use optional(z) params with SSCANF?
Any examples pls...(if possible with 2 or 3 optional params)
Reply
#2

Read ******'s release thread, optional params are capital letters. So instead of "s" it's "S", don't use Z either.
Reply
#3

Код:
CMD:me(playerid, params[])
{
	new pName[MAX_PLAYER_NAME]; // Get the players name
	new str[128]; // holds a string
	if (sscanf(params, "z", str)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /me <action>"); // Shows how to use the command
	else
	{
		GetPlayerName(playerid, pName, sizeof(pName)); // Gets the player name
		format(str, sizeof(str), "*%s %s", pName, str); // formats it for us, so we can see what it looks like
		SendClientMessageToAll(COLOR_PINK, str); // Just like in mIRC :P 
	}
	return 1;
}
You mean something like this? Also I'll edit this post later if you really need one with multiple params.
Reply
#4

Guys like i sad "I need example with OPTIONAL parameters"
Something like /car [ID/NAME][COLOR1][COLOR2] in these case COLOR1 and COLOR2 are optional

So if i type /car 543 its ok and if i type /car 543 0 its ok it will just set car color to black

I NEED JUST EXAMPLE ON HOW TO USE OPTIONAL PARAMETERS IN SSCANF
Reply
#5

pawn Код:
new vName[ 40 ], vColor[ 2 ];
if( sscanf( params, "SDD", vName, vColor[ 0 ], vColor[ 1 ] ) )
// Rest of code
Assuming RealCop228 is correct with what he said ( I haven't bothered messing with the new sscanf ).
Reply
#6

pawn Код:
sscanf(params, "S[128]II", ...);
If you want to add defaults to colors you can use:

pawn Код:
sscanf(params, "S[128]I(default1)I(default2)", ...);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)