AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Vote Menu Not Appearing (https://forums.alliedmods.net/showthread.php?t=86875)

DIGI- 03-03-2009 18:51

Vote Menu Not Appearing
 
Okay, I got this pug mod going but the vote menu wont appear when all players ready up to change the map, so i have a maps.ini but it still won't show the votemap menu

Here is the code
Code:

new filename[64]
get_configsdir( filename, 63 )
format( filename, 63, "%s/maps.ini", filename )
load_settings(filename)

load_settings(filename[]) {
    if (!file_exists(filename)) return 0
    new text[256], szDesc[48]
    new a , pos = 0
    while(map_count < MAX_MAPS && read_file(filename,pos++,text,255,a))
    {
        if(text[0]==';') continue
        if(parse(text,map_name[map_count],31,szDesc,47) < 2 ) continue
        if(!is_map_valid(map_name[map_count])) continue
        if(strlen(szDesc) > 31 )
        {
            copy(map_desc[map_count],28, szDesc )
            map_desc[map_count][28] = map_desc[map_count][29] = map_desc[map_count][30] = '.'
            map_desc[map_count][31] = 0
        }
        else copy(map_desc[map_count],31, szDesc )
        map_count++
    }
    return 1
}

public vote_map() {
    if(!map_count) {
        set_task(0.5,"vote_teams")
        return PLUGIN_HANDLED
    }
    new Float:votetime = get_cvar_float("pug_vote_time") + 10.0
    set_cvar_float("pug_last_voting", get_gametime() + votetime)
    //client_print(0,print_chat,votemap_started)
    showsay(0,votemap_started)
    for(new i=0; i<=map_count; ++i) {
        map_votecount[i]=0
    }
    for(new id=1; id<=maxplayers; ++id) {
        vote_map_menu(id,map_menuposition[id]=0)
    }
    set_task(votetime,"check_mapvotes",task_mapvote)
    return PLUGIN_HANDLED
}

public vote_map_menu(id,pos) {
    if(pos < 0) return
    new menuBody[1024], b = 0, start= pos * 7
    if(start >= map_count) start=pos=map_menuposition[id]=0
    new len = format(menuBody,1023,"\yChoose a map:^n^n")
    new end = start + 7, keys = (1<<9)
    if(end > map_count) end=map_count
    for(new a = start; a < end; ++a) {
        keys |= (1<<b)
        len += format(menuBody[len],1023-len,"\y%d.\w %s^n",++b,map_desc[a])
    }
    if(end != map_count) {
        len += format(menuBody[len],1023-len,"^n\y9.\w More^n\y0.\w %s", pos? "Back":"Exit")
        keys |= (1<<8)
    } else {
        len += format(menuBody[len],1023-len,"^n\y0.\w %s", pos ? "Back" : "Exit")
    }
    show_menu(id,keys,menuBody,-1)
}

public count_mapvotes(id,key) {
    switch(key) {
        case 8: vote_map_menu(id,++map_menuposition[id])
        case 9: vote_map_menu(id,--map_menuposition[id])
        default: {
            new mapnumber = (map_menuposition[id]*7) + (key)
            ++map_votecount[mapnumber]
            if(get_cvar_num("pug_vote_answers")==1) {
                new player_name[32]
                get_user_name(id,player_name,31)
                if(map_votecount[mapnumber] > 1) client_print(0,print_chat,"%s voted for %s (currently %i votes)",player_name,map_name[mapnumber],map_votecount[mapnumber])
                else client_print(0,print_chat,"%s voted for %s (currently %i vote)",player_name,map_name[mapnumber],map_votecount[mapnumber])
            }
        }
    }
    return PLUGIN_HANDLED
}

public check_mapvotes() {
    new num, ppl[32], a=0, ms[300]
    get_players(ppl,num,"c")
    if(num==0) num = 1
    for(new i = 0; i <=map_count; ++i) {
        if(map_votecount[a] < map_votecount[i]) {
            a=i
        }
    }
    new currentMap[32]
    get_mapname(currentMap,31)
    if(!equali(map_name[a],currentMap)) {
        format(ms,299,mapvote_succes,map_name[a])
        showsay(0,ms)
        //client_print(0,print_chat,mapvote_succes,map_name[a])
        set_cvar_num("pug_mapchange",1)
              message_begin(MSG_ALL, SVC_INTERMISSION)
              message_end()
              set_task(2.0,"delayedChange",0,map_name[a],strlen(map_name[a]) + 1)
        return PLUGIN_HANDLED
    }
    format(ms,299,votemap_failed,currentMap)
    //client_print(0,print_chat,votemap_failed,currentMap)
    set_task(0.5,"vote_teams")
    return PLUGIN_HANDLED
}

public delayedChange(mapname[]) {
    server_cmd("changelevel %s",mapname)
}


danielkza 03-03-2009 18:53

Re: Keypad Admin And Vote Team Problem =/
 
I present you the [code] tags:
http://forums.alliedmods.net/misc.php?do=bbcode#code


All times are GMT -4. The time now is 17:01.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.