AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] votemaps (https://forums.alliedmods.net/showthread.php?t=237806)

Snitch 03-29-2014 18:05

[help] votemaps
 
It will be built on the server time [mod]
timeleft.amxx?

And how can I do: new const Change
To 1?
Without 3 new const = all maps in new const 1 and shares will randomly

At the end votemap it sets the nextmap server and deliver the next Round.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >

new bool:Voted33 ];

new 
g_szRoundVotemap;

new 
g_szKind], TimerEndVote 0;

new const 
Change[][] = { 
"jb_funny_live",
"jail_crewkule",
"jb_flyhigh",
"jail_pyramid"
}
new const 
Change2[][] = { 
"jail_crewkule2",
"jail_aj_bananamuffin_nd",
"jail_rehab_b2",
"jail_xmf"
}
new const 
Change3[][] = { 
"jail_armageddon",
"jail_renner_b6",
"jail_rats"
}
public 
plugin_init() {
register_plugin("Simple VoteMap""1.0""AMXX")

register_event"HLTV""NewRound""a""1=0""2=0" )
}


public 
NewRound()
{
g_szRoundVotemap++;

ColorChat0"there will be votemap in: %i Rounds"g_szRoundVotemap);


if(
g_szRoundVotemap == 3)
set_task1.0"ActionSpecial" );
}
public 
ActionSpecial()
{

for( new 
1<= get_maxplayers(); i++ ){

Voted] = false;
show_menui0"^n");
}

g_szKind] = 0
g_szKind
] = 0
g_szKind
] = 0
g_szKind
] = 
switch(random_num(0,3) ){

case 
0:EndVote 1
case 1:EndVote 2
case 2:EndVote 3
case 3:EndVote 4
}

for( new 
iget_maxplayers(); <= ji++ ){

if( !
is_user_alive) || !is_user_connected) )
continue;

Timer 17
ChangeMaps
(i)
}

client_cmd(0"spk ^"get red(e80ninety(s45to check(e20) use bay(s18mass(e42cap(s50)^""
set_task17.0"checkvotesd",1700 ); 
countdown2();

return 
1;
}


public 
ChangeMaps(client)
{

static 
szMap[128]; 
new 
st];
formatex(szMapcharsmax(szMap), "\r[AMXX]\w Choose Map:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" "\rNot Voted"Timer);
new 
menu menu_create(szMap"handlerdddd");
switch(
EndVote)
{
case 
1:

for( new 
ksizeof Changek++ )
{
num_to_strkst);
formatexszMapcharsmaxszMap ), "\w%s \d[\y%i Votes\d]"Change], g_szKind]);
menu_additemmenuszMapst );
}
}
case 
2:
{
for( new 
ksizeof Change2k++ )
{
num_to_strkst);
formatexszMapcharsmaxszMap ), "\w%s \d[\y%i Votes\d]"Change2], g_szKind]);
menu_additemmenuszMap,st );
}
}
case 
3:
{
for( new 
ksizeof Change3k++ )
{
num_to_strkst);
formatexszMapcharsmaxszMap ), "\w%s \d[\y%i Votes\d]"Change3], g_szKind]);
menu_additemmenuszMap,st );


}

}
menu_setpropmenuMPROP_EXITMEXIT_NEVER );
menu_display(client,menu);

}

public 
checkvotesd()

new 
Winner 0;
switch(
EndVote)
{
case 
1:

for( new 
0sizeof Changei++ )
{
if( 
g_szKindWinner ] < g_szKind] )
{
Winner i;
}
}
}
case 
2:
{
for( new 
0sizeof Change2i++ )
{
if( 
g_szKindWinner ] < g_szKind] )
{
Winner i;
}
}
}
case 
3:
{
for( new 
0sizeof Change3i++ )
{
if( 
g_szKindWinner ] < g_szKind] )
{
Winner i;
}
}
}

}
for( new 
1<= get_maxplayers(); i++ )
{
Voted] = false;
show_menui0"^n");
}
switch(
EndVote)
{
case 
1:

ColorChat0"%s ^4won ^1the vote with ^3%i ^1"ChangeWinner ], g_szKindWinner ] );
for( new 
0sizeof Changei++ )
{
g_szKind] = 0
}
}
case 
2:
{
ColorChat0"%s ^3won ^1the vote with ^3%i ^1"Change2Winner ], g_szKindWinner ] );
for( new 
0sizeof Change2i++ )
{
g_szKind] = 0
}

