Talking bots
#1

Well, I have attempted to make a talking bot which will talk to you, I have tried to set it on a timer but it just does not work.


This part works apart from the "SetTimer".
pawn Код:
if(vehicleid == botcar)
    {
        SendClientMessage(playerid, COLOR_GREY, "Taxi Driver says: Welcome to the Taxi mate, please sit back and enjoy the ride.");
        SetTimer("TaxiTalk", 60000, true);
    }
pawn Код:
forward TaxiTalk(playerid);
public TaxiTalk(playerid)
{
    ProxDetector(3.0, playerid, "Taxi Driver says: Haven't I seen you before?", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    ProxDetector(3.0, playerid, "Taxi Driver says: Lovely weather we are having.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    ProxDetector(3.0, playerid, "Taxi Driver says: You look happy.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    return 1;
}
Reply
#2

Ofcourse it doesn't work, your function has a parameter.
use SetTimerEx
pawn Код:
SetTimerEx("TaxiTalk", 60000, true, "i", playerid);
Reply
#3

* and you could also change the clientmessage into SendPlayerMessageToPlayer so it actually looks like the bot is talking to you. much cewler

find it here https://sampwiki.blast.hk/wiki/SendPlayerMessageToPlayer
Reply
#4

Thanks! I have a question, I have this:
pawn Код:
forward TaxiTalk(playerid);
public TaxiTalk(playerid)
{
    ProxDetector(3.0, playerid, "Taxi Driver says: Haven't I seen you before?", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    ProxDetector(3.0, playerid, "Taxi Driver says: Lovely weather we are having.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    ProxDetector(3.0, playerid, "Taxi Driver says: You look happy.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
    return 1;
}
How could I possible pause it so at the end of one sentence the bot pauses then says the second sentence and at the end of everything the bot does not repeat it.
Reply
#5

At the top of your script:
pawn Код:
new talkSentences = -1;
And the timer function:
pawn Код:
forward TaxiTalk(playerid);
public TaxiTalk(playerid)
{
    switch(talkSentences)
    {
        case 0:
        {
            ProxDetector(3.0, playerid, "Taxi Driver says: Haven't I seen you before?", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
            talkSentences++;
        }
        case 1:
        {
            ProxDetector(3.0, playerid, "Taxi Driver says: Lovely weather we are having.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
            talkSentences++;
        }
        case 2:
        {
            ProxDetector(3.0, playerid, "Taxi Driver says: You look happy.", COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY, COLOR_GREY);
            talkSentences = -1;
        }
    }
    return 1;
}
And one more thing, edit your part where the timer is started like this:
pawn Код:
if(vehicleid == botcar)
    {
        SendClientMessage(playerid, COLOR_GREY, "Taxi Driver says: Welcome to the Taxi mate, please sit back and enjoy the ride.");
        talkSentences = 0;
        SetTimer("TaxiTalk", 60000, true);
    }
And that should do it. Test it and tell me if it works.
Reply
#6

Thanks, works, Is there anyway I could freeze the bot until some one enters it?
Reply
#7

How do you mean freeze the bot?
Reply
#8

Like using "TogglePlayerControllable" but used on the bot.
Reply
#9

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Like using "TogglePlayerControllable" but used on the bot.
Is this possible?
Reply
#10

Sure..why not ?
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)