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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sscanf Warning (/showthread.php?tid=274003)



Sscanf Warning - CSSI - 04.08.2011

Warning: Strings without a length are deprecated, please add a destination of size.
pawn Код:
dcmd_pm(playerid,params[])
{
    new id,message[128],string[128],name[MAX_PLAYER_NAME];
    if(sscanf(params,"us",id,message)) SendClientMessage(playerid,0x00FF00AA,"Usage: /pm [id] [Message]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid,0x00FF00AA,"Player Not Connected");
    else {
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"PM From %s (%i) -%s",name,playerid,message);
    SendClientMessage(id,0x00FF00AA,string);
   
    }
    return 1;
}
Warning is Printed On the server Console .


Re: Sscanf Warning - Jack_Leslie - 04.08.2011

pawn Код:
dcmd_pm(playerid,params[])
{
    new id,message[128],string[128],name[MAX_PLAYER_NAME];
    if(sscanf(params,"us[128]",id,message)) SendClientMessage(playerid,0x00FF00AA,"Usage: /pm [id] [Message]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid,0x00FF00AA,"Player Not Connected");
    else {
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"PM From %s (%i) -%s",name,playerid,message);
    SendClientMessage(id,0x00FF00AA,string);
   
    }
    return 1;
}


Try that .


Re: Sscanf Warning - CSSI - 04.08.2011

Works!,Thanks.


Re: Sscanf Warning - Famalamalam - 04.08.2011

With sscanf, you must declare the string length in the actual format itself. So when you create a string:

pawn Код:
new message[128],string[128];
You must then also declare it:

pawn Код:
if(sscanf(params,"us[128]",id,message)) // Notice the [128]
You only need to do this for strings.