SA-MP Forums Archive
sscanf warning - 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: sscanf warning (/showthread.php?tid=352178)



sscanf warning - tixzor - 18.06.2012

when using /gotoid cmd ,i get error on server_log,
Код:
[12:58:26] sscanf warning: Format specifier does not match parameter count.
here is script



Код:
CMD:gotoid(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_ERROR,"SERVER: Nemozes koristiti tu komandu jer nisi admin lvl 2! ");
	new targetid, string[128];
	if(sscanf(params, "uz[6]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "SERVER: Taj igrac nije online!");
	else
	{
		new pName[24];
		GetPlayerName(targetid,pName,128);
		format(string, sizeof(string), "SERVER:  Teleportiro si se kod  [%d]%s.",targetid, pName);
		SendClientMessage(playerid,COLOR_RED,string);
		SetPlayerInterior(playerid,GetPlayerInterior(targetid));
		new Float:TPX, Float:TPY, Float:TPZ;
		GetPlayerPos(targetid, TPX, TPY, TPZ);
		SetPlayerPos(playerid, TPX, TPY, TPZ+1);
	}
	return 1;
}



Re: sscanf warning - WagnerPM - 18.06.2012

pawn Код:
CMD:gotoid(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_ERROR,"SERVER: Nemozes koristiti tu komandu jer nisi admin lvl 2! ");
    new targetid, string[128];
    if(sscanf(params, "uz[6]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "SERVER: Taj igrac nije online!");
    {
        new pName[24];
        GetPlayerName(targetid,pName,128);
        format(string, sizeof(string), "SERVER:  Teleportiro si se kod  [%d]%s.",targetid, pName);
        SendClientMessage(playerid,COLOR_RED,string);
        SetPlayerInterior(playerid,GetPlayerInterior(targetid));
        new Float:TPX, Float:TPY, Float:TPZ;
        GetPlayerPos(targetid, TPX, TPY, TPZ);
        SetPlayerPos(playerid, TPX, TPY, TPZ+1);
    }
    return 1;
}



Re: sscanf warning - tixzor - 19.06.2012

Quote:
Originally Posted by WagnerPM
Посмотреть сообщение
pawn Код:
CMD:gotoid(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_ERROR,"SERVER: Nemozes koristiti tu komandu jer nisi admin lvl 2! ");
    new targetid, string[128];
    if(sscanf(params, "uz[6]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "SERVER: Taj igrac nije online!");
    {
        new pName[24];
        GetPlayerName(targetid,pName,128);
        format(string, sizeof(string), "SERVER:  Teleportiro si se kod  [%d]%s.",targetid, pName);
        SendClientMessage(playerid,COLOR_RED,string);
        SetPlayerInterior(playerid,GetPlayerInterior(targetid));
        new Float:TPX, Float:TPY, Float:TPZ;
        GetPlayerPos(targetid, TPX, TPY, TPZ);
        SetPlayerPos(playerid, TPX, TPY, TPZ+1);
    }
    return 1;
}
again error.


Re: sscanf warning - Skaizo - 19.06.2012

pawn Код:
CMD:gotoid(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_ERROR,"SERVER: Nemozes koristiti tu komandu jer nisi admin lvl 2! ");
    new targetid, string[128];
    if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "SERVER: Taj igrac nije online!");
    {
        new pName[24];
        GetPlayerName(targetid,pName,128);
        format(string, sizeof(string), "SERVER:  Teleportiro si se kod  [%d]%s.",targetid, pName);
        SendClientMessage(playerid,COLOR_RED,string);
        SetPlayerInterior(playerid,GetPlayerInterior(targetid));
        new Float:TPX, Float:TPY, Float:TPZ;
        GetPlayerPos(targetid, TPX, TPY, TPZ);
        SetPlayerPos(playerid, TPX, TPY, TPZ+1);
    }
    return 1;
}



Re: sscanf warning - ReneG - 19.06.2012

The command only uses one parameter, that is a targetid.

Change
pawn Код:
if(sscanf(params, "uz[6]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
to
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "POMOC: /goto [PlayerID/PartOfName]");
u is the userid specifier. That's all you need for this command.