29.08.2011, 02:14
I recently just made this for my server...
Start off like this:
This message will display for everyone and will be chosen randomly to talk.
Mine is much more complicated, but I am not giving it away. This is just a simple one.
The array is formatted so:
Bot message first, name after. I also have one where the name can be mentioned first by the bot, then the bots message after.
Let me know if it isn't working right or ask me for help.
Start off like this:
pawn Код:
// top of script
new Ids[] =
{
0,1
};
// above will be used to choose id 0 and 1 (assuming the bots aren't id 0 or 1, you can change the numbers and amount to how many bots you have
new botresponses[3][256] =
{
{"You smell like shit,"},
{"That's not what the other bots told me,"},
{"gtfo out of my server,"}
};
// 3 means amount of messages,
// 256 means maximum size of all sentences (you can make it 128, 256 is innefficient)
---------
// Under onplayertext ...
new randbot1 = random(sizeof(botresponses)); // this will choose a random message from the new array we made (called botresponses)
new id = random(sizeof(Ids)); // will make the server choose id 0 and 1 (assuming they are the bots) and their name will be chosen to send the message to the player who talks
new rand = random(25);
new Name[24];
GetPlayerName(playerid,Name,24);
if(rand >= 0 && rand <= 25)
{
format(string,128,"%s %s",botresponses[randbot1],Name);
SendPlayerMessageToAll(Ids[id], string);
}
// the first %s will be the message sent from the botresponses array, while the 2nd %s will be the name of the player who the bot talks to.
Mine is much more complicated, but I am not giving it away. This is just a simple one.
The array is formatted so:
Bot message first, name after. I also have one where the name can be mentioned first by the bot, then the bots message after.
Let me know if it isn't working right or ask me for help.