Sscanf
#1

I have been seeing these messages on the rcon console
Код:
[21:07:38] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:07:38] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[21:07:38] sscanf warning: No default value found.
[21:07:38] sscanf warning: Format specifier does not match parameter count.
I know 'Strings without a length are deprecated, please add a destination size' comes up when i use my /cage command. Will this mess anything up or can i 'ignore' them
Reply
#2

Can you paste the command so we can see?

pawn Код:
new somethin[10];
if(sscanf(params, "s[10]", somethin)) return SendClientMessage(playerid, -1, "some error message");
Reply
#3

Ever since i made this cage i got it

pawn Код:
dcmd_cage(playerid,params[])
{
    if(AccInfo[playerid][Level] < 2)
    return ErrorMessages(playerid, 5);

    new id, reason[64],string[128];
    if(sscanf(params,"is",id,reason)) return SendClientMessage(playerid, COLOR_GREEN,"USAGE: /cage [PlayerId] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_GREEN,"The Player is not connected!");
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    CagePlayer(id);
    format(string,sizeof string,"** ADMIN CAGE: %s has been caged - %s",vName,reason);
    SendClientMessageToAll(adminpink,string);
    return 1;
}
Reply
#4

put s[64] in there instead of just is

so it would be

pawn Код:
if(sscanf(params,"is[64]",id,reason))
Reply
#5

Don't use "i" for player name, use "u" or "r". With that you can either put a part of the player's name, or their ID. Try the code below.
pawn Код:
dcmd_cage(playerid,params[])
{
    if(AccInfo[playerid][Level] < 2)
    return ErrorMessages(playerid, 5);

    new id,string[128];
    if(sscanf(params,"us",id,params)) return SendClientMessage(playerid, COLOR_GREEN,"USAGE: /cage [PlayerId] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_GREEN,"The Player is not connected!");
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    CagePlayer(id);
    format(string,sizeof string,"** ADMIN CAGE: %s has been caged - %s",vName,params);
    SendClientMessageToAll(adminpink,string);
    return 1;
}
Reply
#6

Why a 64 string for this message? USAGE: /cage [PlayerId] [reason] put it to 34 and in sscanf implement s with his lenght, like this
pawn Код:
"is[64]",
Reply
#7

pawn Код:
(1828) : warning 219: local variable "pName" shadows a variable at a preceding level
(1846) : warning 219: local variable "pName" shadows a variable at a preceding level
I know they are just warnings but they should never be left
1828 and 1846:
pawn Код:
new pName[MAX_PLAYER_NAME];
Reply
#8

Quote:
Originally Posted by googamalugafoo
Посмотреть сообщение
pawn Код:
(1828) : warning 219: local variable "pName" shadows a variable at a preceding level
(1846) : warning 219: local variable "pName" shadows a variable at a preceding level
I know they are just warnings but they should never be left
1828 and 1846:
pawn Код:
new pName[MAX_PLAYER_NAME];
Check for stock pName && if you don't find it, just change the variables lol


This forum requires that you wait 120 seconds between posts. Please try again in 70 seconds.
^sorage
Reply
#9

Check for a global "pName".
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)