IMO Random works just fine. I think your main problem is that these:
if (iRand = 0)
should be:
if (iRand == 0)
If you want to see the randomness this is how I tested it. I took a part of what you had there and stuck it in a while loop to run 100 times. You will see that you get a pretty even mix. Here's the script:
void main()
{
int iLoops = 100;
int iGuard1;
int iGuard2;
int iGuard3;
int iGuard4;
string sGuard;
while (iLoops >0)
{
int iRand = Random(4);
if (iRand == 0)
{
sGuard = "amarioutcast001";
iGuard1++;
}
if (iRand == 1)
{
sGuard = "amarioutcast";
iGuard2++;
}
if (iRand == 2)
{
sGuard = "arakirirebel";
iGuard3++;
}
if (iRand == 3)
{
sGuard = "dhazaarioutcast";
iGuard4++;
}
iLoops--;
}
string sGuard1 = IntToString(iGuard1);
string sGuard2 = IntToString(iGuard2);
string sGuard3 = IntToString(iGuard3);
string sGuard4 = IntToString(iGuard4);
//sRand = IntToString(iRand);
//SendMessageToPC(GetEnteringObject(), "iRand is " + sRand);
SendMessageToPC(GetEnteringObject(), "Guard1 =" + sGuard1 +
"\\\\\\\\nGuard2 =" + sGuard2 +
"\\\\\\\\nGuard3 =" + sGuard3 +
"\\\\\\\\nGuard4 =" + sGuard4);
}
Hope this helps. Good luck.
EDIT: Please note that for some reason when you put a "\\" in a post here it adds three more to it. There should only be one in front of the "n"s where it says "nGuard2", "nGuard3" and "nGuard4". Not sure why this happens but it can be very problematic to some scripts if people don't catch it.
Modifié par GhostOfGod, 28 juillet 2010 - 06:44 .