Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   For Switch and whoever: Staff Boots (https://forums.graalonline.com/forums/showthread.php?t=72560)

Gambet 03-03-2007 06:45 PM

For Switch and whoever: Staff Boots
 
As requested in this thread:
http://forums.graalonline.com/forums...ad.php?t=72559

PHP Code:

//Custom staff boots system
//By: Gambet
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onKeyPressed(code,key)
{
 if (
key == "z")
  {
   if (
this.staff_boots == "on")
    {
      
this.staff_boots this.speed "";
      
player.chat "Staff Boots -Off-";
      
setTimer(0);
    } else
     {
       
this.staff_boots "on";
       
player.chat "Staff Boots -On-";
       
setTimer(0.05);
     }
  }
 if (
code == 187)
  {
   if (
this.speed+<= 10)
    {
     
this.speed+=1;
     
player.chat "Speed: " this.speed;
    }
  } else if (
code == 189)
   {
    if (
this.speed->= 0)
     {
      
this.speed-=1;
      
player.chat "Speed: " this.speed;
     }
   }
}

function 
onTimeOut()
{
 if (
this.staff_boots == "on")
  {
   for (
a=0a<4a++)
    {
     if (
keydown(a))
      {
       switch(
a)
        {
          case 
"0":
           
player.y-=this.speed;
           break;
          case 
"1":
           
player.x-=this.speed;
           break;
          case 
"2":
           
player.y+=this.speed;
           break;
          case 
"3":
           
player.x+=this.speed;
           break;
        }
      }
    }
  }
 
setTimer(0.05);




Made it in like 5 minutes so yeah, do with it as you please. Everyone is open to use it, though there are plenty of boot scripts out there for those of you that don't know how to script -- just add this one to the list!


Though you shouldn't get into the habit of just taking peoples scripts without at least bothering to learn the basics of GScript. It sort of defeats the purpose.


Regardless, enjoy!


:)

Switch 03-03-2007 06:53 PM

THANKS SO MUCH GAMBET! NOW you must read my PM ;P
Also, I put it in my server and found an error. We don't want it at speed 0, so here's a revision:
PHP Code:

//Custom staff boots system
//By: Gambet
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onKeyPressed(code,key)
{
 if (
key == "z")
  {
   if (
this.staff_boots == "on")
    {
      
this.staff_boots this.speed "";
      
player.chat "Staff Boots -Off-";
      
setTimer(0);
    } else
     {
       
this.staff_boots "on";
       
player.chat "Staff Boots -On-";
       
setTimer(0.05);
     }
  }
 if (
code == 187)
  {
   if (
this.speed+<= 10)
    {
     
this.speed+=1;
     
player.chat "Speed: " this.speed;
    }
  } else if (
code == 189)
   {
    if (
this.speed->= 1)
     {
      
this.speed-=1;
      
player.chat "Speed: " this.speed;
     }
   }
}

function 
onTimeOut()
{
 if (
this.staff_boots == "on")
  {
   for (
a=0a<4a++)
    {
     if (
keydown(a))
      {
       switch(
a)
        {
          case 
"0":
           
player.y-=this.speed;
           break;
          case 
"1":
           
player.x-=this.speed;
           break;
          case 
"2":
           
player.y+=this.speed;
           break;
          case 
"3":
           
player.x+=this.speed;
           break;
        }
      }
    }
  }
 
setTimer(0.05);


But the error with THAT is that it STARTS at speed 0, then you ahve to press + (or = ) before it actualy is USABLE to move around on walls and stuff.

napo_p2p 03-03-2007 07:36 PM

Quote:

Originally Posted by Switch (Post 1284086)
But the error with THAT is that it STARTS at speed 0, then you ahve to press + (or = ) before it actualy is USABLE to move around on walls and stuff.

Where you see: player.chat = "Staff Boots -On-";

Just add after: this.speed = 1;

Gambet 03-03-2007 07:49 PM

Quote:

Originally Posted by napo_p2p (Post 1284095)
Where you see: player.chat = "Staff Boots -On-";

Just add after: this.speed = 1;



^


That should fix your problem.

Switch 03-03-2007 08:19 PM

Eheh ok thanks ^.^

Angel_Light 03-03-2007 08:22 PM

I'm just curious, is there a way to make it add and minus speed using the mouse wheel?

Gambet 03-03-2007 08:45 PM

Quote:

Originally Posted by Angel_Light (Post 1284123)
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?



Yes, using the mousewheeldelta and/or mousewheel commands.

Kristi 03-03-2007 08:54 PM

I got bored so I compacted Gambet's script

PHP Code:

//Custom staff boots system
//By: Gambet
//Compacted By: Hell Raven (bordem?)
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onCreated() {
  
this.speed 1// reserve speed setting = better feature?
}

function 
onKeyPressed(code,key) {
  if (
key == "z") {
    
temp.statword = {"Off","On"};
    
this.status abs(temp.status 1);
    
player.chat "Staff Boots -"@temp.statword[this.status]@"-";
    
setTimer(.05 this.status);
  }
  if (
code in {187,189}) {
    
temp.speed this.speed 188 code;
    if(
temp.speed in |1,10|)
      
this.speed temp.speed;
  }
}

function 
onTimeOut() {
  for (
a=0a<4a++)
    if (
keydown(a))
      
player.(char(120 + (a+1) % 2)) += (-int(a/2)*2) * this.speed;
      
  
setTimer(.05);



Twinny 03-04-2007 11:36 AM

Quote:

Originally Posted by Kristi (Post 1284134)
I got bored so I compacted Gambet's script

You beat me to it >_<

cbk1994 03-04-2007 03:25 PM

Quote:

Originally Posted by Angel_Light (Post 1284123)
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?

In a timeout something like this
PHP Code:

function onTimeOut()

 if ( 
mousewheeldelta && this.speed )
 {
  
this.speed -= 1;
 }
 if ( 
mousewheeldelta && this.speed 10 )
 {
  
this.speed += 1;
 }
 
setTimer0.05 );


Sorry about horrible formatting ... the mousewheeldeltas might need to be altered (I forget which way is which).
[EDIT]
Tested this, and fixed the mousewheeldeltas.
Also, this.status = abs(temp.status - 1);?
Should be:
this.status = 1 - this.status;
or:
this.status = abs(this.status - 1);

Riot 03-04-2007 09:08 PM

Quote:

Originally Posted by cbkbud (Post 1284538)
Also, this.status = abs(temp.status - 1);?
Should be:
this.status = 1 - this.status;
or:
this.status = abs(this.status - 1);

or even this.status = !this.status; ;)

napo_p2p 03-04-2007 09:10 PM

Quote:

Originally Posted by Riot (Post 1284639)
or even this.status = !this.status; ;)

