Quote:
Originally Posted by Crow
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.x + 1, this.y + 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(1, 32, 32);
}