![]() |
PutNPC to DBNPC communication
How would that be done? I tried having the putNPCs findNPC the DBNPC, but I don't think they're quite reaching...could someone provide a code sample? I mean, I could probably get the desired results with server strings, but eww...
putNPC: on created, send the DBNPC some sorta ID. on hit or whatever, right before destroying itself, let the DBNPC know DBNPC: When a request comes in from a player's weapon let's say, should be able to find and manipulate the putNPCs in its list no matter where they are. Like, the player says "NPC #6587, move to the right", and it should despite the DBNPC and the player being in different levels from the putNPC. Or am I going about my ultimate goal in the silliest way possible, and the server side of a weapon can Easily search all NPCs on the server, compile a list, and tell them what to do? :-P |
Well, in the DBNPC you can store the classes object. And manipulate it from there...
Like, in the class, you could have. PHP Code:
PHP Code:
|
Hmm, and npc_name is the dbNPC's name? I'll have to give that a try.
|
If you're trying to do what I think you're trying to do, I would probably do this:
In the class that is being joined via putnpc's PHP Code:
PHP Code:
|
Goodness! While elucidating, Jazz's solution works quite well as it stands; I think I have enough code now to lump together some sort of "Find all NPCs in the database, show an arrow pointing to the closest such NPC, tell that NPC to run the "stand still" script" code...
|
I did, in fact, write an example implementation of this a while ago on the wiki: http://wiki.graal.net/index.php/Crea..._Communication
|
You do not need to use findnpc or the (@ "var") syntax if the NPC or weapon name is standard.
Here is my implementation for the class, just showing how the NPC is registered: PHP Code:
PHP Code:
|
Huh. I tried using functions in the first place and they didn't seem to findNPC each other...
|
Quote:
|
I mean I used to have it set up such that
the putnpc function oncreated(){ //etc ZombieControl.addMob(this); //etc } ZombieControl public function addMob(param1){ this.mobs.add(param1); } Maybe I didn't have it as a public function, maybe that was the whole problem. Pretty sure I did, but I've been wrong before. ^^; |
Hrm... a mob? Maybe you don't actually need a database and to just trigger the other monsters in the mob, if that makes any sense?
|
The mob's just one NPC that displays multiple items in its area, and the trouble with triggering is telling NPCs in other levels what to do.
|
Hmm you could just do something like this in the class script
HTML Code:
//NPC.addMember(this); to call it |
Quote:
|
| All times are GMT +2. The time now is 10:23 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.