Random Problem
#1

Hello,

PHP код:
static GreetingsA[9][] = {
"hi","hello","Good Moorning","good afternoon","yo","hey","'ey","hey nigga'","'ey nigga"
};
new 
randchatA[][] =
{
       
""#NPC_NAME"Hello, how are things?",        
    
""#NPC_NAME"Hi, how are you?",                   
    
""#NPC_NAME"Excuse me do you even know me?!",    
    
""#NPC_NAME"Who're you?"                    
}; 
PHP код:
public OnPlayerText(playeridtext[])
{
    for(new 
greetings=0greetings<sizeof(GreetingsA);) {
        
#define max 4
        
new randchatAex random(sizeof(randchatA));
        if(
strfind(textGreetingsA[greetings]) != -1SendChat(randchatA[randchatAex]);
        
greetings++;
    }
    if(
strfind(text"Can I have a room please?") != -1StartRecordingPlayback(ON_FOOT,"NPC1Hotel");
    return 
1;

The problem is, when you start chatting with the NPC it just keep spamming the Greetings.

Ex:

Код:
Me:Hello
Bot: Hello, how are things?		
Bot: Hi, how are you?          	
Bot: Excuse me do you even know me?!	
Bot: Who're you?  
Bot: Who're you?
and so on but with random choices not organized..

any explanation will be appreciated!, thanks
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    for(new greetings = 0; greetings < sizeof(GreetingsA); greetings++)
    {
        if(strfind(text, GreetingsA[greetings]) != -1)
        {
            new randchatAex = random(sizeof(randchatA));
            SendChat(randchatA[randchatAex]);
            break;
        }
    }
    if(strfind(text, "Can I have a room please?") != -1) StartRecordingPlayback(ON_FOOT,"NPC1Hotel");
    return 1;
}
If that doesn't work, show us your SendChat function.

EDIT:
Quote:
Originally Posted by Youice
Посмотреть сообщение
it's not a custom function, it's taken from "a_npc.inc"
Well then, see if the code works. I don't use a_npc often.
Reply
#3

it's not a custom function, it's taken from "a_npc.inc"
Edit: "native SendChat(msg[]);" (the native)
Reply
#4

Well... any luck?
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Well... any luck?
I hope so,

Edit: No it didn't (sorry)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)