Thread: NPC Triggers
View Single Post
  #2  
Old 07-29-2012, 12:03 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Crow View Post
You can't. Triggering NPCs from server- to clientside won't work. Use a weapon NPC to help you.
This is partially true, a serverside triggeraction on an NPC is now received from every player who's using the V6 client. As a result, when updating attr values serverside I'm using it as an optimisation for V6 users, while using a timeout for V5 users:

PHP Code:
function updateSomething(){
  
this.attr[3] = timevar2;
  
triggeraction(this.1this.1"Update"NULL);
}

//#CLIENTSIDE
function onCreated(){
  if(
graalversion 6){
    
this.setTimer(0.05);
  }
}

function 
onPlayerEnters(){
  if(
graalversion >= 6){
    
this.checkUpdate();
  }
}

function 
onTimeout(){
  
this.checkUpdate();
  
this.setTimer(0.05);
}

function 
checkUpdate(){
  if(
this.updatetime != this.attr[3]){
    
this.onActionUpdate();
  }
}

function 
onActionUpdate(){
  
this.updatetime this.attr[3];
  
//stuff

Might also be worth noting that for an NPC to receive a triggeraction, it requires a shape, which can be set by:

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
//32 pixels would be equal to 2 tiles
  
this.setshape(13232);


Last edited by ffcmike; 07-29-2012 at 12:17 AM..
Reply With Quote