Graal Forums

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

ToNy_W 05-07-2005 08:22 PM

setlevel2
 
Her i's my problem, i have a gmap, and i want to use a setlevel2 to warp player on it. But when i tried to warp player on a x that was bigger than 192 or a Y that was bigger than 192, it said "failed", that only happens if i'm not on the gmap, if i am on the gmap, i can warp anywhere on it... So how can i warp a player thats not on the gmap to this gmap on 250,250...?

Admins 05-07-2005 09:32 PM

Quote:

Originally Posted by ToNy_W
Her i's my problem, i have a gmap, and i want to use a setlevel2 to warp player on it. But when i tried to warp player on a x that was bigger than 192 or a Y that was bigger than 192, it said "failed", that only happens if i'm not on the gmap, if i am on the gmap, i can warp anywhere on it... So how can i warp a player thats not on the gmap to this gmap on 250,250...?

For setlevel2 you currently need to use the name of the map part (e.g. mymap_a-5.nw) like you would do when you would use the normal links in the editor.

ToNy_W 05-09-2005 12:53 AM

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?

Kaimetsu 05-09-2005 01:02 AM

Quote:

Originally Posted by ToNy_W
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?

You probably shouldn't mix sleeps and timeouts. What exactly is your NPC supposed to do?

Gambet 05-09-2005 01:22 AM

Try this instead..

NPC Code:

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



^Now, instead of the npc immediately going from the playerchats to the timeout, it will 'sleep' for 10 seconds then it will execute the timeout. In your case, the number you specify for the timeout doesnt matter, but what matters is the number you specify in the sleep.

Evil_Trunks 05-09-2005 01:07 PM

Quote:

Originally Posted by Gambet
Try this instead..

^Now, instead of the npc immediately going from the playerchats to the timeout, it will 'sleep' for 10 seconds then it will execute the timeout. In your case, the number you specify for the timeout doesnt matter, but what matters is the number you specify in the sleep.

I think the real problem here is that when he does sleep, the timeout is completed immediately? In any case, it's better not to mix timeouts and sleeps.

I don't think you really understand how scripts work, looking at your explanation.

CheeToS2 05-09-2005 06:43 PM

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 :)

xAndrewx 05-09-2005 07:38 PM

Very cool. Use Cheetos's version.

Gambet 05-09-2005 09:35 PM

Quote:

Originally Posted by Evil_Trunks
I think the real problem here is that when he does sleep, the timeout is completed immediately? In any case, it's better not to mix timeouts and sleeps.

I don't think you really understand how scripts work, looking at your explanation.


His problem was that after the sleep it went to the timeout portion. In his script, the timout = # part, basically only set the standards for the if (timeout). The only thing that actually "paused" the script would be the sleep. He wanted his npc to sleep for 10 seconds before performing the timeout, which is what I did with my script. I kept it simple, since what he's trying to do (as in what he wants the npc to do) is simple.

In other words, how he had scripted it, he thought that the timeout = # would make the npc "pause" for the amount indicated, but in fact, it didnt matter at all what that number was. What mattered was the number in the sleep. He had sleep 0.5, which is why the npc immediately triggered the timeout right after the sleep. I understand what his problem was (from what he's said). Of course, there is better ways to do it, as indicated by Cheetos, but it doesnt make mines wrong.

Admins 05-10-2005 04:51 PM

When "sleep" is called then it is using the normal timeout variable, but starts the script execution at one command after the sleep command. So code that follows the after-sleep stuff sees a timeout event too. May be just move the if (timeout) above the if (playerchats) stuff, or better always use timeout and not sleep, and remember in this.mode or so what kind of timeout it is (timeout after creating, timeout after touching).


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

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