case 
3:
{
ColorChat0"%s ^3won ^1the vote with ^3%i ^1"Change3Winner ], g_szKindWinner ] );
for( new 
0sizeof Change3i++ )
{
g_szKind] = 0


}
}
}

public 
handlerddddclientmenuitem )
{
if( 
Votedclient ] == true )

ChangeMapsclient);

return 
1;
}

new 
szName32 ];

get_user_nameclientszName32 );
switch(
EndVote)
{
case 
1:

ColorChat0"^3%s^1 has^4 voted ^1for^4 %s"szNameChangeitem ] )

}
case 
2:
{
ColorChat0"^3%s^1 has^4 voted ^1for^4 %s"szNameChange2item ] )
}
}
g_szKinditem ]++;

Votedclient ] = true;

ChangeMaps(client);

return 
1;
}

public 
countdown2()
{
if(
Timer <= 0)
{
remove_task(2000)
}
else
{
Timer--
set_task(1.0,"countdown2");
for( new 
1<= get_maxplayers(); i++ )
{
if( !
is_user_alive) || !is_user_connected) )
continue;
show_menui0"^n");
ChangeMaps(i)
}

}
return 
PLUGIN_HANDLED
}

stock ColorChat(const id, const string[], {FloatSqlResul,_}:...) {
new 
msg[191], players[32], count 1

static len
len 
formatex(msgcharsmax(msg), "^1[^3 AMXX^1] ")
vformat(msg[len], charsmax(msg) - lenstring3)

if(
idplayers[0] = id
else get_players(players,count,"ch")

for (new 
0counti++)
{
if(
is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"),_players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}

return 
1;



Snitch 04-12-2014 17:55

Re: [help] votemaps
 
bump?

NikKOo31 04-12-2014 19:36

Re: [help] votemaps
 
Not tested ._. I hope it helps you

PHP Code:

/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >

#define MAX_MAPS 3

new bool:Voted33 ];
new 
g_szRoundVotemapTimer
new g_szKind[MAX_MAPS]
new 
g_maps[MAX_MAPS][30]
new 
rounds

new const Change[][] =
{
    
"jb_funny_live",
    
"jail_crewkule",
    
"jb_flyhigh",
    
"jail_pyramid",
    
"jail_crewkule2",
    
"jail_aj_bananamuffin_nd",
    
"jail_rehab_b2",
    
"jail_xmf",
    
"jail_armageddon",
    
"jail_renner_b6",
    
"jail_rats"
}

public 
plugin_init()
{
    
register_plugin("Simple VoteMap""1.0""AMXX")    
    
register_event"HLTV""NewRound""a""1=0""2=0" )
    
rounds register_cvar("amx_roundstovote""3")
}


public 
NewRound()
{
    
g_szRoundVotemap++;
    
ColorChat0"there will be votemap in: %i Rounds"g_szRoundVotemap);
    
    if(
g_szRoundVotemap >= get_pcvar_num(rounds))
        
set_task1.0"ActionSpecial" );
}

public 
ActionSpecial()
{
    for( new 
0<= MAX_MAPSi++ ) //select X maps
    
{
        
g_szKind[i] = 0
        format
(g_maps[i], 29"%s"Change[random_num(0sizeof(Change))])
    }
    
    for( new 
1<= get_maxplayers(); i++ ) //show menu
    
{
        if(
is_user_connected(i))
        {
            
Voted[i] = false;
            
ChangeMaps(i)
        }
    }
    
    
Timer 17
    
    client_cmd
(0"spk ^"get red(e80ninety(s45to check(e20) use bay(s18mass(e42cap(s50)^"")  
    
set_task17.0"checkvotesd",1700 );  
    
countdown2();
}

public 
ChangeMaps(client)
{
    static 
szMap[128];               
    new 
st];
    
formatex(szMapcharsmax(szMap), "\r[AMXX]\w Choose Map:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" "\rNot Voted"Timer);
    new 
menu menu_create(szMap"handlerdddd");

    for( new 
0MAX_MAPSk++ ) // show selected maps + votes
    
{
        
num_to_strkst);
        
formatexszMapcharsmaxszMap ), "\w%s \d[\y%i Votes\d]"g_maps[k] , g_szKind[k]);
        
menu_additemmenuszMapst );
    }

    
menu_setpropmenuMPROP_EXITMEXIT_NEVER );
    
