Raised This Month: $ Target: $400
 0% 

Voting menu won't display.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-20-2011 , 10:28   Re: Voting menu won't display.
Reply With Quote #1

1. Recursive task loop from getmaps() and StartVote()
2. Changed getmaps() to be direct call to have maps ready for vote
3. Chooses 4 maps while maps are available to be chosen
4. Only add items to the menu that exist
5. Stop loop if maps list is completely filled
6. First loop reads to end of file, second loop would give no results to add to maps list
7. Remove new line character at end of line
8. Only add map if it exists
9. Close file after using it
PHP Code:
public StartVote()
{
    if (
didgetmap == 0)
    {
        
// #1, #2
        
getmaps()
    }
    new 
rnd
    
    
// #3
    
while (donemaps != && mapscounter 0)
    {
        
rnd random(mapscounter)
        
        
copy(mapschosen[donemaps++], 19mapsavailable[rnd])
        
        
mapsavailable[rnd] = mapsavailable[--mapscounter]
    }        
    
    
gVoteMenu menu_create("\rChange map?""votemap");
    
    
// #4
    
new num[11]
    for(new 
0donemapsi++)
    {
        
num_to_str(inum10)
        
menu_additem(gVoteMenumapschosen[i], num0)
    }
    
menu_additem(gVoteMenu"\nExtend current map""4"0)
    
    new 
players[32], pnumtempid;
    
    
get_players(playerspnum"ch");
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
client_print(tempidprint_chat"%s Please vote for the map you'd like to play in."PREFIX)
        
menu_display(tempidgVoteMenu);
    }
    
    
set_task(10.0"EndVote"); 
    return 
PLUGIN_HANDLED;
}

public 
getmaps()
{
    
get_configsdir(maps_ini_file63);
    
format(maps_ini_file63"%s/maps.ini"maps_ini_file);
    
    new 
mapsfile fopen(maps_ini_file"r")
    new 
linefortest[50]
    
    
// #5, #6
    
while (mapscounter sizeof(mapsavailable) && !feof(mapsfile))
    {
        
fgets(mapsfilelinefortest49)
        
trim(linefortest// #7
        
        // #8
        
if (is_map_valid(linefortest))
        {
            
copy(mapsavailable[mapscounter++], 24linefortest)
        }
    }
    
    
// #9
    
fclose(mapsfile)
    
    
didgetmap++
    
// #1

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:51.


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