SA-MP Forums Archive
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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SSCANF (/showthread.php?tid=193661)



SSCANF - DRIFT_HUNTER - 27.11.2010

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)


Re: SSCANF - Scenario - 27.11.2010

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


Re: SSCANF - Leon_Rahil! - 27.11.2010

Код:
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.


Re: SSCANF - DRIFT_HUNTER - 27.11.2010

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


Re: SSCANF - Grim_ - 27.11.2010

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


Respuesta: SSCANF - MrDeath537 - 27.11.2010

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)", ...);