How to make each NPC say random stuff?
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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

all you ned is the bot ids.
Reply
#6

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);
}
Reply
#7

Thanks a lot xDeadlyBoy, it works !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)