menu_display(client,menu);
}

public 
checkvotesd()
{      
    new 
Winner 0;
    for( new 
1sizeof g_mapsi++ ) // select maps with more votes
    
{
        if( 
g_szKindWinner ] < g_szKind] )
            
Winner i;
    }

    
ColorChat0"%s ^4won ^1the vote with ^3%i ^1"g_mapsWinner ], g_szKindWinner ] );
    new 
map[30]
    
format(map29"%s"g_maps[Winner])
    
set_task(5.0"changemap_"_map30// change map in 5 seconds from vote end
}

public 
changemap_(param[])
    
server_cmd("changelevel %s"param)

public 
handlerddddclientmenuitem )
{
    if( 
Votedclient ] == true )
    {
        
ChangeMapsclient);
        return
    }
    
    new 
szName32 ];
    
get_user_nameclientszName32 );

    
ColorChat0"^3%s^1 has^4 voted ^1for^4 %s"szNameg_mapsitem ] )
    
g_szKinditem ]++;
    
    
Votedclient ] = true;
    
ChangeMaps(client);
    return
}

public 
countdown2()
{
    if(
Timer <= 0)
        
remove_task(2000)
    else
    {
        
Timer--
        
set_task(1.0,"countdown2");
        for( new 
1<= get_maxplayers(); i++ )
            if(
is_user_connected) )
                
ChangeMaps(i)
    }
}

stock ColorChat(const id, const string[], {FloatSqlResul,_}:...)
{
    new 
msg[191], players[32], count 1
    
static len
    len 
formatex(msgcharsmax(msg), "^1[^3 AMXX^1] ")
    
vformat(msg[len], charsmax(msg) - lenstring3)
    if(
id)    players[0] = id
    
else    get_players(players,count,"ch")
    
    for (new 
0counti++)
    {
        if(
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"),_players[i])
            
write_byte(players[i])
            
write_string(msg)
            
message_end()
        }
    }
    return



Snitch 04-13-2014 14:18

Re: [help] votemaps
 
Quote:

Originally Posted by NikKOo31 (Post 2123763)
Not tested ._. I hope it helps you

PHP Code:

/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >

#define MAX_MAPS 3

new bool:Voted33 ];
new 
g_szRoundVotemapTimer
new g_szKind[MAX_MAPS]
new 
g_maps[MAX_MAPS][30]
new 
rounds

new const Change[][] =
{
"jb_funny_live",
"jail_crewkule",
"jb_flyhigh",
"jail_pyramid",
"jail_crewkule2",
"jail_aj_bananamuffin_nd",
"jail_rehab_b2",
"jail_xmf",
"jail_armageddon",
"jail_renner_b6",
"jail_rats"
}

public 
plugin_init()
{
register_plugin("Simple VoteMap""1.0""AMXX"
register_event"HLTV""NewRound""a""1=0""2=0" )
rounds register_cvar("amx_roundstovote""3")
}


public 
NewRound()
{
g_szRoundVotemap++;
ColorChat0"there will be votemap in: %i Rounds"g_szRoundVotemap);

if(
g_szRoundVotemap >= get_pcvar_num(rounds))
set_task1.0"ActionSpecial" );
}

public 
ActionSpecial()
{
for( new 
0<= MAX_MAPSi++ ) //select X maps
{
g_szKind[i] = 0
format
(g_maps[i], 29"%s"Change[random_num(0sizeof(Change))])
}

for( new 
1<= get_maxplayers(); i++ ) //show menu
{
if(
is_user_connected(i))
{
Voted[i] = false;
ChangeMaps(i)
}
}

Timer 17

client_cmd
(0"spk ^"get red(e80ninety(s45to check(e20) use bay(s18mass(e42cap(s50)^""
set_task17.0"checkvotesd",1700 ); 
countdown2();
}

public 
ChangeMaps(client)
{
static 
szMap[128]; 
new 
st];
formatex(szMapcharsmax(szMap), "\r[AMXX]\w Choose Map:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" "\rNot Voted"Timer);
new 
menu menu_create(szMap"handlerdddd");

for( new 
0MAX_MAPSk++ ) // show selected maps + votes
{
num_to_strkst);
formatexszMapcharsmaxszMap ), "\w%s \d[\y%i Votes\d]"g_maps[k] , g_szKind[k]);
menu_additemmenuszMapst );
}

