[HELP]sscanf warning: Strings without a length are deprecated, please add a destination size.
#1

I get this warning and then the server crashes. the offline ban command crashes the server.
PHP код:
CMD:oban(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] < 2) return 0;
    {
        new 
otherplayerfilestring[79], string[128], reason[128];
         if(
sscanf(params"ss"otherplayerreason)) return SendClientMessage(playeridCOLOR_GRAY,"Usage: /oban [playername] [reason]");
        if(
otherplayer == playerid) return SendClientMessage(playeridCOLOR_ERROR"Error: You cannot offline ban yourself.");
        if(
PlayerInfo[playerid][pAdmin] < PlayerInfo[otherplayer][pAdmin] && PlayerInfo[playerid][pAdmin] != 6) return SendClientMessage(playeridCOLOR_ERROR"Error: You cannot offline ban this player.");
        
format(filestringsizeof(filestring), "/Users/%s.ini"otherplayer);
        if(!
fexist(filestring)) return SendClientMessage(playeridCOLOR_ERROR"Error: Account does not exist.");
        else
        {
            new 
INI:File INI_Open(filestring);
            
INI_SetTag(File,"User Files");
            
INI_WriteInt(File"Banned"1);
            
INI_WriteString(File"BannedReason"reason);
            
INI_WriteString(File"BannedBy"GetName(playerid));
            
INI_Close(File);
            
format(stringsizeof(string), "Admin Log: %s has offline banned player %s."GetName(playerid), otherplayer);
             
Admin(COLOR_ADMIN_LOG,string1);
             
SendDC(AUSERLOGstring);
             
SaveToFile("AdminLogs",string);
        }
    }
    return 
1;

Reply
#2

PHP код:
new otherplayer[MAX_PLAYER_NAME];
if(
sscanf(params"s[24]s[128]"otherplayerreason)) return SendClientMessage(playeridCOLOR_GRAY,"Usage: /oban [playername] [reason]"); 
Reply
#3

Quote:

new otherplayer, filestring[79], string[128], reason[128];

it should be like that

PHP код:
        new otherplayer[128], filestring[79], string[128], reason[128]; 
and this line
Quote:

if(sscanf(params, "ss", otherplayer, reason)) return SendClientMessage(playerid, COLOR_GRAY,"Usage: /oban [playername] [reason]");

should be like that

PHP код:
if(sscanf(params"s[128]s[128]"otherplayerreason)) return SendClientMessage(playeridCOLOR_GRAY,"Usage: /oban [playername] [reason]"); 
The point is that you didn't add size for the string..
Reply
#4

Why would your string and reason array sizes be same? No one would put such a big reason that will occupy all 128 cells, maybe you should use 50 cells instead. And if your reason string is 128 then your string size will be not sufficient for the reason and will require more cells.
Reply
#5

It fixed the warning but it still crashes the server when I use the command
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Use `u`, not `s`, for player names/IDs.
I am searching for the file of the user(Who is offline) thats why I'm using the string.

It still crashes the server tho
Reply
#7

Use "print"s to see what is being executed and where it actually stops executing (at which point the crash is caused).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)