Can't find what I'm doing wrong!
#2

As far as I can see your code repeats calling the random function till it finds a number which hasn't be taken
The problem is if there is only one number left it will probably hang your server for serveral seconds till it randomize the last number

I will use here a static usedNumber variable, so you can remove your usednumbers array
pawn Код:
//
    if(time == 00 || time == 15 || time == 30 || time == 45) {
        static
            usedNumber
        ;
        if(drugpointcounter == 10) {
            drugpointcounter = 0;
            usedNumber = 0;
        }
        new rand = random(10 - drugpointcounter);

        while(usedNumber & (1 << rand)) {
            rand++;
        }
        usedNumber |= 1 << rand;

        MoveSmugglingPoint(rand);
        drugpointcounter++;
    }
Thats a pretty easy implantation but it should work
Reply


Messages In This Thread
Can't find what I'm doing wrong! - by jimdevil13 - 17.02.2013, 10:39
AW: Can't find what I'm doing wrong! - by Nero_3D - 17.02.2013, 11:48
Re: Can't find what I'm doing wrong! - by jimdevil13 - 17.02.2013, 11:59
AW: Can't find what I'm doing wrong! - by Nero_3D - 17.02.2013, 12:29

Forum Jump:


Users browsing this thread: 1 Guest(s)