23.04.2013, 03:48
Hi i am creating a bot system.
All messages that the bot are sending are from a .txt not from script.
It works. However.
It always stuck at the 1st line from the .txt and also it only takes the 1st whole word.
Not the whole word of the line.
Demonstration:
Steve will send these.
But instead the result is
Then it keeps sending.
How to fix it?
BOT_NAME is "Steve".
All messages that the bot are sending are from a .txt not from script.
It works. However.
It always stuck at the 1st line from the .txt and also it only takes the 1st whole word.
Not the whole word of the line.
Demonstration:
Код:
Hello i am bot of JakAdmin.
But instead the result is
Код:
Steve: Hello
How to fix it?
pawn Код:
#if BOT_FEATURE == true
ChatTimer = SetTimer("BotChat", 1000*60*1, true);
#endif
#if BOT_FEATURE == true
if(fexist("JakAdmin/Config/botdialogue.txt"))
{
new File:dialogue;
new str[256];
dialogue = fopen("JakAdmin/Config/botdialogue.txt", io_read);
while(fread(dialogue, str, sizeof(str), false))
{
new idx;
format(Chats[ChatCount], 256, "%s", strtok(str, idx));
ChatCount++;
}
print("Bot Dialogue has been loaded!");
}
else
{
print("Bot Dialogue has not been loaded!");
}
#endif
#if BOT_FEATURE == true
forward BotChat();
public BotChat()
{
if(ccount == sizeof(Chats)) ccount = 0;
new str[256];
format(str, sizeof(str), "%s: "white"%s", BOT_NAME, Chats[ccount]);
SendClientMessageToAll(COLOR_GREEN, str); //Change the colour!
format(str, sizeof(str), "%s: %s", BOT_NAME, Chats[ccount]);
printf(str);
return 1;
}
#endif