Raised This Month: $51 Target: $400
 12% 

Structure HUD [HELP]


Post New Thread Reply   
 
Thread Tools Display Modes
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 04-12-2010 , 18:51   Re: Structure HUD [HELP]
Reply With Quote #21

Yes that's what i want, my code is almost ready only lack fix what I said, and to show how votes leads the map
flamin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2010 , 19:01   Re: Structure HUD [HELP]
Reply With Quote #22

How do you want it to select maps to vote
__________________
Bugsy is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 04-12-2010 , 19:14   Re: Structure HUD [HELP]
Reply With Quote #23

Here you puts the code complete vote on maps:

PHP Code:
public votemap_start()
{
    if(
pug_voting) { set_task(get_pcvar_float(pug_cvar_vote_time),"votemap_start",100 pug_votemap_menu); return; }

    
pug_voting 1;
    
arrayset(pug_voted,0,33)

    
arrayset(pug_votemap_votes,0,pug_votemap_count)
    
pug_display_menu_all(pug_votemap_menu)

    
client_print(0,print_chat,"",pug_headerLANG_PLAYER"PUG_VOTE_START""PUG map");
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_START""PUG map");
    
set_task(get_pcvar_float(pug_cvar_vote_time),"votemap_end",100 pug_votemap_menu)
}

public 
votemap_end()
{
    
pug_cancel_menu()

    
pug_voting 0;
    
remove_task 100 pug_votemap_menu )

    if(
votemap_count()) voteteam_start();
}

public 
votemap_handle(idmenuitemFloat:hold_time)
{
    if( 
item ) return PLUGIN_CONTINUE;
 
    static 
accesscallback
    
static cmd[1056], cmdname[1056]

    
cmdname[0] = '^0'
    
cmd[0] = '^0'
 
    
menu_item_getinfo(menuitemaccesscmd,1055,cmdname,1055callback);
    
pug_votemap_votes[str_to_num(cmd)]++;
        
    
set_hudmessage(025500.760.1000.0,30.00.00.03)
    
show_hudmessage(0,"Map votes:")

    
set_hudmessage(2552552250.760.1300.0,30.00.00.04)
    
show_hudmessage(0,cmdname,1055)

    
client_print(0,print_chat,"",pug_headerLANG_PLAYER"PUG_VOTED_FOR"cmdname);
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTED_FOR"cmdname);

    
pug_voted[id] = 1;
    if(
pug_should_stopvote() ) votemap_end()
 
    return 
PLUGIN_HANDLED;
}

public 
votemap_count()
{
    new 
winnerwinner_votesvotes

    
for(new 0pug_votemap_count; ++i)
    {
        
votes pug_votemap_votes[i]
        if(
votes winner_votes) { winner iwinner_votes votes; }
        else if(
votes == winner_votes) if(random_num(0,1)) { winner iwinner_votes votes; }
    }

    if(
pug_votemap_votes[winner] == 0)
    {
        
message_begin(MSG_ALLSVC_INTERMISSION)
        
message_end()

        new 
iMap random(pug_votemap_count)
            
set_task(3.0,"pug_votemap_change2"iMap);
            
client_printprint_chat "[ESVE Pug] %s has been chosen randomly." pug_votemap_nameiMap ] );  
        return 
PLUGIN_CONTINUE
    
}

    
client_print(0,print_chat,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_WIN"pug_votemap_name[winner]);
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_WIN"pug_votemap_name[winner]);

    
pug_voting 0;
    
votemap_noswitch 1;
    
set_pcvar_num(pug_cvar_votemap_e,0)

    
message_begin(MSG_ALLSVC_INTERMISSION)
    
message_end()

    
set_task(3.0,"pug_votemap_change",winner)
    return 
PLUGIN_CONTINUE
}

public 
pug_votemap_change2iMap )
{
    
server_cmd"changelevel %s" pug_votemap_nameiMap ] );
}  

