Author Topic: Does every client have a number?  (Read 2753 times)

How would you get a random hex number?

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


D: This doesn't work
Code: [Select]
%client.textColor = getRandom(000000, FFFFFF);
messageClient(%client,'',"the color is " @ %client.textColor);
This says "the color is 0" every time?

D: This doesn't work
Code: [Select]
%client.textColor = getRandom(000000, FFFFFF);
messageClient(%client,'',"the color is " @ %client.textColor);
This says "the color is 0" every time?

I dont think you can get random hex value that way.
Code: [Select]
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);
}
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.
« Last Edit: September 06, 2010, 03:53:06 PM by DYLANzzz »

Broken code. Recheck it.

%rand = getrandom...
switch(%blah)
default:  %dig=%blah;

I dont think you can get random hex value that way.
Code: [Select]
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);
}
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.
Thanks!
Broken code. Recheck it.

%rand = getrandom...
switch(%blah)
default:  %dig=%blah;
I thought it looked a little odd. Thanks to you too.

My mod beta worked! Thanks guys!

A friend said that %a is the client

Actually no, a friend said that %a was the index of that player on the NPL_List (playerlist).

Actually no, a friend said that %a was the index of that player on the NPL_List (playerlist).
Ho ho ho, an index you say? :D That may come in handy.