vote next map
#4

Just mark the maps you already selected

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
            }
        }
    }
Another note:

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"
};
Reply


Messages In This Thread
vote next map - by swieberdevos - 03.07.2011, 16:04
Re: vote next map - by SpiderWalk - 03.07.2011, 16:15
Re: vote next map - by swieberdevos - 03.07.2011, 16:19
AW: vote next map - by Nero_3D - 03.07.2011, 16:34
[No subject] - by swieberdevos - 03.07.2011, 16:42

Forum Jump:


Users browsing this thread: 2 Guest(s)