public 
pug_votemap_change(winner)
{
    
server_cmd("changelevel %s",pug_votemap_name[winner]);

If you fixed the hud must be in votemap handle that is the counter of maps
flamin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2010 , 19:56   Re: Structure HUD [HELP]
Reply With Quote #24

Let me know if you have any problems. I didn't thoroughly test because I do not have a server with real players to test with.

Edit: Added color to HUD, voting no longer ends once all players have voted, and HUD only shows maps that have been voted.

Edit2: Made only heading green, made it so vote cannot start if a vote already exists, added <No Votes> on HUD if there are not yet any votes.

PHP Code:
#include <amxmodx>
#include <amxmisc>

const VoteMaps 10;    //Number of maps in each vote
const VoteTime 30;    //Number of seconds to allow people to vote
const TaskMapHUD 1092;    //Task-ID for map vote HUD

enum _:MapInfo
{
    
MapIndex,
    
MapVotes
}

new 
g_iVoteMenu;
new 
g_iVoteMapCount;
new 
g_iMapVotesVoteMaps ][ MapInfo ];
new 
g_szVoteMapsVoteMaps ][ 33 ];
new 
g_iNumPlayers;
new 
g_iVoteCount;
new 
g_iSyncHUDObj];

public 
plugin_init() 
{
    
register_plugin"Vote Map" "0.1" "bugsy" );
    
    
g_iSyncHUDObj] = CreateHudSyncObj();
    
g_iSyncHUDObj] = CreateHudSyncObj();
    
    
register_concmd"say votemap" "VoteMap" );
}

public 
VoteMapid )
{
    if ( 
task_existsTaskMapHUD ) )
    {
        
client_printid print_chat "* There is already a vote taking place so cannot start vote." );
        return 
PLUGIN_HANDLED;
    }
    
    new 
szFile64 ] , iPlayers32 ];
    
    
get_playersiPlayers g_iNumPlayers );
    
    if ( !
g_iNumPlayers )
        return 
PLUGIN_HANDLED;
        
    
g_iVoteCount 0;
    
    
g_iVoteMenu menu_create"Vote for Map" "VoteHandler" );
    
    
copyszFileget_configsdirszFile charsmaxszFile ) ) ] , charsmaxszFile ) , "/maps.ini" );
    
    if( 
file_existsszFile ) ) 
        
LoadMapFileszFile );
        
    if ( !
g_iVoteMapCount )
    {
        
copyszFile charsmaxszFile ) , "mapcycle.txt" ); 
        
LoadMapFileszFile );
    }
    
    
menu_setpropg_iVoteMenu MPROP_EXIT MEXIT_ALL );
    
    for ( new 
g_iNumPlayers i++ )
        
menu_displayiPlayers] , g_iVoteMenu );
    
    
UpdateHUD();
    
set_task1.0 "UpdateHUD" TaskMapHUD "a" VoteTime );
    
    return 
PLUGIN_HANDLED;
}

LoadMapFile( const szFile[] )
{
    new 
szText256 ] , iFile;
    
    
iFile fopenszFile "rt" );
    
    
g_iVoteMapCount 0;
    
    while( ( 
g_iVoteMapCount VoteMaps ) && !feofiFile ) && fgetsiFile szText charsmaxszText ) ) )
    {
        
trimszText );
        
        if( ( ( 
szText] == '^0' ) || ( szText] == '/' ) || ( szText] == ';' ) ) || !is_map_validszText ) ) 
            continue;

        
copyg_szVoteMapsg_iVoteMapCount ] , charsmaxg_szVoteMaps[] ) , szText );

        
g_iMapVotesg_iVoteMapCount ][ MapIndex ] = g_iVoteMapCount++;

        
menu_additemg_iVoteMenu szText )
    }
    
    
fcloseiFile );
}

public 
VoteHandlerid menu item )
{
    if ( 
item == MENU_EXIT )
        return 
PLUGIN_HANDLED;
    
    static 
szName33 ];
    
    
get_user_nameid szName charsmaxszName ) );
    
    
g_iMapVotesitem ][ MapVotes ]++;
    
g_iVoteCount++;
    
    
client_printprint_chat "* %s voted for %s" szName g_szVoteMapsitem ] );
    
    return 
PLUGIN_HANDLED;
}

