Sscanf Warning
#1

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 .
Reply
#2

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 .
Reply
#3

Works!,Thanks.
Reply
#4

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


Forum Jump:


Users browsing this thread: 2 Guest(s)