menu_setpropmenuMPROP_EXITMEXIT_NEVER );
menu_display(client,menu);
}

public 
checkvotesd()

new 
Winner 0;
for( new 
1sizeof g_mapsi++ ) // select maps with more votes
{
if( 
g_szKindWinner ] < g_szKind] )
Winner i;
}

ColorChat0"%s ^4won ^1the vote with ^3%i ^1"g_mapsWinner ], g_szKindWinner ] );
new 
map[30]
format(map29"%s"g_maps[Winner])
set_task(5.0"changemap_"_map30// change map in 5 seconds from vote end
}

public 
changemap_(param[])
server_cmd("changelevel %s"param)

public 
handlerddddclientmenuitem )
{
if( 
Votedclient ] == true )
{
ChangeMapsclient);
return
}

new 
szName32 ];
get_user_nameclientszName32 );

ColorChat0"^3%s^1 has^4 voted ^1for^4 %s"szNameg_mapsitem ] )
g_szKinditem ]++;

Votedclient ] = true;
ChangeMaps(client);
return
}

public 
countdown2()
{
if(
Timer <= 0)
remove_task(2000)
else
{
Timer--
set_task(1.0,"countdown2");
for( new 
1<= get_maxplayers(); i++ )
if(
is_user_connected) )
ChangeMaps(i)
}
}

