Sscanf plugin warning
#1

Hi. I don't understand where is the problem:

pawn Код:
dcmd_use(playerid, params[])
{
    new drugs[10];
    if(PlayerI[playerid][InEvent] == 1) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}You are already taking part in somewhere, so firstly type /leave!","{FF0000}*[INFO]: {668888}Jūs jau kaћkur dalyvaujate, todėl pirma naudokite /leave!");
    if(PlayerI[playerid][Offered] > 0) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}Firstly cancel offers with /cancel!","{FF0000}*[INFO]: {668888}Pirma atљaukite pasiūlymus su /cancel!");
    if(PlayerDrunkLevel[playerid] > 225) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}You can't use drugs when you are drunk","{FF0000}*[INFO]: {668888}Negalite naudoti nartkotikų, kol esate girtas");
    if(sscanf(params, "s[10]",drugs))
    {
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Usage: {CCFF00}/use [drugs]","{FF0000}*[INFO]: {668888}Naudojimas: {CCFF00}/use [drugs]");
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Drugs: Extazy, Weed, Opium","{FF0000}*[INFO]: {668888}Narkotikai: Extazy, Weed, Opium");
        return 1;
    }
    if(strlen(drugs) > 10 || strlen(drugs) < 0)
    {
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Usage: {CCFF00}/use [drugs]","{FF0000}*[INFO]: {668888}Naudojimas: {CCFF00}/use [drugs]");
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Drugs: Extazy, Weed, Opium","{FF0000}*[INFO]: {668888}Narkotikai: Extazy, Weed, Opium");
        return 1;
    }
    if(strcmp(params,"weed",true) == 0)
    {
        //do
    }
    else if(strcmp(params,"extazy",true) == 0)
    {
        //do
    }
    else if(strcmp(params,"opium",true) == 0)
    {
        //do
    }
    return 1;
}
I get this warning:

Код:
[22:37:40] sscanf warning: String buffer overflow.
Reply
#2

Try upping this value:

Код:
new drugs[10];
Reply
#3

I did this:
pawn Код:
new drugs[20];
    if(PlayerI[playerid][InEvent] == 1) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}You are already taking part in somewhere, so firstly type /leave!","{FF0000}*[INFO]: {668888}Jūs jau kažkur dalyvaujate, todėl pirma naudokite /leave!");
    if(PlayerI[playerid][Offered] > 0) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}Firstly cancel offers with /cancel!","{FF0000}*[INFO]: {668888}Pirma atšaukite pasiūlymus su /cancel!");
    if(PlayerDrunkLevel[playerid] > 225) return SendClientMessageLang(playerid,COLOR_WHITE,"{FF0000}*[INFO]: {668888}You can't use drugs when you are drunk","{FF0000}*[INFO]: {668888}Negalite naudoti nartkotikų, kol esate girtas");
    if(sscanf(params, "s[19]",drugs))
    {
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Usage: {CCFF00}/use [drugs]","{FF0000}*[INFO]: {668888}Naudojimas: {CCFF00}/use [drugs]");
        SendClientMessageLang(playerid, COLOR_WHITE, "{FF0000}*[INFO]: {668888}Drugs: Extazy, Weed, Opium","{FF0000}*[INFO]: {668888}Narkotikai: Extazy, Weed, Opium");
        return 1;
    }
and i wrote "/use aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" in game and i got the same warning...
Reply
#4

Up it to:

Код:
new drugs[128];
Your string is longer than 20.

See what happens.
Reply
#5

With 128 it's okay. But i don't need all 128. Hm it's interesting..
Reply
#6

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
With 128 it's okay. But i don't need all 128. Hm it's interesting..
So it's working now ?
Reply
#7

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
With 128 it's okay. But i don't need all 128. Hm it's interesting..
You don't even need sscanf
Reply
#8

Yes. Anyway, thanks for answers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)