20.02.2007, 16:31
Delvour\'s pawn version :
The timer is needed, else it send the message before what you type in the chat
You need \'strsep\' and you can find it HERE
Have fun...
ok y_less, corrected.
pawn Code:
public OnGameModeInit()
{
SetTimer("SendBotMessage",500,1);
return 1;
}
new BOT_NAME[] = "Delvour";
new ANSWERS_A[][] = {"Yes.","No.","Maybe.","Fuck you!","Who knows...","I don\'t know.","Whatever.."};
new ANSWERS_B[][] = {"That\'s not a question.","You don\'t ask me anything.","I answer to questions."};
new ANSWERS_C[][] = {"I\'m busy atm.","Yes?","What?","Zzzz..","Leave me alone!","Do not annoy me."};
new WaitAnswer;
new botmsg[256];
public OnPlayerText(playerid, text[])
{
new idx = 0;
botmsg = strsep(text,idx);
if (!strcmp(botmsg,BOT_NAME,true) && !WaitAnswer)
{
botmsg = strsep(text,idx);
if (text[strlen(text)-1] == \'?\' && strlen(text) > strlen(BOT_NAME)+4)
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_A[random(sizeof(ANSWERS_A))]);
}
else if (text[strlen(text)-1] != \'?\' && strlen(text) > strlen(BOT_NAME))
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_B[random(sizeof(ANSWERS_B))]);
}
else
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_C[random(sizeof(ANSWERS_C))]);
}
format(botmsg,sizeof(botmsg),"%s: %s",BOT_NAME,botmsg);
WaitAnswer = 1;
return 1;
}
return 1;
}
public SendBotMessage()
{
if (WaitAnswer)
{
SendClientMessageToAll(0xFF0000AA,botmsg);
WaitAnswer = 0;
}
}
You need \'strsep\' and you can find it HERE
Have fun...
ok y_less, corrected.