public 
UpdateHUD()
{    
    static 
iDisplayCount = -1;
    
    if ( ++
iDisplayCount == VoteTime )
    {
        
SelectMap();
    }
    else
    {
        static 
szHUDVoteMaps 40 ] , iPos iPos2;
        static 
g_iMapVotesTempVoteMaps ][ MapInfo ];
        
        
iPos copyszHUD charsmaxszHUD ) , "Map Votes:" );
        
        
szHUDiPos++ ] = EOS;
        
iPos2 iPos;
        
        if ( 
g_iVoteCount )
        {
            
g_iMapVotesTemp g_iMapVotes;
            
SortCustom2Dg_iMapVotesTemp VoteMaps "SortMaps" );
        
            for ( new 
g_iVoteMapCount i++ )
                if ( 
g_iMapVotesTemp][ MapVotes ] )
                    
iPos += formatexszHUDiPos ] , charsmaxszHUD ) - iPos "%s - %d vote%s^n" g_szVoteMapsg_iMapVotesTemp][ MapIndex ] ] ,  g_iMapVotesTemp][ MapVotes ] , ( g_iMapVotesTemp][ MapVotes ] != ) ? "s" "" );
        }
        else
        {
            
iPos += copyszHUDiPos ] , charsmaxszHUD ) - iPos "<No Votes>^n" );
        }
        
        
iPos += formatexszHUDiPos ] , charsmaxszHUD ) - iPos "^n%d second%s remaining" VoteTime iDisplayCount , ( VoteTime iDisplayCount ) != "s" "" );
        
        
set_hudmessage255 0.58 0.12 6.0 1.1 );
        
ShowSyncHudMsgg_iSyncHUDObj] , szHUD );
        
        
set_hudmessage255 255 255 0.58 0.20 6.0 1.1 );
        
ShowSyncHudMsgg_iSyncHUDObj] , szHUDiPos2 ] );
    }
}

SelectMap()
{
    new 
iMostVotes iWinner = -1;

    
menu_destroyg_iVoteMenu );
    
    
message_beginMSG_ALL SVC_INTERMISSION );
    
message_end();
    
    for ( new 
g_iVoteMapCount i++ )
    {
        if ( 
g_iMapVotes][ MapVotes ] > iMostVotes )
        {
            
iMostVotes g_iMapVotes][ MapVotes ];
            
iWinner i;
        }
    }
    
    if ( 
iWinner == -)
    {
        
iWinner randomg_iVoteMapCount );
        
client_printprint_chat "* No votes were made so %s was selected randomly as next map." g_szVoteMapsiWinner ] );
    }
    else
    {
        
client_printprint_chat "* %s has received %d vote%s and will be the next map!" g_szVoteMapsiWinner ] , iMostVotes , ( iMostVotes != ) ? "s" "" );
    }

    
set_task3.0 "ChangeMap" iWinner );
}

public 
ChangeMapiMapIndex )
{
    
server_cmd"changelevel %s" g_szVoteMapsiMapIndex ] );
}
    
public 
SortMapselem1[] , elem2[] )
{
    if( 
elem1] > elem2] ) 
        return -
1;
    else if( 
elem1] < elem2] )
        return 
1;
    
    return 
0;

__________________

Last edited by Bugsy; 04-13-2010 at 21:34.
Bugsy is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 04-12-2010 , 20:40   Re: Structure HUD [HELP]
Reply With Quote #25

PHP Code:
public pug_votemap_menu;
public 
pug_cvar_vote_time;
public 
pug_cvar_votemap
public pug_cvar_votemap_e

new votemap_noswitch
public pug_voting 0;

public 
plugin_init()
{
   
pug_cvar_vote_time register_cvar("pug_vote_delay","20")

    
pug_cvar_votemap register_cvar("pug_votemap","1")
    
pug_cvar_votemap_e register_cvar("pug_votemap_enabled","1")

   
register_pug_admincmd("votemap","cmd_votemap",PUG_CMD_LVL,"MAPS")

    
pug_votemap_menu menu_create("ESVE Pug Map:","votemap_handle");
    
menu_setprop(pug_votemap_menu,MPROP_EXIT,MEXIT_NEVER)
}

