sscanf warning: Format specifier does not match parameter count.
#1

Hello guys.

Alright so I have a problem, when I start my server I get my log spammed by these.

Код:
sscanf warning: Format specifier does not match parameter count.
And I don't know where its coming from so it's pretty hard to solve it. So does anyone know how I can track it down and maybe solve it?

All help appreciated.
Reply
#2

This happens when you do this:
pawn Код:
new id, secid;
if(sscanf(params, "dd", id))//missing one parameter..
It should happen when you do a command, try to investigate which command is it and fix it.
Reply
#3

Can it be this one?

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(BlockPM[playerid] == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm this player because he has blocked you from doing so.");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid, COLOR_GREY,"ERROR: That player has disabled Private Messages.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Reply
#4

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(BlockPM[playerid] == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm this player because he has blocked you from doing so.");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid, COLOR_GREY,"ERROR: That player has disabled Private Messages.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by HY
Посмотреть сообщение
pawn Код:
if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
Next time explain him that you have to specify the size of the string along with the specifier.
Reply
#6

Quote:
Originally Posted by DavidSparks
Посмотреть сообщение
Can it be this one?

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(BlockPM[playerid] == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm this player because he has blocked you from doing so.");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid, COLOR_GREY,"ERROR: That player has disabled Private Messages.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Yes, you need to
Quote:
Originally Posted by kirk
Посмотреть сообщение
specify the size of the string along with the specifier.
pawn Код:
CMD:pm(playerid, params[])
{
    new id, msg[128];
    if(sscanf(params, "us[128]", id, msg))return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");

    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(BlockPM[playerid] == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm this player because he has blocked you from doing so.");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid, COLOR_GREY,"ERROR: That player has disabled Private Messages.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");

    new str[128], Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];

    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
   
    format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, msg), SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, msg), SendClientMessage(id, COLOR_YELLOW, str);
    return 1;
}
Also why are you using sscanf more than one, sscanf split the parameters into the parameters you choose, no need to use it again, I'm talking about "sscanf(params, "ds[128]", id, str2);"
Reply
#7

You need to define the size/cells of the string when using the 'variable' in sscanf.
The size must not be smaller than your original code you are implying on, or else you might get half of the code working.
The example above my post is correct.
Reply
#8

Thanks for the help guys but it seems like the problem still occurs...

Remember that it's specially when I start the server not when I type any command.

Anyways, any other solution tips?
Reply
#9

Download and configure CrashDetect, it'll print you where the error is.
Reply
#10

Alright so whats next :S

Код:
[17:08:12] [debug] Run time error 4: "Array index out of bounds"
[17:08:12] [debug]  Accessing element at index 598 past array upper bound 499
[17:08:12] [debug] AMX backtrace:
[17:08:12] [debug] #0 0045c7d4 in public OnVehicleSpawn (598) from SFRP.amx
[17:08:12] [debug] #1 native SetVehicleToRespawn () from samp-server.exe
[17:08:12] [debug] #2 001b3ac8 in public Audio_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #3 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #4 00011174 in public SSCANF_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #5 0000b31c in public zcmd_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #6 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #7 0000add8 in public Timers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #8 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #9 0000ac60 in public YVers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #10 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #11 00009980 in public Itter_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #12 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #13 00000ef4 in public OnGameModeInit () from SFRP.amx
[17:08:12] [debug] Run time error 4: "Array index out of bounds"
[17:08:12] [debug]  Accessing element at index 599 past array upper bound 499
[17:08:12] [debug] AMX backtrace:
[17:08:12] [debug] #0 0045c7d4 in public OnVehicleSpawn (599) from SFRP.amx
[17:08:12] [debug] #1 native SetVehicleToRespawn () from samp-server.exe
[17:08:12] [debug] #2 001b3afc in public Audio_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #3 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #4 00011174 in public SSCANF_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #5 0000b31c in public zcmd_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #6 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #7 0000add8 in public Timers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #8 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #9 0000ac60 in public YVers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #10 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #11 00009980 in public Itter_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #12 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #13 00000ef4 in public OnGameModeInit () from SFRP.amx
[17:08:12] [debug] Run time error 4: "Array index out of bounds"
[17:08:12] [debug]  Accessing element at index 600 past array upper bound 499
[17:08:12] [debug] AMX backtrace:
[17:08:12] [debug] #0 0045c7d4 in public OnVehicleSpawn (600) from SFRP.amx
[17:08:12] [debug] #1 native SetVehicleToRespawn () from samp-server.exe
[17:08:12] [debug] #2 001b3b30 in public Audio_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #3 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #4 00011174 in public SSCANF_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #5 0000b31c in public zcmd_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #6 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #7 0000add8 in public Timers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #8 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #9 0000ac60 in public YVers_OnScriptInit () from SFRP.amx
[17:08:12] [debug] #10 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #11 00009980 in public Itter_OnGameModeInit () from SFRP.amx
[17:08:12] [debug] #12 native CallLocalFunction () from samp-server.exe
[17:08:12] [debug] #13 00000ef4 in public OnGameModeInit () from SFRP.amx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)