sscanf warning: Format specifier does not match parameter count.
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)