public 
plugin_cfg() try_load_votemap_menu()

CREATE_GEN_FORW_ID(firsthalf_forward)

public 
pug_firsthalf(GEN_FORW_ID(forward_id))
{
    
firsthalf_forward forward_id

    
if( get_pcvar_num(pug_cvar_votemap_e) && get_pcvar_num(pug_cvar_votemap) ) votemap_start();
    else 
voteteam_start();

    return 
PLUGIN_HANDLED;
}

public 
pug_finished()
{
    if(!
votemap_noswitchset_pcvar_num(pug_cvar_votemap_e,1)
}

#define MAX_MAPS 20

new pug_votemap_votes[MAX_MAPS]
new 
pug_votemap_name[MAX_MAPS][32]
new 
pug_votemap_count;

public 
try_load_votemap_menu()
{
    
// Rukia: Get our maps.ini
    
static filename[64]
    
get_configsdirfilename63 )
    
formatfilename63"%s/maps.ini"filename )

    
// Rukia: Otherwise, just use mapcycle
    
if(file_exists(filename)) 
    {
        
load_votemap_menu(filename)
        if(
pug_votemap_count != 0) return;
    }

    
copy(filename,63,"mapcycle.txt")
    
load_votemap_menu(filename)
}

public 
load_votemap_menu(filename[])
{
    new 
file fopen(filename,"rb")

    static 
text[256], szDesc[48], num[10]
    while( (
pug_votemap_count MAX_MAPS) && !feof(file) && fgets(file,text,255) )
    {
        
// Rukia: Take out common comment conventions
        
if(text[0]==';') continue
        if( (
text[0]=='/') && (text[1]=='/') ) continue

        
// Rukia: Remove the newline character
        
text[strlen(text)] = '^0'

        
// Rukia: Get the map name and description out of what we read
        
strbreak(text,pug_votemap_name[pug_votemap_count],31,szDesc,47)
        
// Rukia: If the map is invalid, skip it
        
if( !is_map_validpug_votemap_name[pug_votemap_count] ) ) continue;

        
// Rukia: If there is no description (such as if we use mapcycle) then just use the first part of the map name
        
if(szDesc[0] == '^0'strtok(pug_votemap_name[pug_votemap_count],szDesc,47,"",0,'.',1)
    
        
// Rukia: The map number will be our index
        
formatex(num,9,"%i",pug_votemap_count)

        
// Rukia: Add the item into the menu and move on
        
menu_additem(pug_votemap_menupug_votemap_name[pug_votemap_count],num )

        
pug_votemap_count++;
    }

    
fclose(file)
}

public 
cmd_votemap(id,level,cid)
{
    if (!
cmd_access(idlevelcid1) ) return pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED")
    
    
votemap_start()
    return 
PLUGIN_HANDLED;
}

public 
votemap_start()
{
    if(
pug_voting) { set_task(get_pcvar_float(pug_cvar_vote_time),"votemap_start",100 pug_votemap_menu); return; }

    
pug_voting 1;
    
arrayset(pug_voted,0,33)

    
arrayset(pug_votemap_votes,0,pug_votemap_count)
    
pug_display_menu_all(pug_votemap_menu)

    
client_print(0,print_chat,"",pug_headerLANG_PLAYER"PUG_VOTE_START""PUG map");
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_START""PUG map");
    
set_task(get_pcvar_float(pug_cvar_vote_time),"votemap_end",100 pug_votemap_menu)
}

public 
votemap_end()
{
    
pug_cancel_menu()

    
pug_voting 0;
    
remove_task 100 pug_votemap_menu )

    if(
votemap_count()) voteteam_start();
}

