View Single Post
  #13  
Old 09-03-2012, 03:50 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 scriptless View Post
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(commandnxny) {
  if ( 
command == "move" ) {
    
nx;
    
ny;
    
chat "moved" SPC nx SPC ny;
  }
}


//#CLIENTSIDE
function onCreated() {
  
this.catchEvent(GraalControl"onMouseDragged""onMouseDragged");
  
setshape(1getimgwidth(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 .5this.ooy +.5"Serverside""move"this.nnxthis.nny);
  }
}

function 
onMouseDragged(objmodmxmy) {
  if ( 
this.candrag == true ) {
    
mousex this.ox;
    
mousey this.oy;
    
this.nnx mousex this.ox;
    
this.nny mousey this.oy;
  }

First time it's moved it fine after that it breaks.
It looks like it would be fine to send mousex and mousey as coordinate parameters, rather than using this.nnx and this.nny.
Also should use this.ox and this.oy to store this.x and this.y rather than factoring in the mouse position.

It's also worth mentioning that if the image hasn't been downloaded to your client yet, getimgwidth() and getimgheight() would return 0.
Reply With Quote