Thread: setlevel2
View Single Post
  #7  
Old 05-09-2005, 06:43 PM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Quote:
Originally Posted by ToNy_W
Argg, i've had another problem...

if (created) {
timeout=10;
}
if (playerchats) {
message test;
sleep 0.5;
message ;
}
if (timeout) {
message hmm;
timeout=10;
}

well i'm kinda new to scripting, and i was messing around with things online, and i tried the previous script, the problem is that, after i touch it, when it sleeps 0.5 seconds, it execute the stuff in the if (timeout) without waiting 10 secondes...why?
Like you were told in #gscript, there are problems with using sleep and timeout together; you could try something like this instead:
NPC Code:

if (created) {
this.time = 10; // how long until you want it to say hmm
timeout = .5; // making it shorter so we can put the "test" in a timeout instead of sleep
}

if (playerchats) {
message test;
this.texttime = .5; // how long you want it to say test
}

if (timeout) {
this.time -= .5; // this will make this.time count down to 0 (like timeout = 10)
if (this.texttime == 0) // if it is 0, it is time to make the "test" go away
message ;
if (this.texttime >= 0) // if it is bigger than 0, count down
this.texttime -= .5;
if (this.time == 0) { // if time left (from 10 sec) is 0, do the "hmm" message
message hmm;
this.time = 10; // reset the timer
}
timeout=.5;
}


It is a little more complicated that way; you are basically scripting your own timeout system, but it will let you do what you want without using sleep
__________________

Reply With Quote