Quote:
Originally Posted by cbk1994
..
|
I was trying to not confuse him since he's new to scripting. But that works better then what I suggested.
Quote:
Originally Posted by Stowen
Alright guys, so I used the formula for distance that Chris has supplied me with and it works great. I get a constant moving speed of 10. Not sure what the measurement for speed on Graal would be LOL but I got 10. That's enough for me to do my work. Anyways, here's the script if anybody wishes to use it themselves.
PHP Code:
//#CLIENTSIDE
function onCreated() { onTimeOut(); }
function onTimeOut() { this.x1 = player.x; this.y1 = player.y; sleep(1); this.x2 = player.x; this.y2 = player.y; dist(this.x1, this.y1, this.x2, this.y2); }
function dist(x1, y1, x2, y2) { this.dist = (((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) ^ 0.5; player.chat = this.dist; setTimer(0.05); }
|
Normally you set the timer at the end of the timeout function itself..
and sleep(1).. isn't needed.. let me adjust it a little.
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.x1 = player.x;
this.y1 = player.y;
setTimer(1);
}
function onTimeOut() {
dist(this.x1, this.y1, player.x, player.y);
// set the values to current position
this.x1 = player.x;
this.y1 = player.y;
setTimer(1);
}
function dist(x1, y1, x2, y2) {
this.dist = (((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) ^ 0.5;
player.chat = this.dist;
}
The reason I changed it like this is becasue if you set the variables after you check the distance.. the next time the script runs the dist() function it will be using the old values.. then updating them after the comparison. also sleep causes script problems.. you can just set the timer to 1 second intervals and not need sleep() or waitfor()