sscanf warning: Strings without a length are deprecated, please add a destination size.
#1

hey everyone,

i had this error:
pawn Код:
sscanf warning: Strings without a length are deprecated, please add a destination size.
when i used this commands:
pawn Код:
CMD:akill(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 2)
    {
        new targetid, tname[MAX_PLAYER_NAME], reason;
        new string[128], string2[128], string3[128];
        if(sscanf(params, "us", targetid, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /akill [playerid] [reason]");
        GetPlayerName(targetid, tname, sizeof(tname));
        SetPlayerHealth(targetid, 0);
        format(string, sizeof(string), "ADMIN_KILL: {FF0000}%s {00FF00}has been Killed by an Admin, Reason: {FF0000}%s", tname, reason);
        format(string2, sizeof(string2), "you have killed {FF0000}%s, {00FF00}Reason: {FF0000}%s", tname, reason);
        format(string3, sizeof(string3), "You have been Killed by an Admin, Reason: {FF0000}%s", reason);
        SendClientMessage(playerid, COLOR_GREEN, string2);
        SendClientMessage(targetid, COLOR_GREEN, string3);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin level 2 to use this command");
    return 1;
}
CMD:explode(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new targetid, tname[MAX_PLAYER_NAME], reason;
        new string[128], string2[128], string3[128];
        if(sscanf(params, "us", targetid, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /explode [playerid] [reason]");
        GetPlayerName(targetid, tname, sizeof(tname));
        new Float:x, Float:y, Float:z;
        GetPlayerPos(targetid, x, y, z);
        CreateExplosion(x, y, z, EXPLOSION_TYPE, 20);
        format(string, sizeof(string), "ADMIN_EXPLODE: {FF0000}%s {00FF00}has been Exploded by an Admin, Reason: {FF0000}%s", tname, reason);
        format(string2, sizeof(string2), "you have Exploded {FF0000}%s, {00FF00}Reason: {FF0000}%s", tname, reason);
        format(string3, sizeof(string3), "You have been Exploded by an Admin, Reason: {FF0000}%s", reason);
        SendClientMessage(playerid, COLOR_GREEN, string2);
        SendClientMessage(targetid, COLOR_GREEN, string3);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin level 1 to use this command");
    return 1;
}
but i have the string length set to 128 right? string[128]...

anyways wut do i do wrong here?

i dont want warnings/errors in my scripts/console, so i wanna get rid of this one too

greets niels
Reply
#2

Код:
reason[128];
Reply
#3

Above +

pawn Код:
if(sscanf(params, "us[120]", targetid, reason))
This ^
Reply
#4

This is what is wrong:

PHP код:
if(sscanf(params"us"targetidreason)) 
It should be:

PHP код:
if(sscanf(params"us[128]"targetidreason)) 
//Replace "128" with your reason size.
Reply
#5

reason is an int then told a string in sscanf? Shouldn't it be like reason[stringsize], anyhow. Let's say the reason is 48, then you should do if(sscanf(params, "us[48]", targetid, reason))
Reply
#6

hmm i see, but ******, you say that i can use new string[128] 3 times? for the player who got killed, the player who killed him, AND the allmessage to tell everyone he got killed?

so like:
pawn Код:
format(string, sizeof(string), "ADMIN_EXPLODE: {FF0000}%s {00FF00}has been Exploded by an Admin, Reason: {FF0000}%s", tname, reason);
        SendClientMessageToAll(COLOR_GREEN, string);

        format(string, sizeof(string), "you have Exploded {FF0000}%s, {00FF00}Reason: {FF0000}%s", tname, reason);
        SendClientMessage(playerid, COLOR_GREEN, string);
       
        format(string, sizeof(string), "You have been Exploded by an Admin, Reason: {FF0000}%s", reason);
        SendClientMessage(targetid, COLOR_GREEN, string);
so you say this works? this sends still the same messages to the players?

and which should i do?

pawn Код:
reason[128];
or

pawn Код:
if(sscanf(params, "us[128]", targetid, reason))
??

also:
http://forum.sa-mp.com/showpost.php?...15&postcount=6

anyone knows wuts the problem there?
i posted it earlier on other topic, but noone seems to respond to there, cuz its not in first page anymore i think
Reply
#7

As its a string you have to specify size. so both maybe.
Reply
#8

lolz, xD so you say both works? but not both at same time? so when i do reason[128]; that will work fine? also did you said with the formats i posted earlier, it works or not works? im not that advanced english xD
Reply
#9

ok so i have to do:
pawn Код:
new reason[128];
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /akill [playerid] [reason]");
and that will work?

and how about the:
pawn Код:
format(string, sizeof(string), "ADMIN_EXPLODE: {FF0000}%s {00FF00}has been Exploded by an Admin, Reason: {FF0000}%s", tname, reason);
        SendClientMessageToAll(COLOR_GREEN, string);

        format(string, sizeof(string), "you have Exploded {FF0000}%s, {00FF00}Reason: {FF0000}%s", tname, reason);
        SendClientMessage(playerid, COLOR_GREEN, string);
       
        format(string, sizeof(string), "You have been Exploded by an Admin, Reason: {FF0000}%s", reason);
        SendClientMessage(targetid, COLOR_GREEN, string);
that should work fine like this?
Reply
#10

They must work fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)