Graal Forums

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

Novice 03-06-2009 10:53 PM

Timeout problem
 
I'm doing a simple Levitation script just for fun.
For some reason, everything except the timeout works.
Even when I change the name of the timeout to something like "onAir" and use "scheduleEvent(0.05,"Air",null);" or changing the name of the timeout to "Air" and using "sleep(0.05); Air();" it just won't work.
Here's what I've got. Also, I don't care if you use this on your own server, just give me credit.
PHP Code:

//Scripted by Novice
//#CLIENTSIDE
function onCreated() {
  
this.rep = {"walk","grab","pull","push","sit"};
  
this.air 0;
  
player.0;
  
setTimer(0.05);
}

function 
onWeaponFired() {
  if (
this.air == 0) {
    
this.air 1;
    for (
i=0i<this.rep.size(); i++)
      
replaceAni(this.rep[i],"idle");
  }
  else if (
this.air in {1,2}) {
    
this.air 0;
    for (
i=0i<this.rep.size(); i++)
      
replaceAni(this.rep[i],this.rep[i]);
  }
}

function 
onTimeOut() {
  if (
player.== && this.air != 0)
    
this.air 2;
  if (
player.== && this.air != 0)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);


Is there anything that looks wrong in there?

LoneAngelIbesu 03-06-2009 11:13 PM

I don't see this.stage being defined anywhere, yet it's in two of your conditional checks. So, I took it out, and the effect is a small up-and-down movement.

PHP Code:

function onTimeout() {
  if (
player.== 2)
    
this.air 2;
  if (
player.== 1)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);



Novice 03-06-2009 11:23 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1471902)
I don't see this.stage being defined anywhere, yet it's in two of your conditional checks. So, I took it out, and the effect is a small up-and-down movement.

PHP Code:

function onTimeout() {
  if (
player.== 2)
    
this.air 2;
  if (
player.== 1)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);



Ah, I had this.stage from an earlier version.
Even with that changed, it still won't work.

LoneAngelIbesu 03-06-2009 11:25 PM

Quote:

Originally Posted by Novice (Post 1471910)
Ah, I had this.stage from an earlier version.
Even with that changed, it still won't work.

The only other thing I changed was the deployment method. I used onPlayerChats(), because the onWeaponFired() key in being used on Valikorlia, already.

So, it could possibly be a problem with the way you are deploying. Have you tried using onKeyPressed()?

Novice 03-06-2009 11:35 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1471914)
The only other thing I changed was the deployment method. I used onPlayerChats(), because the onWeaponFired() key in being used on Valikorlia, already.

So, it could possibly be a problem with the way you are deploying. Have you tried using onKeyPressed()?

I had put up a check system with setting player's chat after setting this.air , "player.chat = this.air;" seemed to work setting your chat to "0" or "1".

Chompy 03-06-2009 11:42 PM

I don't see why you need an always running timeout loop.

You should make a check so it only runs while active/levitating, and doesn't run at all when not active/levitating. Just a tip.

Novice 03-07-2009 07:26 PM

Fixed the problem: GServer needed to restart :p


All times are GMT +2. The time now is 04:16 AM.

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