Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Err help? (https://forums.graalonline.com/forums/showthread.php?t=42685)

SSRobgeta 02-12-2003 04:42 AM

Err help?
 
Umm I was trying to scrip something that counts how many letters in your text you say, there are. This is kinda simple but it only works 1 time. And when I added a timeout it oviously didn't help. It's werid. I probally overlooked something but here ya go:
NPC Code:
// NPC made by Rob Getashu
if (created) {
this.ctxtcount = strlen(#v(#c));;
}
if (playerchats) {
if (this.ctxtcount=<8&&this.ctxtcount>0) {
message good;
}
if (this.ctxtcount>8) {
message bad;
}
}



Thanks

CheeToS2 02-12-2003 01:41 PM

and you have two ;'s after the line of code Kai just questioned.. won't really harm the script I think, but its pointless none the less (you only need one) x.x

[edit]theres another big problem in it, but I think i'll let you figure that out yourself.. hint: you're using if (created) to check the length of the players chat text[/edit]

SSRobgeta 02-12-2003 03:28 PM

Yea, but Kai, when I took out the (#v) it didn't work anymore. But when I leave it in, the string always stays 1? Maybe I was using the wrong command to read the number of letters?

SSRobgeta 02-12-2003 03:47 PM

Quote:

Originally posted by Kaimetsu
Cheetos pointed out the biggest problem. if(created) only runs once.
SO Should I use if (timeout) there?

SSRobgeta 02-12-2003 10:18 PM

Quote:

Originally posted by Kaimetsu


That depends. When do you want it to make the check?

Well, whatever the person chats, the script will make sure the text is 8 or below characters. Then it'll make the text a string and save it. And later print it out.

adam 02-12-2003 10:24 PM

Quote:

Originally posted by SSRobgeta

Well, whatever the person chats, the script will make sure the text is 8 or below characters. Then it'll make the text a string and save it. And later print it out.


Well there it is. You've got it. Now tell us, what event happens when a player chats?
what function checks the length of the string?
what is the string for the players current chat text?
how do you save a string?
how do you print out a string?


And in that order.

SSRobgeta 02-12-2003 10:26 PM

Quote:

Originally posted by adam



Well there it is. You've got it. Now tell us, what event happens when a player chats?
what function checks the length of the string?
what is the string for the players current chat text?
how do you save a string?
how do you print out a string?


And in that order.

Err first, This is just a beta test on what I can;t work out. And Couldn't you easily just read the damn script instead of making me explain it :\

CheeToS2 02-12-2003 10:35 PM

Quote:

Originally posted by SSRobgeta

Err first, This is just a beta test on what I can;t work out. And Couldn't you easily just read the damn script instead of making me explain it :\

he asked those questions to explain to you how to create your script correctly x.x

SSRobgeta 02-12-2003 10:50 PM

Quote:

Originally posted by CheeToS2

he asked those questions to explain to you how to create your script correctly x.x

o.o

adam 02-12-2003 11:03 PM

Quote:

Originally posted by CheeToS2

he asked those questions to explain to you how to create your script correctly x.x

Indeed I did. :-)

All of the answers to those questions are in the script posted already. But things are a bit out of order in it. >.< Maybe he's just not used to the way graal does things.

SSRobgeta 02-12-2003 11:16 PM

Quote:

Originally posted by adam
Maybe he's just not used to the way graal does things.
Yea, I'm use to other Programing languages and I haven't scripted in Gscript for awhile, but I got it fixed see!
NPC Code:

// NPC made by Rob Getashu
if (created || playerenters) {
timeout = 0.1;
}
if (timeout) {
this.ctxtcount = strlen(#c);
if (this.ctxtcount<=8) {
message good #v(this.ctxtcount);
}
if (this.ctxtcount>8) {
message bad;
}
timeout = 0.1;
}


adam 02-12-2003 11:27 PM

Quote:

Originally posted by SSRobgeta

Yea, I'm use to other Programing languages and I haven't scripted in Gscript for awhile, but I got it fixed see!
NPC Code:

// NPC made by Rob Getashu
if (created || playerenters) {
timeout = 0.1;
}
if (timeout) {
this.ctxtcount = strlen(#c);
if (this.ctxtcount<=8) {
message good #v(this.ctxtcount);
}
if (this.ctxtcount>8) {
message bad;
}
timeout = 0.1;
}


Good job, Now forget the timeout loop and use the playerchats event. :-) Save the timeout loop for something that requires one.

mhermher 02-13-2003 10:23 PM

Why did my post get deleted?

SSRobgeta 02-13-2003 10:30 PM

Quote:

Originally posted by mhermher
Why did my post get deleted?
Your answer lies within the mods young grasshopper...


All times are GMT +2. The time now is 05:56 AM.

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