i just tested the following script in a local npc (putnpc2) and it worked fine -
PHP Code:
function onCreated() {
this.ani = "grab";
setshape( 1, 80, 80);
}
function onInitialize(temp.pobj) {
this.owner = temp.pobj.account;
triggeraction(this.x + .5, this.y + .5, "Test", null);
}
function onPlayerChats() {
if (player.chat == "test") {
this.onInitialize(player);
}
}
//#CLIENTSIDE
function onCreated() {
this.setshape(1, 80, 80);
}
function onActionTest() {
this.scheduleEvent(.05, "ShowPoly");
this.chat = ":D";
}
function onShowPoly() {
with(findimg(200)) {
polygon = {
this.x - 5, this.y - 5,
this.x + 5, this.y - 5,
this.x + 5, this.y + 5,
this.x - 5, this.y + 5
};
red = green = blue = 0;
alpha = .6;
layer = 3;
}
}
so im fairly confident its breaking either because of the timeout or because of whats happening in the timeout
unrelated but also note how 'scheduleEvent' invokes 'onShowPoly' from the parameter 'ShowPoly'
if all else fails then why not try setting a gani attr on serverside, then moving the poly script into the gani attr script?
npc -
PHP Code:
function onCreated() {
this.owner = null;
this.ani = "grab";
setshape( 1, 16 * 5, 16 * 5);
this.attr[5] = "polytest.gani";
}
polytest.gani -
PHP Code:
SCRIPT
function onPlayerEnters(){
with(findimg(200)) {
polygon = {
this.x - 5, this.y - 5,
this.x + 5, this.y - 5,
this.x + 5, this.y + 5,
this.x - 5, this.y + 5
};
red = green = blue = 0;
alpha = .6;
layer = 3;
attachtoowner = true;
}
}
SCRIPTEND
using 'attachtoowner = true;' will make the poly automatically follow the npc object as it moves