SA-MP Forums Archive
Sscanf plugin warning - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sscanf plugin warning (/showthread.php?tid=236581)



Sscanf plugin warning - BuLLeT[LTU] - 07.03.2011

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.



Re: Sscanf plugin warning - Stigg - 07.03.2011

Try upping this value:

Код:
new drugs[10];



Re: Sscanf plugin warning - BuLLeT[LTU] - 07.03.2011

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...


Re: Sscanf plugin warning - Stigg - 07.03.2011

Up it to:

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

See what happens.


Re: Sscanf plugin warning - BuLLeT[LTU] - 07.03.2011

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


Re: Sscanf plugin warning - Stigg - 07.03.2011

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 ?


Re: Sscanf plugin warning - dice7 - 07.03.2011

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


Re: Sscanf plugin warning - BuLLeT[LTU] - 07.03.2011

Yes. Anyway, thanks for answers