Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   if (playersays) problem (https://forums.graalonline.com/forums/showthread.php?t=43169)

melissa1988 03-02-2003 07:14 PM

if (playersays) problem
 
Hey, I've never done scripting before and I'm just starting to learn a little bit. Would anyone be kind enough to tell me what I did wrong with this little script I made? It works for the most part, but some parts won't

NPC Code:
  
if (playertouchsme) {message Welcome to my room!;sleep 3;message Do you like punk?;sleep 3;
if (playersays(yes)) {message Really? I LOVE punk!;sleep 3;message You got any liquor?;sleep 3;
if (playersays(yes)) {message Cool! Give me some shots!;sleep 3;
if (playersays(no)) {message Aww...You're no fun...;}}}
}
if (playersays(no)) {message You're *** then! Punk rules!;sleep 3;
if (playersays(**** you)) {message No thanks, I have your mom for that!;sleep 3;
if (playersays(shut up pickles!)) {message No you shut up!;shootnuke down;}}
}
if (playerisfemale) {message Hey baby wanna screw?;sleep 3;
if (playersays(no)) {message That's okay, you're just one of millions!;sleep 3;
if (playersays(yes)) {message Go lay in the bed! I'll be there...;sleep 3;
if (playersays(okay)) {message Go lay in the bed! I'll be there...;sleep 3;}}}
}
if (playeronhorse) {message Get off that horse you ****! You're trackin' mud on my floor!;sleep 3;
}
if (wa****) {message Ouch! Take this ya ****!;shootnuke down;
}


the parts that don't work are the (playersays(no)) {message Aww...you're no fun}, (playersays(**** you)) {message No thanks...}. and a few others i think...
I'm still learning this so it's probably something stupid so I appologize to all the scripting gurus here. I've been searching all over the place for someone to help, so this is my last resort. Thanks in advance. I'm not asking for someone to fix my code, but for someone to tell me how to fix it or suggest a better way to do this.. :) thanks

AlexH 03-02-2003 07:28 PM

Use

if (playerchats&&strequals(#c,text)) {
stuff;
}

Instead of playersays.

Torankusu 03-02-2003 08:23 PM

Quote:

Originally posted by AlexH
Use

if (playerchats&&strequals(#c,text)) {
stuff;
}

Instead of playersays.

Example using your (melissa-whatever's) code:

NPC Code:

if (playertouchsme){
message Welcome to my room!;
sleep 3;
message Do you like punk?;
sleep 3;
if (playerchats && strequals(#c,yes)) {message Really? I LOVE punk!;
sleep 3;
message You got any liquor?;
sleep 3;
}
}


#c = chat, in case you didn't know.

strequals is really useful, as is strcontains and other things with "str" in them. I recommend looking them up and learning more about them. Check in newfeatures also. There are some pretty new commands there.

Knuckles 03-02-2003 08:39 PM

Quote:

Originally posted by Torankusu

Example using your (melissa-whatever's) code:

NPC Code:

if (playertouchsme){
message Welcome to my room!;
sleep 3;
message Do you like punk?;
sleep 3;
if (playerchats && strequals(#c,yes)) {message Really? I LOVE punk!;
sleep 3;
message You got any liquor?;
sleep 3;
}
}


#c = chat, in case you didn't know.

strequals is really useful, as is strcontains and other things with "str" in them. I recommend looking them up and learning more about them. Check in newfeatures also. There are some pretty new commands there.

O.O, I don't think that would work.. >:P.
It would, accept you would have to say it EXACTLY on the 3rd second.

NPC Code:

if (playertouchsme) {
message Hi, whats up?;
sleep 1;
message Do you like punk?;
this.mode = 1; // Just pretend that this means 'if was talked to'
}

if (playerchats && strequals(#c,yes) && this.mode == 1) message Oh cool! Me too!;
// Noticed I added the && this.mode == 1.
// Thats to check if the NPC was talked to/touched

// Else if the player chats NO.. blah
else if (playerchats && strequals(#c,no) && this.mode == 1) message Ewww! I can't belive you don't like punk!;


Torankusu 03-02-2003 08:55 PM

Quote:

Originally posted by Knuckles


O.O, I don't think that would work.. >:P.
It would, accept you would have to say it EXACTLY on the 3rd second.

NPC Code:

if (playertouchsme) {
message Hi, whats up?;
sleep 1;
message Do you like punk?;
this.mode = 1; // Just pretend that this means 'if was talked to'
}

if (playerchats && strequals(#c,yes) && this.mode == 1) message Oh cool! Me too!;
// Noticed I added the && this.mode == 1.
// Thats to check if the NPC was talked to/touched

// Else if the player chats NO.. blah
else if (playerchats && strequals(#c,no) && this.mode == 1) message Ewww! I can't belive you don't like punk!;


I didn't test it, nor was I expecting it to work. I just showed him how to use the playerchats and strequals. He can find out the bugs on his own.

Knuckles 03-02-2003 09:08 PM

Quote:

Originally posted by Torankusu

I didn't test it, nor was I expecting it to work. I just showed him how to use the playerchats and strequals. He can find out the bugs on his own.

o.O, okie.

melissa1988 03-02-2003 09:28 PM

Thanks! That seems to be more efficient

I'm having a problem with else if though

NPC Code:

if (playertouchsme) {message Hi, welcome to my humble abode!;sleep 1;message Do you like punk?;this.mode = 1;}
if (playerchats && strequals(#c,yes) && this.mode == 1) message Oh cool! Me too!;sleep 2;message You got any liqour?;this.mode = 2;
else if (playerchats && strequals(#c,no) && this.mode == 1) message You're *** then! Punk rules!;
else if (playerchats && strequals(#c,maybe) && this.mode == 1) message Maybe? What kinda goofball answer is that?;
else if (playerchats && strequals(#c,no) && this.mode == 2) message Damn! I wanna get FUBARed!;
}



it tells me no if-cause specified...i don't understand what that means

Falados 03-02-2003 10:21 PM

Dont use playerchats inside other things =\.
I dont think it is a wise idea to nest events... strequals(#c,whatever) should suffice, as long as it is nested in your event (in this case, the event is playertouchsme)

melissa1988 03-02-2003 11:05 PM

Thanks. :) Sorry I'll remember that in the future
It works now. :)

funnylinkwantsbomys 03-03-2003 07:27 AM

if (playertouchsme){
message Welcome to my room!;
sleep 2;
message Do you like punk?;
sleep .5;
if (playerchats && strequals(#c,yes)) {message Really? I LOVE punk!;
sleep 2;
message You got any liquor?;
sleep 2;
}
}
sleep should be small between those?

Knuckles 03-03-2003 07:42 AM

Dont put the playerchats inside the playertouchsme.

HoudiniMan 03-03-2003 01:23 PM

I'd show you a little example here... but after i read what it says it would insult the maker and anybody who contributed for that npc to exist at all :\

adam 03-03-2003 05:01 PM

Quote:

Originally posted by Kaimetsu
It's kinda annoying when people don't listen to me :\
:-( It only happened once, you ever gonna unblock me?

Quote:

Originally posted by funnylinkwantsbomys
if (playertouchsme){
message Welcome to my room!;
sleep 2;
message Do you like punk?;
sleep .5;
if (playerchats && strequals(#c,yes)) {message Really? I LOVE punk!;
sleep 2;
message You got any liquor?;
sleep 2;
}
}
sleep should be small between those?

You really should find a way to do it without sleep, sleep can be hazardous. Try timeouts. And again, don't use playerchats inside of another if statement.

HoudiniMan 03-03-2003 05:39 PM

In general while still not supporting the boozer npc...

NPC Code:

if (playerenters) {
message initial;
sleep 2; //
message ; // only needing sleep if you want to clear the message
}
if (playerchats&&strequals(#c,yes)) {
message newmessage;
}
if (playerchats&&strequals(#c,newreply)) {
message another new message;
}



Sleep is unneeded unless you want the message to leave after a couple seconds, in which case you need to set it to blank

screen_name 03-03-2003 07:03 PM

Quote:

Originally posted by funnylinkwantsbomys
if (playertouchsme){
message Welcome to my room!;
sleep 2;
message Do you like punk?;
sleep .5;
if (playerchats && strequals(#c,yes)) {message Really? I LOVE punk!;
sleep 2;
message You got any liquor?;
sleep 2;
}
}
sleep should be small between those?


Listen to Kai!

NPC Code:

if (playertouchsme) {
message Welcome to my room!;
sleep 2;
message Do you like punk?;
sleep 2;
if (strequals(#c,yes)) {
message Really? I LOVE punk!;
sleep 2;
message You got any liquor?;
sleep 2;
}
}


tlf288 03-04-2003 05:42 AM

NPC Code:

if (playertouchsme) {
message Listen to frickin Kai! k?;
set asked;
}

if (playerchats && asked) {
if (strequals(#c,Ok)) {
message Thank you, he is the smartest being ya know!;
}
else if (strequals(#c,No)) {
message Well then your just a dope...;
}
else if (strequals(#c,Why)) {
message Becasue he is the smartest being, duh!;
}

sleep3;
message;
}



Comment the sleep3 and message to make it so the message doesn't clear.

melissa1988 03-04-2003 06:07 PM

Well at any rate, thanks for giving me several ways to do the same effect. :) I really appreciate how helpful you guys have been.

G_yoshi 03-08-2003 08:29 PM

Quote:

Originally posted by Kaimetsu
NPC Code:

if(playertouchsme){
message So, you wanna see how I'd code it?;
this.state=1;
timeout=2;
}
if(timeout) message;
if(playerchats){
if(this.state==1){
if(strequals(#c,yes)){
message Well you can just go to hell; timeout=2;
}
elseif(strequals(#c,no)){
message Well you can just go to hell; timeout=2;
}
}
}


This is why you should not anger the script monkey ;)

screen_name 03-08-2003 08:39 PM

Quote:

Originally posted by G_yoshi


This is why you should not anger the script monkey ;)

^.^
I answered no. I guess I get to visit Michigan.

G_yoshi 03-08-2003 09:03 PM

Quote:

Originally posted by screen_name


^.^
I answered no. I guess I get to visit Michigan.

Erm...::confused::

adam 03-09-2003 12:29 AM

Quote:

Originally posted by screen_name


^.^
I answered no. I guess I get to visit Michigan.

Why are you visiting me?

screen_name 03-09-2003 09:33 AM

There is a place named Hell, Michigan.

G_yoshi 03-10-2003 01:36 AM

Quote:

Originally posted by screen_name
There is a place named Hell, Michigan.
Already knew that.

Lots of other cities with strange names.


All times are GMT +2. The time now is 06:07 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.