Quote:
Originally Posted by ffcmike
While that would be fine for a weapon script, there is no 'this.name' within a local NPC on Clientside. You can however store it as an attr Serverside. The first parameter should also be 'npc' rather than 'gui'.
PHP Code:
function onCreated(){ this.attr[1] = this.name; } //#CLIENTSIDE function sendTrigger(){ triggerserver("npc", this.attr[1], mousex, mousey); }
|
I was using it in a Weapon Script. I was just showing how I was placing them.. now oddly. I can drag the npc.. it changes the chat above the npc.. but its not sending the right cords or something.. every time i move it it says the same x/y...
PHP Code:
function onActionServerside(command, nx, ny) {
if ( command == "move" ) {
x = nx;
y = ny;
chat = "moved" SPC nx SPC ny;
}
}
//#CLIENTSIDE
function onCreated() {
this.catchEvent(GraalControl, "onMouseDragged", "onMouseDragged");
setshape(1, getimgwidth(this.image), getimgheight(this.image));
this.oox = this.x;
this.ooy = this.y;
}
function onMouseDown() {
if ( mousex in |x,x+getimgwidth(this.image)/16| && mousey in |y,y+getimgheight(this.image)/16| ) {
this.ox = mousex - x;
this.oy = mousey - y;
this.candrag = true;
}
}
function onMouseUp() {
if ( this.candrag == true ) {
this.candrag = fasle;
triggeraction(this.oox + .5, this.ooy +.5, "Serverside", "move", this.nnx, this.nny);
}
}
function onMouseDragged(obj, mod, mx, my) {
if ( this.candrag == true ) {
x = mousex - this.ox;
y = mousey - this.oy;
this.nnx = mousex - this.ox;
this.nny = mousey - this.oy;
}
}
First time it's moved it fine after that it breaks.