Random Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Problem (
/showthread.php?tid=411528)
Random Problem -
Youice - 29.01.2013
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(playerid, text[])
{
for(new greetings=0; greetings<sizeof(GreetingsA);) {
#define max 4
new randchatAex = random(sizeof(randchatA));
if(strfind(text, GreetingsA[greetings]) != -1) SendChat(randchatA[randchatAex]);
greetings++;
}
if(strfind(text, "Can I have a room please?") != -1) StartRecordingPlayback(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
Re: Random Problem -
Threshold - 29.01.2013
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.
Re: Random Problem -
Youice - 29.01.2013
it's not a custom function, it's taken from "a_npc.inc"
Edit: "native SendChat(msg[]);" (the native)
Re: Random Problem -
Threshold - 29.01.2013
Well... any luck?
Re: Random Problem -
Youice - 29.01.2013
Quote:
Originally Posted by BenzoAMG
Well... any luck?
|
I hope so,
Edit: No it didn't (sorry)