03.07.2011, 16:34
Just mark the maps you already selected
Another note:
You dont need to enter the size of constant arrays
pawn Код:
//
#define maxmapsshown 5
new
x = 0, //loop variable
rand = 0, //random variable
count = 0, //counts variable
selected = 0; //saves the selected maps
for( ; count != maxmapsshown ; ++count) { //loops till we got our 5 maps
rand = random(sizeof DMmapname - count); //gets an random value
for(x = 0; x != sizeof DMmapname; ++x) { //loops through all mapids
if(selected & (1 << x)) {
continue; //jumps over the selected
}
if(!rand--) { //adds the map if we found our randomized map
strcat(str, DMmapname[x], sizeof str); //adds the mapname to the string
strcat(str, "\n", sizeof str); //adds a newline - strcat is faster than format
selected |= (1 << x); //marks the map as selected
break; //stops the loop - we found our map
}
}
}
You dont need to enter the size of constant arrays
pawn Код:
#define maxmapsss sizeof(DMmapname)
stock const DMmapname[][] = {
"dmpalace",
"dm mall",
"dm factory",
"dm madness",
"dm docks",
"dm sf town",
"dm airport",
"dm evening",
"dm trapper",
"dm ur owned"
};