SA-MP Forums Archive
npc chat help - 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: npc chat help (/showthread.php?tid=193499)



npc chat help - farris - 26.11.2010

ok so im making an npc but when you type a message to it the response comes before the orginal message.that needs to be fixed. heres the code




if (strfind(text, "Wheres a good place to eat?") != -1)
{
switch(random(3))
{
case 0:
{
SendPlayerMessageToPlayer(playerid,0,"The steak house is a good place in north LV near the fire station.");
}
case 1:
{
SendPlayerMessageToPlayer(playerid,0,"Theres an awesome buffet at the four dragons just southbound from here.");
}
case 2:
{
SendPlayerMessageToPlayer(playerid,0,"Theres a donut shop all the way southbound this road to the right!");
}
}
}
return 1;
}


Re: npc chat help - JamesC - 26.11.2010

pawn Код:
OnPlayerText(playerid, text[])
{
    if (strfind(text, "Wheres a good place to eat?") != -1)
    {
        switch(random(3))
        {
            case 0:
            {
                SendPlayerMessageToPlayer(playerid,0,"The steak house is a good place in north LV near the fire station.");
            }
            case 1:
            {
                SendPlayerMessageToPlayer(playerid,0,"Theres an awesome buffet at the four dragons just southbound from here.");
            }
            case 2:
            {
                SendPlayerMessageToPlayer(playerid,0,"Theres a donut shop all the way southbound this road to the right!");
            }
        }
        return 0;
    }
    return 1;
}
Untested.