Graal Forums

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

projectigi 01-26-2008 01:14 AM

Detecting Updates
 
Hi,

is there any way to detect if a weapon has been added/updated/whatever?

Twinny 01-26-2008 01:25 AM

Since you gave no real information, I'd say just have an updateid var. It checks itself against the server and updates itself if the server has a higher number.

cbk1994 01-26-2008 02:45 AM

Explain.

You could just use onCreated, if you mean when someone hits UPDATE in RC?

Chompy 01-26-2008 02:51 AM

Well, you have these:
PHP Code:

function onCreated() {
}

function 
onPlayerEnters() {
}

function 
onInitialized() {



cbk1994 01-26-2008 03:27 AM

Quote:

Originally Posted by Chompy (Post 1371920)
Well, you have these:
PHP Code:

function onCreated() {
}

function 
onPlayerEnters() {
}

function 
onInitialized() {



I've never needed onPlayerEnters in a script. onCreated works fine for me.

Not exactly sure what onInitialized is.

DustyPorViva 01-26-2008 03:45 AM

onInitialized is when the code is first executed on server start, I believe.

onCreated is fired whenever the NPC is saved/updated.

Chompy 01-26-2008 03:49 AM

Quote:

Originally Posted by cbkbud (Post 1371925)
I've never needed onPlayerEnters in a script.

Hmm, I used it in my baddy script :o In the timeout, when there's no players it will set timeout to 0 and don't execute anything. So, in the onPlayerEnters() event I restart the timeout again etc. :o

I think it's pretty nice :)

cbk1994 01-26-2008 04:23 AM

Quote:

Originally Posted by Chompy (Post 1371931)
Hmm, I used it in my baddy script :o In the timeout, when there's no players it will set timeout to 0 and don't execute anything. So, in the onPlayerEnters() event I restart the timeout again etc. :o

I think it's pretty nice :)

Sorry, I meant in a weapon, like I assume he is talking about.

EDIT: On second thought, I used it once to make a zone system (meaning PK and No-PK zones).

DustyPorViva 01-26-2008 05:58 AM

I use it for map-related instances.

projectigi 01-26-2008 11:23 AM

i meant if theres a way to detect that a weapon has been added/updated(any weapon in rc)(from a weapon or dbnpc)(without changing the actual weapon you check)

Inverness 01-26-2008 12:47 PM

The only way to detect if a weapon has been updated is to put something in its onCreated() area which is called when updated.

projectigi 01-26-2008 02:56 PM

well i just wanna do a non-anonymous echo()(that it adds the weapon name)
but i need to know if a new weapon has been added xD

Chompy 01-26-2008 03:28 PM

Quote:

Originally Posted by projectigi (Post 1372000)
well i just wanna do a non-anonymous echo()(that it adds the weapon name)
but i need to know if a new weapon has been added xD

Err, you want to detect from one wnpc that an other wnpc has been updated?

projectigi 01-26-2008 03:59 PM

no, that a new wnpc has been added

cbk1994 01-26-2008 05:30 PM

Like added to the player?

in a loop something like:
PHP Code:

if ( this.oldWeps != player.weapons )
{
  
// ...
}
this.oldWeps player.weapons

?

projectigi 01-26-2008 05:32 PM

no, added in rc

cbk1994 01-26-2008 05:43 PM

Quote:

Originally Posted by projectigi (Post 1372024)
no, added in rc

Then onCreated would be the only way, to my knowledge of course.

Chompy 01-26-2008 06:38 PM

Hmm, why would you want that? o.o

Anyways, you made this thread to see if there was an event for it? Or some way to detect it? Or an idea that you thought could be added :o

projectigi 01-26-2008 06:47 PM

to see if theres a way to do it :p

well because i have to overwrite the echo for all weapons, and new weapons don't have it overwritten, and i don't feel like using a timeout XD

zokemon 01-26-2008 07:40 PM

The only way to do that would be to have some script that would either read the "weapons/" folder (not recommended) or to read the "weapons" variable (serverside) which is a list of all weapons on the NPC Server.

Do the latter using a loop or so like someone previously suggested. Not a very good use of your NPC Server's CPU though.

And no, there is no event for when a new WNPC is added to the NPC Server (other then locally with-in that script, but that doesn't help you).

Twinny 01-27-2008 12:54 AM

Add a weapon/object called "version". In every script, add version.(@this.name)++; If the version number is 1, doStuff();

Otherwise, I cannot see a point in your desires >_<

zokemon 01-27-2008 01:44 AM

Yeah but that requires adding stuff to each new script which kind of defeats the purpose.


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

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