SA-MP Forums Archive
How to make each NPC say random stuff? - 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: How to make each NPC say random stuff? (/showthread.php?tid=242287)



How to make each NPC say random stuff? - grand.Theft.Otto - 19.03.2011

I have about 5 bot's on my server, and I was wondering how I could get them to say random stuff, 1 of them every 1 minute, not all at once every 1 minute.

You may have seen in CrazyBob's server, his bot's say random funny stuff about every 1 minute, how can I get something like that?


Re: How to make each NPC say random stuff? - Jochemd - 19.03.2011

You can use an array which you set + 1 every time a bot says something so the ID of the talking bot gets higher by one (they should been ordered in ID). Then just do a random message.


Re: How to make each NPC say random stuff? - xDeadlyBoy - 19.03.2011

pawn Код:
//Top of the mod
new Ids[] = {botid1, botid2, botid3};

//OnGameModeInit
SetTimer("SendRandomBotMsg", 60000, 1);

//anywhere
forward SendRandomBotMsg();
public SendRandomBotMsg()
{
new id = random(sizeof(Ids));
SendPlayerMessageToAll(Ids[id], "random message");
}
make sure to edit the bot ids (the amount doesn't matter) and the message.


Re: How to make each NPC say random stuff? - grand.Theft.Otto - 19.03.2011

Yes, but wouldn't I need if(IsPlayerIsNPC or add the bot's names somewhere?


Re: How to make each NPC say random stuff? - xDeadlyBoy - 19.03.2011

all you ned is the bot ids.


Re: How to make each NPC say random stuff? - Joe Staff - 19.03.2011

pawn Код:
//TOP of script, below #includes
forward bottalk(id);
new messages[][X]=
{
"lolololololol",
"messaaaaaaaaage"
};

// END of ongamemodeinit
for(new bot; bot<MAX_PLAYERS;bot++)
{
if(IsPlayerNPC(bot))bottalk(bot);
}

//BOTTOM of script
public bottalk(id)
{
//chatfunction(id,messages[random(sizeof(messages))]);
SetTimetEx("bottalk",5000+random(5000),0,"i",id);
}



Re: How to make each NPC say random stuff? - grand.Theft.Otto - 19.03.2011

Thanks a lot xDeadlyBoy, it works !