Level NPC Server -> Client Communication?
As the title suggests, I'm looking to have the serverside interact with the clientside in a level npc. I'm aware of the backwards direction which I would use triggeraction for, however, I'm not sure how to go about server to the client. Thank you for taking your time to read this and possibly answer this short question!
EDIT: Also, what I'm trying to accomplish is showing a polygon around an NPC detecting a range of 5 tiles around the NPC. This polygon should be visible to everyone. |
in the new V6 client a serverside triggeraction() in a level npc is received on the clients of all players in the level, and if you want to store data that can be retrieved on the client of a player who enters the level you can also use this.attr[#]
PHP Code:
|
Thank you however this doesn't appear to be working:
PHP Code:
PHP Code:
PHP Code:
|
im not sure that you can specify parameters as 'this.' variables like that as opposed to using 'temp.', have you tried doing 'this.chat = "test";' to ensure the trigger is at least being received?
also having the first parameter in the setshape() as 0 instead of 1 might be a problem, and is the setshape() on both clientside and serverside? |
Quote:
Just tested using 1 as setshape and nothing changes anyways. |
have you used setshape(); on clientside as well?
when its used serverside that doesnt get synchronised to clientside in the way that some other variables do, and because the trigger is being received on the client it needs a shape to be set clientside |
Quote:
EDIT: Nope, this isn't working either. Really weird. |
could you post the entire script?
it sounds like youre doing everything right based on what youve provided so it would be interesting to see it all pieced together one guess would be that the serverside function which contains 'triggeraction();' isnt being executed, have you debugged that as well? |
PHP Code:
|
there is no default event called 'onInitialize' in level npcs, only database npcs and putnpc2s
its also worth mentioning that there is no player parameter in that onInitialize event using the same event on clientside and serverside is perfectly fine, you can even use onCreated() within multiple classes that are joined to the same object |
Quote:
temp.npc.trigger("Initialize", params...); |
oh well in that case although it should still work its not a good idea to use that event name because it will be invoked every time the npc server is restarted
only other explanations i can think of is that you cant do 0.05 second timeouts serverside and trying it could be preventing the entire script, plus the npcs x and y are being altered after the triggeraction (which does get synchronised to clientside) and that could somehow be breaking it i would suggest commenting out the timeout out and seeing if the triggeraction works |
Quote:
I'm pretty sure this has something to do with the shape(s), that's always been the problem for me. Unfortunately I'm in a bit of a hurry and wasn't able to really look over your script at all, maybe I'll be able to get back too it later. |
Quote:
|
Maybe I'm not getting the right idea here, but why don't you just put the scheduleevent(.05, "showPoly"); (which might work but should have a third param, so scheduleevent(.05, "showPoly", null);) in the clientside onCreated(), as you seem to be sending the trigger right after the NPC is placed anyways.
|
All times are GMT +2. The time now is 05:27 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.