public 
votemap_handle(idmenuitem)
{
    if( 
item ) return PLUGIN_CONTINUE;
 
    static 
accesscallback
    
static cmd[3], name[32], cmdname[32]
 
    
menu_item_getinfo(menuitemaccesscmd,2,cmdname,31callback);
    
pug_votemap_votes[str_to_num(cmd)]++;

    
get_user_name(id,name,31)
        
    
client_print(0,print_chat,"",pug_headerLANG_PLAYER"PUG_VOTED_FOR"namecmdname);
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTED_FOR"namecmdname);

    
pug_voted[id] = 1;
    if(
pug_should_stopvote() ) votemap_end()
 
    return 
PLUGIN_HANDLED;
}

public 
votemap_count()
{
    new 
winnerwinner_votesvotes

    
for(new 0pug_votemap_count; ++i)
    {
        
votes pug_votemap_votes[i]
        if(
votes winner_votes) { winner iwinner_votes votes; }
        else if(
votes == winner_votes) if(random_num(0,1)) { winner iwinner_votes votes; }
    }

    if(
pug_votemap_votes[winner] == 0)
    {
        
message_begin(MSG_ALLSVC_INTERMISSION)
        
message_end()

        new 
iMap random(pug_votemap_count)
            
set_task(3.0,"pug_votemap_change2"iMap);
            
client_printprint_chat "[ESVE Pug] %s has been chosen randomly." pug_votemap_nameiMap ] );  
        return 
PLUGIN_CONTINUE
    
}

    
client_print(0,print_chat,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_WIN"pug_votemap_name[winner]);
    
console_print(0,"%s %L",pug_headerLANG_PLAYER"PUG_VOTE_WIN"pug_votemap_name[winner]);

    
pug_voting 0;
    
votemap_noswitch 1;
    
set_pcvar_num(pug_cvar_votemap_e,0)

    
message_begin(MSG_ALLSVC_INTERMISSION)
    
message_end()

    
set_task(3.0,"pug_votemap_change",winner)
    return 
PLUGIN_CONTINUE
}

public 
pug_votemap_change2iMap )
{
    
server_cmd"changelevel %s" pug_votemap_nameiMap ] );
}  

public 
pug_votemap_change(winner)
{
    
server_cmd("changelevel %s",pug_votemap_name[winner]);


Last edited by flamin; 04-14-2010 at 01:34.
flamin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2010 , 20:46   Re: Structure HUD [HELP]
Reply With Quote #26

Quote:
Originally Posted by flamin View Post
Your plugin shows only 7 maps and shows also in the hud, I want the maps appear on the hud when a player the select
Change this to the # maps you want voted.
#define MAX_MAPS 7

Quote:
Originally Posted by flamin View Post
The code called the maps.ini and also has a timer for the vote
My plugin tries first for maps.ini and if it doesnt exist or no maps found it goes for mapcycle.txt (exactly like in the code you posted above)

Quote:
Originally Posted by flamin View Post
The code is ongoing, after which begins the voting and the player chooses the map will appear in the hud with the votes that leads, No shows all the maps in the hud Nor does the remaining time, As i can implement its code in votemap_handle? But to work with what you have my code?
My plugin shows vote menu with maps and a HUD showing all maps along with the number of votes each has. Below the maps it has a timer for how many seconds remain in the vote. I provided exactly what is pictured with the exception of green color.

It also ends the voting and chooses a map once all players have voted. So if you are testing this on a server where you are the only player, the vote will end once you pick a map from the menu.
__________________

Last edited by Bugsy; 04-12-2010 at 20:48.
Bugsy is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 04-12-2010 , 22:05   Re: Structure HUD [HELP]
Reply With Quote #27

Good, tell how can implement in my code? As i can integrate in votemap handle and completed the plugin You can help me?
flamin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2010 , 22:11   Re: Structure HUD [HELP]
Reply With Quote #28

What does my code not do that you want it to?
__________________
Bugsy is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 04-12-2010 , 22:18   Re: Structure HUD [HELP]
Reply With Quote #29

You do not understanding... You can help implement in my code? And apology the discomfort
flamin is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 04-12-2010 , 22:44   Re: Structure HUD [HELP]
Reply With Quote #30

Quote:
Originally Posted by flamin View Post
You do not understanding... You can help implement in my code? And apology the discomfort
Why can't you use his code? It's better than 'yours'.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ 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 03:36.


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