Sscanf strings
#1

Hello guys, I hope you answer me fastly, it's not a huge error, my script does work, I can access the game, but in my console, I have there warning :
pawn Код:
scanf warning string buffer overflow
scanf warning strings without a length are deprecated please add a destination size
I know where the problem is coming from, it's from this CMD:
pawn Код:
CMD:fakemessage(playerid,params[]) {
    if(PlayerInfo[playerid][pAdminlevel] >= 3)
    {
        new toplayerid;
        new string[70];
        if (!sscanf(params, "rs", toplayerid, string))
        {
          if (toplayerid != INVALID_PLAYER_ID)
          {
                new
                    message[128],
                    message1[128],
                    PlayerName[MAX_PLAYER_NAME], // the player we want to give money to
                    PlayerI[MAX_PLAYER_NAME];
                GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
                GetPlayerName(toplayerid, PlayerI, sizeof(PlayerI));
                format(message, sizeof(message), "{ffff00}%s:{ffffff} %s", PlayerI, string);
                SendClientMessageToAll(COLOR_WHITE, message);
                format(message1, sizeof(message1), "Admin CMD : %s FakeMessaged %s by : %s", PlayerName, PlayerI, string);
                SendToAdmins(COLOR_YELLOW,message1);
                AdminCmdLog(playerid, message1);
          }
          else SendClientMessage(playerid, 0xFF0000FF, "That player is not connected.");
        }
        else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /fakemessage <playerid> <text>");
    }
    else SendClientMessage(playerid,COLOR_RED,"Only admins (3) can use this command!");
    return 1;
}
I also know I didn't define the lengths of my strings well, but I don't know how to fix it, please guys, could you help me ?
Reply
#2

Change:
Код:
if (!sscanf(params, "rs", toplayerid, string))
To:
Код:
if (!sscanf(params, "rs[70]", toplayerid, string))
Reply
#3

I have more commands, and I never needed to add [length] in params .. But Lemme check this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)