stock ColorChat(const id, const string[], {FloatSqlResul,_}:...)
{
new 
msg[191], players[32], count 1
static len
len 
formatex(msgcharsmax(msg), "^1[^3 AMXX^1] ")
vformat(msg[len], charsmax(msg) - lenstring3)
if(
idplayers[0] = id
else get_players(players,count,"ch")

for (new 
0counti++)
{
if(
is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"),_players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
return



it's Random Maps? show every 3 rounds 4 Maps to choose or all maps?

i want it show only 4 maps every vote

NikKOo31 04-13-2014 15:45

Re: [help] votemaps
 
You can change

PHP Code:

#define MAX_MAPS 3 

To

PHP Code:

#define MAX_MAPS 4 

If you want 4 maps in the vote ^^
And with

PHP Code:

rounds register_cvar("amx_roundstovote""3"

You can configure how many rounds will be played before the vote ^^

But I don't have time to test if right now, if you get any errors let me know.
The only thing I just saw is that you don't check if the map exist/in valid map.

Snitch 04-14-2014 04:18

Re: [help] votemaps
 
bug:
there will be votemap in: 0 Rounds = nothing happend, no votemaps
i did sv_Restart 1
there will be votemap in: -1 Rounds

Code:

[AMXX]    [0] NewVoteMaps.sma::ActionSpecial (line 68)
[AMXX] Displaying debug trace (plugin "NewVoteMaps.amxx")
[AMXX] Run time error 4: index out of bounds
[AMXX]    [0] NewVoteMaps.sma::ActionSpecial (line 68)

i did clcmd to open votemaps
Time to choose: \y%i = not working

NikKOo31 04-14-2014 06:11

Re: [help] votemaps
 
I don't know how I didn't see this xD

PHP Code:

for( new 0<= MAX_MAPSi++ ) //select X maps 

-->
PHP Code:

for( new 0MAX_MAPSi++ ) //select X maps 

And for the '-1 Rounds' change this
PHP Code:

public NewRound()
{
    
g_szRoundVotemap++;
    
ColorChat0"there will be votemap in: %i Rounds"g_szRoundVotemap);
    
    if(
g_szRoundVotemap >= get_pcvar_num(rounds))
        
set_task1.0"ActionSpecial" );


To
PHP Code:

public NewRound()
{
    
g_szRoundVotemap++;
    
ColorChat0"there will be votemap in: %i Rounds"get_pcvar_num(rounds) - g_szRoundVotemap);
    
    if(
g_szRoundVotemap >= get_pcvar_num(rounds))
        
set_task1.0"ActionSpecial" );


Was just a typo
:3

Snitch 04-14-2014 13:06

Re: [help] votemaps
 
*Why this show me, two times jail_rats in vote?
Logs:
Code:

[AMXX] Run time error 4: index out of bounds
[AMXX]    [0] NewVoteMaps.sma::handlerdddd (line 135)

if you can please help me with something?

fix > Time to choose: %i?

the nextmap will change nextround?
without of message.

and i want type nextvote
and that will show message the next vote will show more %i

Thank dude:)

^SmileY 04-14-2014 16:46

Re: [help] votemaps
 
Try this:

PHP Code:

#include <amxmodx>

#define TASKID 1337
#define MAX_MAPS 32

new g_iMapCount;
new 
g_sMaps[MAX_MAPS][32];
new 
g_iMapVotes[MAX_MAPS];
new 
g_iMenuMap;

new 
g_pRounds;
new 
g_pRandom;
new 
g_pMapCycle;

new 
g_iRounds;


public 
plugin_init()
{
    
register_plugin("Vote Map",AMXX_VERSION_STR,"SmileY");
    
    
g_pRounds     register_cvar("amxx_votemap_rounds","3");
    
g_pRandom     register_cvar("amxx_votemap_random","1");
    
g_pMapCycle     get_cvar_pointer("mapcyclefile");
    
    
register_event("SendAudio","ev_SendAudio","a","2=%!MRAD_terwin","2=%!MRAD_ctwin");
}

public 
plugin_cfg()
{
    new 
sPatch[40];
    
get_localinfo("amxx_configsdir",sPatch,charsmax(sPatch));

    
format(sPatch,charsmax(sPatch),"%s/custom_maps.ini",sPatch);

    if(!
LoadMaps(sPatch))
    {
        
get_pcvar_string(g_pMapCycle,sPatch,charsmax(sPatch));
        
        
LoadMaps(sPatch);
    }
}

public 
LoadMaps(const sPatch[])
{
    if(
file_exists(sPatch))
    {
        new 
iFile fopen(sPatch,"rb");
        
        new 
sMap[32],iNum[10];
        
        new 
sCurrent[32];
        
get_mapname(sCurrent,charsmax(sCurrent));
        
        
g_iMenuMap menu_create("Vote Map:","MenuHandle",1);
        
menu_setprop(g_iMenuMap,MPROP_EXIT,MEXIT_NEVER);
        
        while(!
feof(iFile) && (g_iMapCount MAX_MAPS))
        {
            
fgets(iFile,sMap,charsmax(sMap));
            
trim(sMap);
            
            if(
sMap[0] != ';' && is_map_valid(sMap) && !equali(sMap,sCurrent))
            {
                
copy(g_sMaps[g_iMapCount],charsmax(g_sMaps[]),sMap);
                    
                
num_to_str(g_iMapCount,iNum,charsmax(iNum));
                
menu_additem(g_iMenuMap,g_sMaps[g_iMapCount],iNum);
            
                
g_iMapCount++;
            }
        }
        
        
fclose(iFile);
        
        return 
g_iMapCount;
    }
    
    return 
0;
}

public 
ev_SendAudio()
{
    new 
iRounds get_pcvar_num(g_pRounds);
    
    if(
iRounds && !task_exists(TASKID))
    {
        
g_iRounds++;
        
        if(
g_iRounds >= iRounds)
        {
            
StartVoteMap();
        }
        else
        {
            new 
iLack = (iRounds g_iRounds);
            
            if(
iLack 1)
            {
                
client_print_color
                
(
                    
0,
                    
print_team_red,
                    
"^4[AMXX] ^3%i ^1Rounds remaining to start the ^3Vote Map.",
                    
iLack
                
);
            }
            else
            {
                
client_print_color
                
(
                    
0,
                    
print_team_red,
                    
"^4[AMXX] ^3WARNING: LAST ROUND TO VOTE FOR NEW MAP!"
                
);
            }
        }
    }
    
/* else server_print("[AMXX] Vote Map Disabled."); */
}

public 
StartVoteMap()
{
    
arrayset(g_iMapVotes,0,sizeof(g_iMapVotes));
    
    new 
iPlayers[32],iNum;
    
get_players(iPlayers,iNum,"ch");
    
    for(new 
i;iNum;i++)
    {
        
menu_display(iPlayers[i],g_iMenuMap);
    }
    
    
set_task(15.0,"VoteMapEnd",TASKID);
    
    
client_print_color(0,print_team_blue,"^4[AMXX] ^3Starting Vote to Next Map...");
}

public 
MenuHandle(id,iMenu,iKey)
{
    if(
iKey != MENU_EXIT)
    {
        new 
sInfo[3],sKey[32],iAccess,iBack;
        
menu_item_getinfo(iMenu,iKey,iAccess,sInfo,charsmax(sInfo),sKey,charsmax(sKey),iBack);
        
        
g_iMapVotes[str_to_num(sInfo)]++;
        
        new 
sName[32];
        
get_user_name(id,sName,charsmax(sName));
        
        
client_print_color(0,print_team_grey,"^4[AMXX] ^3%s ^1choosed ^3%s",sName,sKey);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
VoteMapEnd()
{
    
show_menu(0,0,"^n",1);
    new 
iWinner,iWinnerVotes,iVotes;

    for(new 
i;g_iMapCount;i++)
    {
        
iVotes g_iMapVotes[i];
    
        if(
iVotes >= iWinnerVotes)
        {
            
iWinner i;
            
iWinnerVotes iVotes;
        }
        else if(
iVotes == iWinnerVotes)
        {
            if(
random_num(0,1))
            {
                
iWinner i;
                
iWinnerVotes iVotes;
            }
        }
    }
    
    if(
g_iMapVotes[iWinner])
    {
        
client_print_color
        
(
            
0,
            
print_team_blue,
            
"^4[AMXX] ^1Changing Map to ^3%s...",
            
g_sMaps[iWinner]
        );
    }
    else
    {
        if(
get_pcvar_num(g_pRandom))
        {
            while(!
is_map_valid(g_sMaps[iWinner]))
            {
                
iWinner random(g_iMapCount);
            }
            
            
client_print_color
            
(
                
0,
                
print_team_grey,
                
"^4[AMXX] ^3%s ^1Has been choosen: No one voted for a valid map.",
                
g_sMaps[iWinner]
            );
        }
        else
        {
            
set_task(5.0,"StartVoteMap",TASKID);
            
            
client_print_color
            
(
                
0,
                
print_team_grey,
                
"^4[AMXX] ^3Restarting Vote Map: No one voted for a valid map."
            
);
        }
    }
    
    
set_task(5.0,"ChangeMap",TASKID,g_sMaps[iWinner],sizeof(g_sMaps[]));
}

public 
ChangeMap(const sMap[])
{
    
server_cmd("changelevel ^"%s^"",sMap);



Snitch 04-15-2014 06:20

Re: [help] votemaps
 
Quote:

Originally Posted by ^SmileY (Post 2124590)
Try this:

PHP Code:

#include <amxmodx>

#define TASKID 1337
#define MAX_MAPS 32

new g_iMapCount;
new 
g_sMaps[MAX_MAPS][32];
new 
g_iMapVotes[MAX_MAPS];
new 
g_iMenuMap;

new 
g_pRounds;
new 
g_pRandom;
new 
g_pMapCycle;

new 
g_iRounds;


public 
plugin_init()
{
    
register_plugin("Vote Map",AMXX_VERSION_STR,"SmileY");
    
    
g_pRounds     register_cvar("amxx_votemap_rounds","3");
    
g_pRandom     register_cvar("amxx_votemap_random","1");
    
g_pMapCycle     get_cvar_pointer("mapcyclefile");
    
    
register_event("SendAudio","ev_SendAudio","a","2=%!MRAD_terwin","2=%!MRAD_ctwin");
}

public 
plugin_cfg()
{
    new 
sPatch[40];
    
get_localinfo("amxx_configsdir",sPatch,charsmax(sPatch));

    
format(sPatch,charsmax(sPatch),"%s/custom_maps.ini",sPatch);

    if(!
LoadMaps(sPatch))
    {
        
get_pcvar_string(g_pMapCycle,sPatch,charsmax(sPatch));
        
        
LoadMaps(sPatch);
    }
}

public 
LoadMaps(const sPatch[])
{
    if(
file_exists(sPatch))
    {
        new 
iFile fopen(sPatch,"rb");
        
        new 
sMap[32],iNum[10];
        
        new 
sCurrent[32];
        
get_mapname(sCurrent,charsmax(sCurrent));
        
        
g_iMenuMap menu_create("Vote Map:","MenuHandle",1);
        
menu_setprop(g_iMenuMap,MPROP_EXIT,MEXIT_NEVER);
        
        while(!
feof(iFile) && (g_iMapCount MAX_MAPS))
        {
            
fgets(iFile,sMap,charsmax(sMap));
            
trim(sMap);
            
            if(
sMap[0] != ';' && is_map_valid(sMap) && !equali(sMap,sCurrent))
            {
                
copy(g_sMaps[g_iMapCount],charsmax(g_sMaps[]),sMap);
                    
                
num_to_str(g_iMapCount,iNum,charsmax(iNum));
                
menu_additem(g_iMenuMap,g_sMaps[g_iMapCount],iNum);
            
                
g_iMapCount++;
            }
        }
        
        
fclose(iFile);
        
        return 
g_iMapCount;
    }
    
    return 
0;
}

public 
ev_SendAudio()
{
    new 
iRounds get_pcvar_num(g_pRounds);
    
    if(
iRounds && !task_exists(TASKID))
    {
        
g_iRounds++;
        
        if(
g_iRounds >= iRounds)
        {
            
StartVoteMap();
        }
        else
        {
            new 
iLack = (iRounds g_iRounds);
            
            if(
iLack 1)
            {
                
client_print_color
                
(
                    
0,
                    
print_team_red,
                    
"^4[AMXX] ^3%i ^1Rounds remaining to start the ^3Vote Map.",
                    
iLack
                
);
            }
            else
            {
                
client_print_color
                
(
                    
0,
                    
print_team_red,
                    
"^4[AMXX] ^3WARNING: LAST ROUND TO VOTE FOR NEW MAP!"
                
);
            }
        }
    }
    
/* else server_print("[AMXX] Vote Map Disabled."); */
}

public 
StartVoteMap()
{
    
arrayset(g_iMapVotes,0,sizeof(g_iMapVotes));
    
    new 
iPlayers[32],iNum;
    
get_players(iPlayers,iNum,"ch");
    
    for(new 
i;iNum;i++)
    {
        
menu_display(iPlayers[i],g_iMenuMap);
    }
    
    
set_task(15.0,"VoteMapEnd",TASKID);
    
    
client_print_color(0,print_team_blue,"^4[AMXX] ^3Starting Vote to Next Map...");
}

public 
MenuHandle(id,iMenu,iKey)
{
    if(
iKey != MENU_EXIT)
    {
        new 
sInfo[3],sKey[32],iAccess,iBack;
        
menu_item_getinfo(iMenu,iKey,iAccess,sInfo,charsmax(sInfo),sKey,charsmax(sKey),iBack);
        
        
g_iMapVotes[str_to_num(sInfo)]++;
        
        new 
sName[32];
        
get_user_name(id,sName,charsmax(sName));
        
        
client_print_color(0,print_team_grey,"^4[AMXX] ^3%s ^1choosed ^3%s",sName,sKey);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
VoteMapEnd()
{
    
show_menu(0,0,"^n",1);
    new 
iWinner,iWinnerVotes,iVotes;

    for(new 
i;g_iMapCount;i++)
    {
        
iVotes g_iMapVotes[i];
    
        if(
iVotes >= iWinnerVotes)
        {
            
iWinner i;
            
iWinnerVotes iVotes;
        }
        else if(
iVotes == iWinnerVotes)
        {
            if(
random_num(0,1))
            {
                
iWinner i;
                
iWinnerVotes iVotes;
            }
        }
    }
    
    if(
g_iMapVotes[iWinner])
    {
        
client_print_color
        
(
            
0,
            
print_team_blue,
            
"^4[AMXX] ^1Changing Map to ^3%s...",
            
g_sMaps[iWinner]
        );
    }
    else
    {
        if(
get_pcvar_num(g_pRandom))
        {
            while(!
is_map_valid(g_sMaps[iWinner]))
            {
                
iWinner random(g_iMapCount);
            }
            
            
client_print_color
            
(
                
0,
                
print_team_grey,
                
"^4[AMXX] ^3%s ^1Has been choosen: No one voted for a valid map.",
                
g_sMaps[iWinner]
            );
        }
        else
        {
            
set_task(5.0,"StartVoteMap",TASKID);
            
            
client_print_color
            
(
                
0,
                
print_team_grey,
                
"^4[AMXX] ^3Restarting Vote Map: No one voted for a valid map."
            
);
        }
    }
    
    
set_task(5.0,"ChangeMap",TASKID,g_sMaps[iWinner],sizeof(g_sMaps[]));
}

public 
ChangeMap(const sMap[])
{
    
server_cmd("changelevel ^"%s^"",sMap);



what u did here? Messy code
Error: Undefined symbol "client_print_color" on line 100
Warning: Loose indentation on line 104
Warning: Expression has no effect on line 104
Error: Invalid expression, assumed zero on line 106

Why not do it in my code?


All times are GMT -4. The time now is 05:55.

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