SA-MP Forums Archive
Why using native from string.inc crash samp-npc - 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: Why using native from string.inc crash samp-npc (/showthread.php?tid=421502)



Why using native from string.inc crash samp-npc - Azazelo - 09.03.2013

Using this command make 0.3x samp-npc to crash on any typed text Why?

pawn Код:
//source https://sampwiki.blast.hk/wiki/NPC:OnPlayerText
public OnPlayerText(playerid, text[])
{
    if (strfind(text, "stupid bot") != -1)
    {
        new string[80], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Hey %s! Don't say those things! We, bots, are cool!", name);
        SendChat(string);
    }
    return 1;
}
And here brake point of this :


Any help apprised.


Re: Why using native from string.inc crash samp-npc - MP2 - 09.03.2013

And the crash doesn't happen when you comment it out?


Re: Why using native from string.inc crash samp-npc - Azazelo - 09.03.2013

yes no errors when /* */
And if i try to use if (strfind(text, "stupid bot") != -1) or any else string comparator the crash happen.

Edit: I will attach whole code to see it.

pawn Код:
//
// NPC Test Script
// Kye 2009
//

#include <a_npc>

//------------------------------------------

main()
{
    printf("npcidle: running");
}

//------------------------------------------
//------------ Talk TEST -------------------
public OnPlayerText(playerid, text[])
{

    if (strfind(text, "stupid bot") != -1)
    {
        new string[80], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Hey %s! Don't say those things! We, bots, are cool!", name);
        SendChat(string);
    }
    return 1;
}
//////////////////////////////////////////////
Compiler say everything is OK. And any chat from player samp-npc crash.