![]() |
Npc to Npc
I've been trying to get an NPC to communicate with another. (such as touching one affects the other) Trigger doesn't seem to work, and I am unable to get callnpc to work either. I don't know if it is the way I am doing it or how it's called...
|
PHP Code:
CallNPC is really a relic from pre npcserver/pre GS2 days, may still work Clientside but it's somewhat deprecated. |
You can use getareanpcs(float, float, float, float) and loop through and find the NPC by a unique id or joined class even.
Baddies find other baddies, I.e: PHP Code:
PHP Code:
PHP Code:
|
I believe ffcmike's explaination is sufficient, however I'm unsure of the this.level.var. Do i insert the level name here or npc? I'm confused as to how to implement in the level... I tried in the script and it comes back as it can't find this.level.someothername.wasTouched (I tried different names in my script, just guess and test with no luck)
|
"this.level" you leave the same, the "somename" part is up to you, you just need to make sure that whatever name is being referred to in one NPC is the specified reference name for the opposite NPC.
|
Yes I understand that, but the reference name is confusing? I place the this.level.var which is what the player would touch, then in the other NPC this.level.var is triggered to hide the image? I'm still very confused, please enlighten me.
|
I believe "var" is a protected variable name, try something else.
|
thats just in my example on forums
|
Maybe show your current script of the 2 NPCs?
Should be as simple as this: NPC 1 PHP Code:
PHP Code:
|
Yea thats how I was doing it, but I get this error and it's the same with mine and yours... : Script: Function obj2.wasTouched not found at line 6 of explodeswitch in script of npcs[0] (in level zie_scripttest.nw at pos (39, 32))
|
Strangest thing actually, I tried it myself and it seemed to be doing nothing at all despite all of my echo's suggesting it was working, I then reconnect to find that the NPC was indeed being hidden just for some reason this was not being sent to the player so it remained visible on my client, this is something Stefan should probably look into.
You can always just to this Clientside if this is a single player thing. |
lol.. I didn't think I was crazy.. so just clientside the whole script?
|
This definitely works clientside.
|
Thanks mike, sucked it took like 2hrs to do something so simple lol
|
Kinda on the same note I am now trying to lay an npc down and have it affect another npc while it is there. again should i trigger an action? I am unsure of this process, but I am trying to affect the npc clientside. I may have to do it serverside?
|
Yeah I still can't get it to work. I have a custom bomb that explodes and when it explodes I want it to hit a switch that triggers something else. I'm just not sure how to send it...
|
does this.gmap.blah work aswell so a variable can be pulled from anywhere on the gmap?
|
i don't really know... I do know that this.level works (Clientside) but with the bomb I would think that it would be easier to just add a trigger? or a public function (which I'm not completely sure i know how or what to do with besides placing in all npcs involved). Since the bomb is added via putnpc2, but I don't really know..
|
Quote:
|
Quote:
I noticed this behaivor when I called public functions which should have updated the NPCs X, Y or hid them but nothing would happen. Adding a trigger causes it to update to players. |
Sounds great, thanks.
|
Still unsure of how that would work.. I haven't really worked with DB NPCs, and I can't seem to get that trigger to function correctly.. set it clientside and check severside right?
|
A simple bomb demonstration and how to use getareanpcs.
class: bomb PHP Code:
PHP Code:
Level script for bomb: PHP Code:
PHP Code:
|
Ok so that all works, but stil working with the bomb, and I want to trigger client now because the this.level.whatever doesn't seem to work serverside. Also it would require every player to use a bomb here.
PHP Code:
|
Sorry for the double post, but is it required to triggerserver to be able to triggerclient?
|
Quote:
|
Quote:
triggerclient allows the server to send "messages" to the client. They aren't dependent on each other, so your script doesn't have to include both if they don't need to. |
ok so why won't this work?
PHP Code:
I just can't get the clientside to function correctly. This is a switch that when it explodes it sends the wasExploded() to do something in another npc in the same level. Maybe public function needs to be server side, but a different puublic function works fine in clientside with a touch switch? |
Only weapon scripts can receive messages from triggerclient.
Why not just hide and show on the server-side instead? |
this way everyone has to use a bomb to use the switch not just one person can hit the switch with the bomb and the rest get the effect.
So can I join this from a weapon script or is there another way to work around it? |
Well the client has the (+90%) same functions so you can apply the concepts of getareanpcs on the client-side of the script.
|
So something like this would work? I had been trying to work with that as well but I can't seem to get it working either. Maybe my syntax is wrong? I dunno..
PHP Code:
|
Bump (sorta)
This is what I am working with, and everything works Except calling the function from the SwitchDB to the door. This is the Switch Database PHP Code:
PHP Code:
PHP Code:
|
does it echo anything in doorOpen? I would also recommend opening the door with a trigger instead of a public function. trigger forces the NPC to update to clients and what not.
|
right but i can't use trigger beecause i want this to be able to be clientside as well. It gives me an error and says it can't find function doorOpen.
|
Are you putting 'on' before the function name. You need to put that with trigger
Such as PHP Code:
PHP Code:
|
A trigger won't work clientside from the DB I don't think, but I don't really know. I don't understand why it won't pick this up as a function though? A trigger would be great if I could work it server to client and client to server without it being a weapon, unfortunately I have tried this.
|
Quote:
|
Sorry for like the triple post, but this seems to call the echo just don't know how to update the object now...
PHP Code:
|
That last post is definitely going in the wrong direction.
One thing I can think of is that the onCreated() of the door or switch is getting called before the database's. For debugging, echoing an object doesn't really make much sense, try echoing temp.door.type() instead to see if anything is actually there. |
| All times are GMT +2. The time now is 03:39 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.