Results 1 to 2 of 2

Thread: bf9 Scripting Homestead

  1. #1

    bf9 Scripting Homestead

    Hello, bf9 here! I have been practicing scripting for quite abit now and I'd like to share some of the basic scripts that I've created for fun. =]

    Here's the first one, it's a script that first generates a hex color code, then it converts it into rgb format before showing the color output with its respective hex color code and rgb value. It'd appreciated to have constructive comments to help me improve!

    PHP Code:
    //#CLIENTSIDE
    function onActionGrab() {
      
    temp.hexcolor genHex();
      
    this.chat temp.hexcolor;
      
    convertHexToRGB(temp.hexcolor);
      
    this.chat "Hex " temp.hexcolor " = RGB(" this.rgb ")";
      
    this.this.rgb[0]/255;
      
    this.this.rgb[1]/255;
      
    this.this.rgb[2]/255;
      
    setcoloreffect(this.r,this.g,this.b,1);
    }

    // Generate Hex Color Code
    function genHex() {
      
    temp.hexlist = {0123456789"A""B""C""D""E""F"};
      
    temp.hex = {000000};
      for (
    i=0i<5i++){
      
    temp.hex[i] = temp.hexlist[int(random(0,16))];
      }
      
    temp.hexcolor "#" temp.hex[0] @ temp.hex[1] @ temp.hex[2] @ temp.hex[3] @ temp.hex[4] @ temp.hex[5];
      return 
    temp.hexcolor;
    }

    // Convert Hex to RGB
    function convertHexToRGB(hexcolor) {
      
    temp.hexlist = {0123456789"A""B""C""D""E""F"};
      
    temp.hexr1 temp.hexlist.index(temp.hexcolor.substring(1,1));
      
    temp.hexr0 temp.hexlist.index(temp.hexcolor.substring(2,1));
      
    temp.hexg1 temp.hexlist.index(temp.hexcolor.substring(3,1));
      
    temp.hexg0 temp.hexlist.index(temp.hexcolor.substring(4,1));
      
    temp.hexb1 temp.hexlist.index(temp.hexcolor.substring(5,1));
      
    temp.hexb0 temp.hexlist.index(temp.hexcolor.substring(6,1));
      
    temp.int(temp.hexr1 16^1) + int(temp.hexr0 16^0);
      
    temp.int(temp.hexg1 16^1) + int(temp.hexg0 16^0);
      
    temp.int(temp.hexb1 16^1) + int(temp.hexb0 16^0);
      
    this.rgb = {temp.rtemp.gtemp.b};
      
    this.chat "R:" temp." G:" temp." B:" temp.b;
      return 
    this.rgb;
    }

    /*
    Quick Conversion Methodology - Hex to Decimal for "A8"
    1) Convert Hex Digit to Dec Value
       A = 10, 8 = 8
    2) Multiply x16^1 for the 1st Dec and x16^0 for the 2nd Dec
       10 x 16^1 = 160, 8 x16^0 = 8
    3) Add both of them to form the converted value
       160 + 8 = 168
    */ 

  2. #2
    yooo !

    I don't understand anything in scripting but hey, welcome back

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •