Add commas to sscanf params.
#1

Hello!

I've started learning sscanf recently after a long time of painful strtok usage and I've realized that sscanf is SO much easier, I've been missing out.

Anyway, I am trying to make a simple /goto command. I've already written the command and it works fine.

Код:
CMD:goto(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
	    if(PlayerInfo[playerid][pAdmin] >= 2)
	    {
	        new Float:X, Float:Y, Float:Z, string[128];
	        if(sscanf(params, "fff", X, Y, Z)) return SCM(playerid, -1, "USAGE: /goto [X] [Y] [Z]");
			SetPlayerPos(playerid, X, Y, Z);
			format(string, sizeof(string), "You have teleported to the follow coordinates: %f, %f, %f.", X, Y, Z);
			SCM(playerid, -1, string);
			return 1;
		}

	}
	return 1;
}
The question is, is it possible to make it read the coords entry with commas?

Because for this command to works, it needs to be in such format:

Код:
/goto 0.00 0.00 0.00
Is it possible to make it like this aswell?

Код:
/goto 0.00, 0.00, 0.00
Thanks!
Reply


Messages In This Thread
Add commas to sscanf params. - by Black Axe - 14.01.2016, 06:59
Re: Add commas to sscanf params. - by PrO.GameR - 14.01.2016, 08:50
Re: Add commas to sscanf params. - by Black Axe - 15.01.2016, 06:27
Re: Add commas to sscanf params. - by PrO.GameR - 15.01.2016, 10:16

Forum Jump:


Users browsing this thread: 1 Guest(s)