Blockland Forums > Modification Help
Does every client have a number?
<< < (4/5) > >>
Syntax:

--- Quote from: Reinforcements on September 06, 2010, 01:09:28 PM ---How would you get a random hex number?

--- End quote ---

You should use getRandom(%this,%that);
Reinforcements:

--- Quote from: Syntax on September 06, 2010, 01:13:41 PM ---You should use getRandom(%this,%that);

--- End quote ---
Ah, thanks! :D
Reinforcements:
D: This doesn't work

--- Code: ---%client.textColor = getRandom(000000, FFFFFF);
messageClient(%client,'',"the color is " @ %client.textColor);
--- End code ---
This says "the color is 0" every time?
DYLANzzz:

--- Quote from: Reinforcements on September 06, 2010, 02:49:59 PM ---D: This doesn't work

--- Code: ---%client.textColor = getRandom(000000, FFFFFF);
messageClient(%client,'',"the color is " @ %client.textColor);
--- End code ---
This says "the color is 0" every time?


--- End quote ---
I dont think you can get random hex value that way.

--- Code: ---function randomHex()
{
   for(%i=0; %i<6;%i++)
   {
      %rand = getRandom(0,15);
      switch(%rand)
      {
         case 10:
         %dig="A";

         case 11:
         %dig="B";

         case 12:
         %dig="C";

         case 13:
         %dig="D";

         case 14:
         %dig="E";

         case 15:
         %dig="F";

         default:
         %dig=%rand;
      }
      %hex=%hex@%dig;
   }
   return(%hex);
}
--- End code ---
You can call this fucntion I whipped up. Put it into your code. This would get a random number 0-15 (amount of choices a single hex digit could be) and if its 10-15 turns it into a letter.
It then combines it all into a single hex variable. Then it returns it.
Chrono:
Broken code. Recheck it.

%rand = getrandom...
switch(%blah)
default:  %dig=%blah;
Navigation
Message Index
Next page
Previous page

Go to full version