PDA

View Full Version : NPCServer updates (6)


Admins
07-24-2005, 08:32 AM
There are new versions of gserver and npcserver, they are uploaded to all machines, but might need to be restarted manually. There are a few updates for the new scripting engine:

- Fixed Switch-in-switch commands, before the switch command was eating the case label that was in front of it
- new onInitialized() event for database npcs when the server has been restarted
- You can create scriptable objects now (besides players and npcs):
this.item1 = new TStaticVar();
this.item1.join("itemfunctions");
...
this.item1.destroy();
Differences to normal objects:
- they are never copied, they are only linked - same behaviour like with GUI objects and players or npcs, if you do pl = player then pl will not recreate the player, if you access pl.account then it will actually access player.account
- they are scriptable, which means they can join classes and run scripts (think of living inventory objects)
- they are destroyed once no variable is linking to it anymore (e.g. if you do this.item1 = NULL; this is using a garbage collector system like in Java), or if you call destroy() for the object
- they can have a name, you can do this.item1 = new TStaticVar("MyFirstItem") and then also access it directly by name, e.g. MyFirstItem.subvar = 123

Rick
07-25-2005, 05:08 AM
Wahoo! Stefan added my suggestions!

This makes me very happy. :)

Malinko
07-25-2005, 04:55 PM
this.item1.join("itemfunctions");
...
this.item1.destroy();
Thanks.

Wahoo! Stefan added my suggestions!

This makes me very happy. :)
Now you can own all playerworlds with Era.

MAYBE. ;)

Inverness
07-27-2005, 05:20 AM
Would it be possible to do:

new TStaticVar("Test123") {
h = 3;
}
and then use Test123.h to get 3?
I'm basing this off of the Gui Controls...

napo_p2p
07-28-2005, 05:02 AM
It seems that Aeon didn't go up after the update ...

ChibiChibiLuc
07-28-2005, 06:21 AM
I really can't see any use for this.. Can someone give me an example?

Why not just use something like whatever.huh = 3?
Unless I'm mislead on how it functions..

Admins
07-28-2005, 03:24 PM
You would need to do this.h = 3
Like I said, it can join classes, then you can define public functions in the class and then you can do stuff like object.functionname(). Also it can use timeouts and such. I guess it's good for inventory systems, and for complex data.

ChibiChibiLuc
07-28-2005, 04:37 PM
Oh, sorry, I was being an idiot.

For some reason, I thought it could only hold variables.. And then I read it again and I'm like.. Wow..

Inverness
07-29-2005, 04:41 AM
This works fine, thanks for help.

Having its own timeout is very nice.

It would be useful if it was possible to call public functions without an object like you do with normal functions.

Admins
07-30-2005, 12:44 AM
What doesn't work with those functions ?

Inverness
07-30-2005, 03:31 AM
When you do call a public function you have to put the weapon name before it, i'd like to be able to call it without using the weapon object:
addItem()
instead of:
weaponname.addItem()

I'd also like to be able to call functions clientside<->serverside. It would help greatly in my inventory system.

Rick
07-30-2005, 03:42 AM
When you do call a public function you have to put the weapon name before it, i'd like to be able to call it without using the weapon object:
addItem()
instead of:
weaponname.addItem()Why? This obfuscates your code.

I'd also like to be able to call functions clientside<->serverside. It would help greatly in my inventory system.While I agree, I find that using triggers is more logical. Your scripts should be designed to do as little as possible between server and client to keep network usage down.

napo_p2p
08-02-2005, 06:02 AM
- new onInitialized() event for database npcs when the server has been restarted


Is that when the whole server restarts, or also when the NPC server is restarted?

I have in a database NPC:
function onInitialized() {
echo("Test");
}


But when I restart the NPC server, it doesn't work.