Graal Forums

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

Furyshots 03-18-2008 12:49 PM

Timer
 
Could anyone help me with making a timer script?
If you touch a npc in game there should be a timer (I would like a visible one, but an invisible one is good too), and if you touch another npc the timer needs to stop. I hope you guys can help me out :D.

Twinny 03-18-2008 01:02 PM

Quote:

Originally Posted by Furyshots (Post 1380563)
Stuff

Please read the rules, found here

Quote:

1. Be clear on your ability level. In other words, do not post asking for scripts, or asking people to fix scripts that are above your ability level. If you are writing a script to aid learning, then try writing a simpler script. If you are looking for a script for a server, then the best solution is probably to hire a scripter.
Basically: please don't ask for complete scripts. If you require such things, ask for a NAT in the playerworld hirings subforum but please adhere to the rules there.

Have you tried making such a script yourself?

Furyshots 03-18-2008 01:08 PM

I can make really really simple scripts, but I dont know how to start on making a timer. Could you guys help me out or tell me what commands I need to use etc.

projectigi 03-18-2008 01:10 PM

You've got PM

Furyshots 03-18-2008 01:17 PM

What I forgot to mention it is for a school project so it needs to work on graal editor. Igi the script you send to me didnt work well:(.

Tigairius 03-18-2008 06:01 PM

Quote:

Originally Posted by Furyshots (Post 1380570)
What I forgot to mention it is for a school project so it needs to work on graal editor. Igi the script you send to me didnt work well:(.

NPC Code:

if (created) {
this.time = 0;
timeout = 0.05;
}
if (timeout) {
this.time++;
message #v(this.time);
timeout = 1;
}



You can also do:
NPC Code:

while(1 == 1) {
this.time++;
message #v(this.time);
sleep 1;
}


Up to you really. If you need help with anything else feel free to forum PM me or contact me via AIM (Tigairius).

DustyPorViva 03-18-2008 06:24 PM

PHP Code:

if (created) {
  
timeout=3;
  
timershow;
}
if (
timeout) {
  
message TadaI'm done!;



Chompy 03-18-2008 08:03 PM

NPC1
PHP Code:

// NPC made by Chompi
//#CLIENTSIDE
if (created) {
  
setimg block.png;
  
level.timer 0;
  
level.time 0;
  
timeout 0.05;
}
if (
playertouchsme) {
  if (
level.timer == 0) {
    
level.timer 1;
    
timeout 0.05;
  }
}
if (
timeout) {
  if (
level.timer == 1) {
    
level.time += 0.05;
    
message Touch the other blockhurry!;
    
timeout 0.05;
  }else
    
message Touch me to start the timer!;


NPC2
PHP Code:

// NPC made by Chompi
//#CLIENTSIDE
if (created) {
  
setimg block.png;
  
timeout 0.05;
}
if (
timeout) {
  if (
level.time 0)
    
message #v(level.time);
  
timeout 0.05;
}
if (
playertouchsme) {
  if (
level.timer == 1) {
    
level.timer 0;
    
message Player touched me in #v(level.time) seconds!;
    
level.time 0;
  }


Bah, long time since I did gs1 but they should work in the editor

Tigairius 03-18-2008 08:16 PM

Quote:

Originally Posted by Chompy (Post 1380619)
Bah, long time since I did gs1 but they should work in the editor

Geez, leave some room for him to learn XD

Chompy 03-18-2008 08:22 PM

Quote:

Originally Posted by Tigairius (Post 1380621)
Geez, leave some room for him to learn XD

oh.. uh.. let me think.. i wonder.. no wait a min....
bah, making those scripts made me open the editor which I haven't done in months xD

Well, I guess he could learn from them? :o

Inverness 03-18-2008 09:14 PM

Quote:

Originally Posted by Tigairius (Post 1380592)
You can also do:
PHP Code:

while(== 1) {
  
this.time++;
  
message #v(this.time);
  
sleep 1;



Don't use a while loop, it will probably stop at the maxlooplimit which is 10,000 by default. If you want an unending loop always use timers or scheduled events.

Even if you did use a while loop it should be while (true) {}

cbk1994 03-18-2008 10:03 PM

Quote:

Originally Posted by Twinny (Post 1380565)
Please read the rules, found here



Basically: please don't ask for complete scripts. If you require such things, ask for a NAT in the playerworld hirings subforum but please adhere to the rules there.

Have you tried making such a script yourself?

nice sig

Chompy 03-18-2008 10:21 PM

Quote:

Originally Posted by cbkbud (Post 1380665)
nice sig

huh, taco godzilla?

zokemon 03-18-2008 11:07 PM

Quote:

Originally Posted by Inverness (Post 1380629)
Don't use a while loop, it will probably stop at the maxlooplimit which is 10,000 by default. If you want an unending loop always use timers or scheduled events.

Even if you did use a while loop it should be while (true) {}

I'm pretty sure there isn't a loop limit offline. I may be thinking of the days pre v2 though.

DustyPorViva 03-18-2008 11:09 PM

I don't really see why anything more than a timeout is needed.


All times are GMT +2. The time now is 12:49 PM.

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