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

Structure HUD [HELP]


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-13-2011 , 18:42   Re: Structure HUD [HELP]
Reply With Quote #71

I would do something like this (you need to add the word "random" without the quotes to your maps.ini or mapcycle.txt).

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 ) && !equali(szText"random")) ) 
            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 if( 
equali(g_szVoteMapsiWinner ], "random") )
    {
        
iWinner randomg_iVoteMapCount );
        
client_printprint_chat "* %s has received %d vote%s so %s will be the next map!" g_szVoteMapsiWinner ] , iMostVotes , ( iMostVotes != ) ? "s" ""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;

__________________
fysiks is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-13-2011 , 20:10   Re: Structure HUD [HELP]
Reply With Quote #72

ty will try it, as well i thought that too, i asked and try it but couldnt this part wins me
PHP Code:
!equali(szText"random")) 
one more time ty
</span></span>
liryck is offline
Send a message via MSN to liryck
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-13-2011 , 20:16   Re: Structure HUD [HELP]
Reply With Quote #73

Let me know if you have any trouble with it.
__________________
fysiks is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-13-2011 , 21:42   Re: Structure HUD [HELP]
Reply With Quote #74

ty testing but what im afraid. look


* Random was selected randomly as next map..., so word random isnt a valid map so there is a chance that word random get selected for a changemap

maybe this could be a solution or u have something better?
PHP Code:
   else if ( equal(g_szVoteMapsiWinner],"Random") )
        {
            
iWinner randomg_iVoteMapCount );
        if ( 
equal(g_szVoteMapsiWinner],"Random") )
        {
            
iWinner+1;
            
client_printprint_chat "* %s was selected randomly as next map... " g_szVoteMapsiWinner ] );
        }
        } 
liryck is offline
Send a message via MSN to liryck
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-13-2011 , 21:55   Re: Structure HUD [HELP]
Reply With Quote #75

I see it now.

A quick "work-around" would be to only put "Random" at the top of the map file and then do:

PHP Code:
    else if( equali(g_szVoteMapsiWinner ], "random") ) 
    { 
        
iWinner random_num(1g_iVoteMapCount-); 
        
client_printprint_chat "* %s has received %d vote%s so %s will be the next map!" g_szVoteMapsiWinner ] , iMostVotes , ( iMostVotes != ) ? "s" ""g_szVoteMapsiWinner ] ); 
    } 
There are other ways around it using a loop but I'd rather avoid that. If you don't want "Random" at the top of the list then it would probably be better to not go with my idea and do it a different way.
__________________
fysiks is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 06-13-2011 , 22:06   Re: Structure HUD [HELP]
Reply With Quote #76

Quote:
Originally Posted by fysiks View Post
I see it now.

A quick "work-around" would be to only put "Random" at the top of the map file and then do:

PHP Code:
    else if( equali(g_szVoteMapsiWinner ], "random") ) 
    { 
        
iWinner random_num(1g_iVoteMapCount-); 
        
client_printprint_chat "* %s has received %d vote%s so %s will be the next map!" g_szVoteMapsiWinner ] , iMostVotes , ( iMostVotes != ) ? "s" ""g_szVoteMapsiWinner ] ); 
    } 
There are other ways around it using a loop but I'd rather avoid that. If you don't want "Random" at the top of the list then it would probably be better to not go with my idea and do it a different way.
ty testing and seems to work perfectly, with my idea it doesnt and not it doesnt matter if random is at top.
liryck is offline
Send a message via MSN to liryck
Old 11-10-2011, 14:03
jar_09
This message has been deleted by jar_09.
jar_09
Senior Member
Join Date: Feb 2011
Old 11-10-2011 , 14:06   Re: Structure HUD [HELP]
Reply With Quote #77

Quote:
Originally Posted by fysiks View Post
I would do something like this (you need to add the word "random" without the quotes to your maps.ini or mapcycle.txt).

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 ) && !equali(szText"random")) ) 
            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 if( 
equali(g_szVoteMapsiWinner ], "random") )
    {
        
iWinner randomg_iVoteMapCount );
        
client_printprint_chat "* %s has received %d vote%s so %s will be the next map!" g_szVoteMapsiWinner ] , iMostVotes , ( iMostVotes != ) ? "s" ""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;

Hi all., As you may remove the part of changing the random map if no votes. Well what I want is that if nobody votes for any map .. mantega is the same map where it is, is the only thing I want. If you could help me, thanks.

(Sorry for my bad English).

Last edited by jar_09; 11-10-2011 at 14:20.
jar_09 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-10-2011 , 22:36   Re: Structure HUD [HELP]
Reply With Quote #78

Quote:
Originally Posted by jar_09 View Post
... my bad English).
Yes, you are correct. I don't know what you want.
__________________
fysiks is offline
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 11-11-2011 , 07:14   Re: Structure HUD [HELP]
Reply With Quote #79

Quote:
Originally Posted by fysiks View Post
Yes, you are correct. I don't know what you want.
He doesn't want to select a random map, but extend it for 15 mins.

i talk their language.
XINLEI is offline
jar_09
Senior Member
Join Date: Feb 2011
Old 11-11-2011 , 09:56   Re: Structure HUD [HELP]
Reply With Quote #80

Quote:
Originally Posted by fysiks View Post
Yes, you are correct. I don't know what you want.
What I want is that if there is no map votes, this is extended by 15 minutes or leave the same map.

and remove or change this part:

PHP Code:
if ( iWinner == -
    { 
        
iWinner randomg_iVoteMapCount ); 
        
client_printprint_chat "* No votes were made so %s was selected randomly as next map." g_szVoteMapsiWinner ] ); 
    } 
for something like this:

PHP Code:
if ( iWinner == -)
{
    
client_printprint_chat "* No votes were made so the current map will stay." );
    return;

but it gives me problems, I can help
Attached Thumbnails
Click image for larger version

Name:	cs1Dibujo.JPG
Views:	95
Size:	33.8 KB
ID:	95068  

Last edited by jar_09; 11-11-2011 at 10:00.
jar_09 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 13:50.


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