NPC Bots
#1

Hey guys, so i just started giving NPC a shot and so far i think its pretty awesome.

But i ran into a few things that keep popping into my head.

How can i make it so that every now and then a bot replies to someone.

For an example,

Player- "Hey Bottie, your dumb"

Bot- "Hey [Name], Cool Story Bro"


Also, how can i make it so that if you press LMB near a bot an menu pops up. I can make the menu but i would have trouble with communicating to the bot that the player press LMB
Reply
#2

You mean like a chat bot...

The script recognises its name and it gives a random reply...?

Also the LMB - IsPlayerInRangeOfPoint(get the bot co-ords place them here) if(newkeys & key define here) i can make this for you to but you have to make the dialog

P.S if you reply that you mean that ill update this post with the code when its created
Reply
#3

So would it be kinda like this.


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_LOOK_BEHIND)
{
GetDistanceFromMeToPoint(2.0, 3.0, 2.0, distance);
{
ShowPlayerDialog(lalalallalalalalallalala);
Reply
#4

Quote:
Originally Posted by Shockey HD
Посмотреть сообщение
So would it be kinda like this.


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_LOOK_BEHIND)
{
GetDistanceFromMeToPoint(2.0, 3.0, 2.0, distance);
{
ShowPlayerDialog(lalalallalalalalallalala);
Yeah, thats if your bot isnt moving anywhere if it is you want to set a timer updating NPC co-ords every 10 secs or so

Plus i cant make the chat bot anymore im not going to be here much longer

This forum requires that you wait 120 seconds between posts. Please try again in 60 seconds. - atleast make this Timer a little smaller - seriously 1 second im wasting my life waiting for the timer to run out -.-
Reply
#5

I recently just made this for my server...

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

Instead of writing the bots name each time why dont you do

new NameOfBot[20] = "BotMan"; or somthing along those lones other than that your code isnt bad
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)