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



sscanf warning problem - Slicebook - 12.06.2014

Console: [17:01:48] sscanf warning: Strings without a length are deprecated, please add a destination size.

command:
Код:
new string[200],name[MAX_PLAYER_NAME];
    if(sscanf(params, "s",string)) return SendClientMessage(playerid, COLOR_ORANGE, "Hasznбlat: /r <Szцveg>");
    if(PlayerInfo[playerid][Frakcio] == 0) return SendClientMessage(playerid,COLOR_BLUE,"(( Nem vagy egyetlen frakciу tagja sem! ))");
    GetPlayerName(playerid,name,sizeof(name));
 	if(PlayerInfo[playerid][Frakcio] == RENDOR || PlayerInfo[playerid][Frakcio] == LRENDOR)
    {
	    for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(PlayerInfo[i][Frakcio] == 1)
			{
				new szoveg[200];
				format(szoveg, sizeof(szoveg), "[Rбdiу]*AP.PD*%s: %s",name,string);
				SendClientMessage(i,COLOR_LIGHTBLUE,szoveg);
		      }
		}
	}
	return 1;
}



AW: sscanf warning problem - BiosMarcel - 12.06.2014

PHP код:
if(sscanf(params,"s[200]",string)) 



Re: sscanf warning problem - Threshold - 12.06.2014

pawn Код:
new string[85];
    if(sscanf(params, "s[85]", string)) return SendClientMessage(playerid, COLOR_ORANGE, "Hasznбlat: /r <Szцveg>");
    if(!PlayerInfo[playerid][Frakcio]) return SendClientMessage(playerid, COLOR_BLUE, "(( Nem vagy egyetlen frakciу tagja sem! ))");
    new name[MAX_PLAYER_NAME], szoveg[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(szoveg, sizeof(szoveg), "[Rбdiу]*AP.PD*%s: %s", name, string);
    if(PlayerInfo[playerid][Frakcio] == RENDOR || PlayerInfo[playerid][Frakcio] == LRENDOR)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(PlayerInfo[i][Frakcio] == 1) SendClientMessage(i, COLOR_LIGHTBLUE, szoveg);
        }
    }
    return 1;
}



Re: sscanf warning problem - kamiliuxliuxliux - 12.06.2014

Yea, when you want to add a parameter as string, you also must use its size. Two examples above.