Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   How to check if a level is updated? (https://forums.graalonline.com/forums/showthread.php?t=71575)

konidias 01-20-2007 06:45 AM

How to check if a level is updated?
 
Is there a way to tell via npc if a level has been updated?

I have some putnpc's that I want to destroy if the level gets updated and I don't know of any way to go about doing this.

coreys 01-20-2007 07:03 AM

Quote:

Originally Posted by konidias (Post 1266591)
Is there a way to tell via npc if a level has been updated?

I have some putnpc's that I want to destroy if the level gets updated and I don't know of any way to go about doing this.

function onCreated()

If an NPC is in a level, it gets created whenever the level is updated.

konidias 01-20-2007 07:08 AM

No. "put npc"

Meaning it's not being created when the level is updated. It stays put.

edit: "created" doesn't tell when a level is updated either. just when an npc was created. I can't very well have the npc destroy when it's created, now can I?

Chandler 01-20-2007 08:10 AM

Quote:

Originally Posted by konidias (Post 1266598)
No. "put npc"

Meaning it's not being created when the level is updated. It stays put.

edit: "created" doesn't tell when a level is updated either. just when an npc was created. I can't very well have the npc destroy when it's created, now can I?

Technically, you can.
HTML Code:

function onCreated()
{
  this.curMode = !this.curMode; //Makes it true first time around...
  if (!this.curMode)
  { 
    this.destroy(); //Destroy once 'this.curMode' is back to false
  }
}

However, I am not too sure if this would work. Would be better if there were a function.

konidias 01-20-2007 04:31 PM

Yeah but my problem is that these npcs were placed in the level with putnpc2. So they are only created one time, no matter how many times you update the level. It's quite an important feature I'd be surprised if there isn't some way of detecting an update level via script...

I'll try to get in touch with Stefan I guess.

Chandler 01-20-2007 08:46 PM

After another think of this, I figured you could do it through
HTML Code:

function onPlayerChats()
{
  if (player.chat != "levelUpdate")
  {
    return false;
  }
  requesttext("options", "");
}
function onReceiveText(texttype, textoption, textlines)
{
  for (temp.curLine = 0; temp.curLine < textlines.size(); temp.curLine++)
  {
    if (textlines[temp.curLine].starts("staff="))
    {
      temp.curStaff = textlines[temp.curLine].tokenize();
      if (player.account in temp.curStaff)
      {
        temp.hasFound = true;
        break;
      }
    }
  }
  if (temp.hasFound)
  {
    this.onCreated();
  }
}

Not really tried it, but I guess it could work, pretty pointless though...
Upon inspection, it didn't work at all... My conclusion being "Script koni_test deleted by Chandler"

Riot 01-20-2007 09:03 PM

Quote:

Originally Posted by Chandler (Post 1266757)
After another think of this, I figured you could do it through

Not really tried it, but I guess it could work, pretty pointless though...
Upon inspection, it didn't work at all... My conclusion being "Script koni_test deleted by Chandler"

It may work, but it wouldn't catch if you uploaded the level, or used an RC command to do it.

konidias 01-20-2007 10:01 PM

Actually it's been pointed out to me that "if (updatelevel)" or "function onUpdateLevel()" actually works and does exactly what I need.

Thanks for the help though! Glad to know there is actually a feature for this.

So just for anyone that might be searching for a way to do this months from now.

if (updatelevel) checks to see if the level has been updated (not if an npc has been initialized or created) So that you can have database npcs know if a level was updated or changed. :)

Chandler 01-20-2007 10:02 PM

Quote:

Originally Posted by konidias (Post 1266776)
Actually it's been pointed out to me that "if (updatelevel)" or "function onUpdateLevel()" actually works and does exactly what I need.

Thanks for the help though! Glad to know there is actually a feature for this.

So just for anyone that might be searching for a way to do this months from now.

if (updatelevel) checks to see if the level has been updated (not if an npc has been initialized or created) So that you can have database npcs know if a level was updated or changed. :)

Oh woah, so there is such a thing! Thanks ^^

konidias 01-22-2007 10:24 PM

Okay, Stefan answered my PM. (I feel bad now that I already know the answer) But he also mentioned it's for dbnpcs... So I'm not sure the updatelevel event will work in level npcs or weapons...

Skyld 01-22-2007 10:34 PM

Quote:

Originally Posted by konidias (Post 1267614)
Okay, Stefan answered my PM. (I feel bad now that I already know the answer) But he also mentioned it's for dbnpcs... So I'm not sure the updatelevel event will work in level npcs or weapons...

Level NPCs are refreshed on update level and therefore will experience onCreated. Database NPCs, being stuck on a layer on top of the level, if you like, will receive onUpdateLevel.

Chandler 01-22-2007 10:43 PM

What a bizarre turn of events!


All times are GMT +2. The time now is 07:15 AM.

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