Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2005, 08:22 PM
ToNy_W ToNy_W is offline
Registered User
Join Date: Aug 2003
Location: Quebec
Posts: 130
ToNy_W is on a distinguished road
Send a message via AIM to ToNy_W
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...?
Reply With Quote
  #2  
Old 05-07-2005, 09:32 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #3  
Old 05-09-2005, 12:53 AM
ToNy_W ToNy_W is offline
Registered User
Join Date: Aug 2003
Location: Quebec
Posts: 130
ToNy_W is on a distinguished road
Send a message via AIM to 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?
Reply With Quote
  #4  
Old 05-09-2005, 01:02 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
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?
__________________
Reply With Quote
  #5  
Old 05-09-2005, 01:22 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #6  
Old 05-09-2005, 01:07 PM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
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.
__________________

Reply With Quote
  #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
  #8  
Old 05-09-2005, 07:38 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Very cool. Use Cheetos's version.
__________________
Reply With Quote
  #9  
Old 05-09-2005, 09:35 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #10  
Old 05-10-2005, 04:51 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:40 AM.


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