Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Whats the differance between timeout and sleep? (https://forums.graalonline.com/forums/showthread.php?t=47382)

SilentSkripter1988 08-22-2003 12:00 AM

Whats the differance between timeout and sleep?
 
Sleep seems to stop the npc, timeout seems to do nothing, and also gani's wont play for me, how do I get a dang gani to play ?

Neoreno 08-22-2003 12:05 AM

Sleep pauses the script for a certain time. Timeout is a countdown.

SilentSkripter1988 08-22-2003 12:06 AM

So like if I do timeout=10 it will keep going with the script but nothing will happen when timeout is finished therefore making timeout utterly useless ?

Riot-Starter 08-22-2003 12:07 AM

Timeout waits the given seconds then calls to the "timeout" statement without stoping the script.

Sleep delays execution.

as for ganis:
Make shure you have the .gani extension on the filename and use
setani gani name w/o .gani,params;

marcoR 08-22-2003 12:09 AM

sleep is a pause in the script, for as long as you tell it to, timeout is a loop. e.g.:

NPC Code:


if (created){ //starts a code block
timeout=0.05; //this sets the loop refresh;
} //ends a code block

if (timeout)//this begins the loop{ //starts a code block
message Fat People; //the NPC says Fat People
sleep 0.5; //sleeps half a second
message Skinny People; //the NPC says Skinny People
timeout=0.05; //this completes the loop
} //ends a code block




A sleep

NPC Code:


if (created)//if the NPC is created{ //starts a code block
message Fat people; //the NPC says Fat People
sleep 2; //pauses 2 seconds
message Skinny People; //the NPC says Skinny People
} //ends a code block




this is as far as my feeble mind understands this exact script, tho my wording probably isn't great. (i tried tho)

Riot-Starter 08-22-2003 12:11 AM

Quote:

Originally posted by marcoR
sleep is a pause in the script, for as long as you tell it to, timeout is a loop. e.g.:

NPC Code:


if (created){ //starts a code block
timeout=0.05; //this sets the loop refresh;
} //ends a code block

if (timeout)//this begins the loop{ //starts a code block
message Fat People; //the NPC says Fat People
sleep 0.5; //sleeps half a second
message Skinny People; //the NPC says Skinny People
timeout=0.05; //this completes the loop
} //ends a code block




A sleep

NPC Code:


if (created)//if the NPC is created{ //starts a code block
message Fat people; //the NPC says Fat People
sleep 2; //pauses 2 seconds
message Skinny People; //the NPC says Skinny People
} //ends a code block



Dont use "//" comments then put {, it's the same as not putting it at all. Drop it down to the next line

marcoR 08-22-2003 12:12 AM

... I was just trying to make it easy for him to understand.

Riot-Starter 08-22-2003 12:17 AM

Just sayin something, if he copies and pastes:
"Error: Unknown command: }"

marcoR 08-22-2003 12:23 AM

well if he does copy and paste it, i'll break his thumbs, because I have that exact script copyrighted

Riot-Starter 08-22-2003 12:26 AM

I seriously doubt you can copyright such a simple script:p

KainDaMan 08-22-2003 12:27 AM

timeout is not a loop unless you make it a loop

NPC Code:

if (playerenters) {
timeout=5;
}
if (timeout) {
message #n sucks!;
}


This accomplishes the same thing as
NPC Code:

if (playerenters) {
sleep 5;
message #n sucks!;
}


but at the same time, isn't a loop.
Like Kiirar said above, timeout is litterally a countdown
the command
NPC Code:

timershow;


does the equivelent to message of the time it has until the timeout event is called

SilentSkripter1988 08-22-2003 06:21 AM

About the Gani's, what are params for? Btw read my post under playerworlds era about banned. see how pissed off i am, 3 p2p accounts, grr.

Neoreno 08-22-2003 04:57 PM

Read the gani forum.

Snakeandy7 08-22-2003 04:59 PM

params = #p
:P

osrs 08-22-2003 07:57 PM

Timeout is an invisible flag that is 'created' when the timeout count reach 0. Another example:

NPC Code:

if(playerenters){
timeout=5;
}

if(timeout){
say2 Chasam;
}



When timeout be 0,it will 'create' the flag and will execute the code inside that timeout block.

By the way,Kaidaman,timeout & sleep aren't the same thing and won't execute the same thing as you said.

Spark910 08-22-2003 08:22 PM

Unless I didnt read it, I think you all missed out the big part.

NPC Code:

if (playertouchsme) {
sleep 2;
hide;
}



You touch it, you wait until 2 before it hides, it does not execute ANYTHING until it has waken from sleep. So it wont do anything until it stops sleeping.

NPC Code:

if (playertouchsme) {
timeout=2;
}

if (timeout) {
hide;
}



If I keep touching it, the timeout will go back to 2. But sleep will not, as it is asleep and can not take any more commands.
If its not correct what I have said, then its because im not a scripter.

marcoR 08-22-2003 08:48 PM

i'm not a scripter either, that's all right, but i've never looked at it that specific way.. kinda like it

KainDaMan 08-22-2003 11:06 PM

Osrs, you obviously failed to read correctly what I had said because the thing is that what I had said was correct and in that particular case, would do the same thing as a sleep, save for the very valid point spark pointed out.

Kaimetsu 08-23-2003 12:44 AM

Important point: On a lower level, sleep basically just makes a note of where the instruction counter is and sets a timeout, then jumps to the same place when the timeout occurs. People often try to combine the two (never a good idea) and end up going crazy.

osrs 08-24-2003 12:26 AM

Quote:

Originally posted by KainDaMan
Osrs, you obviously failed to read correctly what I had said because the thing is that what I had said was correct and in that particular case, would do the same thing as a sleep, save for the very valid point spark pointed out.
Sleep pauses the script execution,timeout doesn't,so both systems are working same?
I understand what you had said,it will execute the same effect on script,but won't work same...

konidias 08-24-2003 01:01 PM

Quote:

Originally posted by SilentSkripter1988
So like if I do timeout=10 it will keep going with the script but nothing will happen when timeout is finished therefore making timeout utterly useless ?
Uh, you sure act pretty knowledgeable for someone who has no idea what they are talking about. :|

If you don't know what timeout does, don't say it is useless, it makes you look like an idiot.


All times are GMT +2. The time now is 01:02 PM.

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