Yup, that's my favorite :).

cbk1994 03-04-2007 09:22 PM

That just doesn't make much sense to me ... 1 - this.status seems so much cleaner

Twinny 03-05-2007 05:41 AM

Quote:

Originally Posted by Riot (Post 1284639)
or even this.status = !this.status; ;)

I prefer this. Just switches the boolean :)

napo_p2p 03-05-2007 05:50 AM

Quote:

Originally Posted by cbkbud (Post 1284648)
That just doesn't make much sense to me ... 1 - this.status seems so much cleaner

I like to think of this.status = !this.status as "toggling".

godofwarares 03-05-2007 04:58 PM

Quote:

Originally Posted by Angel_Light
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?

Try this:

PHP Code:

function onMouseWheel()
{
     if (!(
this.speed+>= 10) && !(this.speed-<= 1))
     {
          
this.speed +=- mousewheeldelta;
     }



Skyld 03-05-2007 05:59 PM

Quote:

Originally Posted by godofwarares (Post 1285073)
Try this:

PHP Code:

function onMouseWheel()
{
     if (!(
this.speed+>= 10) && !(this.speed-<= 1))
     {
          
this.speed +=- mousewheeldelta;
     }



+=-?

Kristi 03-05-2007 06:52 PM

Quote:

Originally Posted by Riot (Post 1284639)
or even this.status = !this.status; ;)

That is my preference too, however, I felt like having fun with math, as you can see from the overall code :D

godofwarares 03-05-2007 07:11 PM

Quote:

Originally Posted by Skyld
+=-?

Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.

Skyld 03-05-2007 07:17 PM

Quote:

Originally Posted by godofwarares (Post 1285116)
Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.

It's not an operator; it's doing what it says:
PHP Code:

temp.foo += -temp.bar

i.e.
PHP Code:

temp.foo 0;
temp.foo +=- 3

... equals -3.
PHP Code:

temp.foo 0;
temp.foo +=- -3

... equals 3.
PHP Code:

temp.foo 0;
temp.foo -=+ 3

... equals -3.
PHP Code:

temp.foo 0;
temp.foo -=+ -3

... equals 3.

Kristi 03-05-2007 07:39 PM

Quote:

Originally Posted by godofwarares (Post 1285116)
Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.

Gramatically speaking, what you just said would be adding the absolute value, because subtracting a number when it is negative is like adding its positive, and actually, that is NOT what it is doing, its simply adding the negative of a variable.

In this case, this.speed +=- mousewheeldelta is better written as
this.speed -= mousewheeldelta
:D

godofwarares 03-06-2007 01:43 PM

Ugh i'm getting my operators screwed up -_-


All times are GMT +2. The time now is 04:23 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.