Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-27-2013, 07:11 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
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.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-27-2013 at 07:18 PM.. Reason: Wrote my instance
Reply With Quote
  #2  
Old 10-27-2013, 07:21 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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:
function updatePoly(temp.polyarray){
  
this.attr[1] = int(timevar2);
  
this.attr[2] = temp.polyarray;
  
triggeraction(this.1this.1"UpdatePoly""");
}

//#CLIENTSIDE
function onCreated()
  
this.setshape(13232);

function 
onPlayerEnters()
  if(
this.attr[1] != this.save_time)
    
this.onActionUpdatePoly();

function 
onActionUpdatePoly(){
  
this.save_time this.attr[1];
  
this.showpoly(200this.attr[2].tokenize(","));

__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #3  
Old 10-27-2013, 07:28 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Thank you however this doesn't appear to be working:
PHP Code:
triggeraction(this..5this..5"Test"this.owner); 
when I try and catch in it clientside doing
PHP Code:
function onActionTest(this.zowner) {
  
scheduleevent(.05"showPoly");
  
this.chat this.zowner;

I even set the shape of the object doing:
PHP Code:
setshape016 516 5); 
But it still isn't working.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #4  
Old 10-27-2013, 07:31 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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?
__________________
This signature has been deleted by Darlene159.

Last edited by Jakov_the_Jakovasaur; 10-27-2013 at 07:42 PM..
Reply With Quote
  #5  
Old 10-27-2013, 07:51 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
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?
I'm pretty sure 0 works as a setshape because that just allows no movement through the NPC. I did setshape serverside and I have debugged the triggeraction and it isn't receiving it.

Just tested using 1 as setshape and nothing changes anyways.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-27-2013 at 07:54 PM.. Reason: Did a simple test
Reply With Quote
  #6  
Old 10-27-2013, 08:04 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #7  
Old 10-27-2013, 10:11 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
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
Oh thank you, I'll try it!

EDIT: Nope, this isn't working either. Really weird.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-27-2013 at 10:18 PM.. Reason: Not working
Reply With Quote
  #8  
Old 10-27-2013, 10:58 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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?
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #9  
Old 10-27-2013, 11:00 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
PHP Code:
function onCreated() {
  
this.owner null;
  
this.ani "grab";
  
setshape116 516 5);
}

function 
onInitialize(playername) {
  
this.owner playername;
  
triggeraction(this..5this..5"Test"null);
  
onTimeOut();
}

function 
onPlayerChats() {
  if (
player.chat == "bye") {
    
destroy();
  }
}

function 
onActionRightMouse() {
  
destroy();
}

function 
onTimeOut() {
  if (
max(this.owner.xthis.x) - min(this.owner.xthis.x) > 5this.+= 1;
  if (
max(this.owner.ythis.y) - min(this.owner.ythis.y) > 5this.+= 1;
  
setTimer(.05);
}

//#CLIENTSIDE
function onCreated() {
  
setshape116 516 5);
}

function 
onActionTest() {
  
scheduleevent(.05"showPoly");
  
player.chat ":D";
}

function 
showPoly() {
  
with(findimg(200)) {
    
polygon = {
      
this.5this.5,
      
this.5this.5,
      
this.5this.5,
      
this.5this.5
    
};
    
red green blue 0;
    
alpha .6;
    
layer 3;
  }

I know that onCreated is there twice but it seems to those parts seem to work fine.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-27-2013 at 11:00 PM.. Reason: Fixed something
Reply With Quote
  #10  
Old 10-27-2013, 11:03 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #11  
Old 10-27-2013, 11:58 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
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
Sorry I forgot to mention that this was a class and I used putnpc2 then I did:
temp.npc.trigger("Initialize", params...);
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #12  
Old 10-28-2013, 12:10 AM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
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
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #13  
Old 10-28-2013, 11:41 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
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
You're confusing his onInitialize() with the default event onInitialized(). He should be fine.

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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #14  
Old 10-29-2013, 12:44 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by xXziroXx View Post
You're confusing his onInitialize() with the default event onInitialized(). He should be fine.

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.
Thank you. But I don't think the shape is the problem.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 10-29-2013 at 12:44 AM.. Reason: Minor Edit
Reply With Quote
  #15  
Old 10-29-2013, 02:00 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
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.
__________________
-Ph8
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:03 AM.


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