SA-MP Forums Archive
Sscanf - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Sscanf (/showthread.php?tid=305612)



Sscanf - SnG.Scot_MisCuDI - 23.12.2011

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


Re: Sscanf - [ABK]Antonio - 23.12.2011

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");



Re: Sscanf - SnG.Scot_MisCuDI - 23.12.2011

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;
}



Re: Sscanf - [ABK]Antonio - 23.12.2011

put s[64] in there instead of just is

so it would be

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



Re: Sscanf - Tee - 23.12.2011

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;
}



Respuesta: Sscanf - kirk - 23.12.2011

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]",



Re: Sscanf - SnG.Scot_MisCuDI - 23.12.2011

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];



Re: Sscanf - [ABK]Antonio - 23.12.2011

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


Re: Sscanf - Tee - 23.12.2011

Check for a global "pName".