sscanf warning 'wondering'
#1

hello guys. i am just wondering. does this harm the server or anything? because when i type some of my commands the sscanf warning shows on console
Код:
[21:20:09] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[21:20:09] sscanf warning: No default value found.
[21:20:09] sscanf warning: Format specifier does not match parameter count.
[21:20:14] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[21:20:14] sscanf warning: No default value found.
[21:20:14] sscanf warning: Format specifier does not match parameter count.
can anyone tell? why sscanf gives thar warning?

Command
pawn Код:
dcmd_adjail(playerid,params[])
{
    new string[128], ID, cmdtime, reason[128];
    if(sscanf(params, "udz", ID, cmdtime, reason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /adjail (Player Name/ID) (Seconds) (Reason)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s(%d) is not spawned. You cannot jail them.");
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    format(string,sizeof(string),"Administrator %s(%d) Has Jailed %s(%d) Reason: %s. ",PlayerName(playerid),playerid,PlayerName(ID),ID, reason);
    SendClientMessageToAll(COLOR_ADMIN,string);
    format(string,sizeof(string),"[ADMIN] You have been Admin Jailed for %d seconds, by Admin %s, Reason: %s.",cmdtime,PlayerName(playerid), reason);
    SendClientMessage(ID,COLOR_ERROR,string);
    format(string,sizeof(string),"Administrator %s(%d) Has Jailed %s(%d) Reason: %s. ",PlayerName(playerid),playerid,PlayerName(ID),ID, reason);

    //TextDraw
    TextDrawShowForPlayer(ID,JailTimer[ID]);

    //Others
    ResetPlayerWeapons(ID);

    new rnd = random(sizeof(JailSpawnPoints));
    JailTime[ID] = cmdtime;
    IsCuffed[ID] =0;
    CuffTime[ID] =0;
    TotalJailTime[ID] = cmdtime;
    SetPlayerInterior(ID,10);
    SetPlayerPos(ID,JailSpawnPoints[rnd][0],JailSpawnPoints[rnd][1],JailSpawnPoints[rnd][2]);
    SetPlayerFacingAngle(ID,JailSpawnPoints[rnd][3]);
    TogglePlayerControllable(ID,1);
    SetPlayerWantedLevel(ID,0);
    SetPlayerToTeamColour(ID);
    SetPlayerVirtualWorld(ID, 0);
    return 1;
}
Reply
#2

Quote:

Show us the code

Why don't you just use s[128], instead of z? I think it's possible havn't tested out :3 But i assume, as you can look at /pm function. They use the same methoed but with addons, reply back if you don't understand
Reply
#3

Код:
if(sscanf(params, "uds[128]", ID, cmdtime, reason))
Replace that line with what I just gave you. I think older versions used z
Reply
#4

the (optional) string specifier "z" got replaced by the "S" - iun which case you need to supply it with an optional parameter (a string here):
Код:
if(sscanf(params, "udS(no reason given)[128]", ID, cmdtime, reason))
...from nowon, when you /adjail someone without reason, it will be "no reason given " automatically
oh, have a look @ https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#5

Quote:
Originally Posted by CrazyChoco
Посмотреть сообщение
Why don't you just use s[128], instead of z? I think it's possible havn't tested out :3 But i assume, as you can look at /pm function. They use the same methoed but with addons, reply back if you don't understand
Thanks for explanation + Rep

Quote:
Originally Posted by Andregood
Посмотреть сообщение
Код:
if(sscanf(params, "uds[128]", ID, cmdtime, reason))
Replace that line with what I just gave you. I think older versions used z
thanks for easy explanation and i get it fast + Rep

Topic Closed! Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)