[Tutorial] How to make a "BOT" replies almost everything player says..
#1

Hi everybody there...
Today, I'm gonna show you, How to make a "BOT" that replies almost all words a player says.
Fine... Let's start...
-----------------------------------------------------------------------------------------
1.-Before do anything, We must add the following include at the top of your script...

pawn Code:
#include <a_samp>//Obviously, we have to add a_samp include which contains all the information to work...

2.-You have to go to the following function:


pawn Code:
public OnPlayerText(playerid, text[]) //At this function, We're gonna write, a text and the response from the "BOT" if we call it like this...
{
    return 1;
}

3.-Onto it, We have to add the following things:

pawn Code:
if(!strcmp(text, "Hello Bot", true)) // Here we have to insert the text, This function will check if the player has said this word
4.-
pawn Code:
{
      new string[128]; GetPlayerName(playerid,string,sizeof(string));
      format(string,sizeof(string),"%s[%d]: %s",string,playerid, text);//Here we are going to give the format, when the player says that word...
5.-
pawn Code:
SendClientMessageToAll(GetPlayerColor(playerid), string);//Here we are going to add the function, to send the text...
      SendClientMessageToAll(green, "[BOT]: Hey Wassup!");//Here is the reply...In other words, What the bot will reply to the player... °Don't forget to add the "#define green 0x33FF33AA" Or you'll get an error
6.-
pawn Code:
return 0;//We have to add return 0;//To stop the BOT says it.
    }//Close the bracket.
The whole function will be like this:

pawn Code:
public OnPlayerText(playerid, text[])
{
if(!strcmp(text, "Hi Bot", true))
    {
      new string[128]; GetPlayerName(playerid,string,sizeof(string));
      format(string,sizeof(string),"%s[%d]: %s",string,playerid, text);
      SendClientMessageToAll(GetPlayerColor(playerid), string);
      SendClientMessageToAll(green, "[BOT]iThe_Bot: Hey Wassup!");
      return 0;
    }
    return 1;
}
So Now You can add your own Words And Replies...

Thank you for see my Tutorial.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)