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

[help] votemaps


Post New Thread Reply   
 
Thread Tools Display Modes
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-15-2014 , 12:56   Re: [help] votemaps
Reply With Quote #11

client_print_color is related to las amxmodx hg dev build.

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-15-2014 , 13:40   Re: [help] votemaps
Reply With Quote #12

From the original code

PHP Code:
new szName32 ];
get_user_nameclientszName32 ); 
-->
PHP Code:
new szName32 ];
get_user_nameclientszName31 ); 
PHP Code:
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); 
-->
PHP Code:
formatex(szMapcharsmax(szMap)-1"\r[AMXX]\w Choose Map:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" "\rNot Voted"Timer); 
(Maybe that message is too long, not sure)

For the chat thing
PHP Code:
registerclcmd("say nextvote""shownextvote"
PHP Code:
public shownextvote(id)
{
    
ColorChatid"there will be votemap in: %i Rounds"get_pcvar_num(rounds) - g_szRoundVotemap); 
    return 
PLUGIN_HANDLED;

And for the change in next round you can use SmileY code or you can hook round end like this
PHP Code:
new bool:g_lastround=false
new g_nextmap[30]//global variables 
PHP Code:
register_logevent("round_end"2"1=Round_End"//register round end event 
PHP Code:
public round_end()
{
    if(
g_lastround)
        
server_cmd("changelevel %s"g_nextmap)

After count votes you must set g_lastround to true and save the winner map in g_nextmap

Last edited by NikKOo31; 04-15-2014 at 13:41.
NikKOo31 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-15-2014 , 15:10   Re: [help] votemaps
Reply With Quote #13

PHP Code:
public shownextvote(id)
{
    
ColorChatid"there will be votemap in: %i Rounds"get_pcvar_num(rounds) - g_szRoundVotemap); 
    return 
PLUGIN_HANDLED;

Vote For all?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-15-2014 at 15:11.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 04-15-2014 , 15:38   Re: [help] votemaps
Reply With Quote #14

Here My Code, test it, if that okay:
Quote:
[AMXX] Displaying debug trace (plugin "NewVoteMaps.amxx")
[AMXX] Run time error 4: index out of bounds
[0] NewVoteMaps.sma::handlerdddd (line 151)
Code:
/* Plugin generated by AMXX-Studio */

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

#define MAX_MAPS 4

new bool:Voted[ 33 ];
new g_szRoundVotemap, Timer
new g_szKind[MAX_MAPS]
new g_maps[MAX_MAPS][30]
new rounds

new bool:g_lastround=false
new g_nextmap[30]//global variables 

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",
"jail_revolution",
"jail_p1tma",
"Jb_mini",
"jail_rixsus_v2",
"jb_unknown",
"jail_toys",
"jail_eltos"
}

public plugin_init()
{
register_plugin("Simple VoteMap", "1.0", "AMXX") 
register_event( "HLTV", "NewRound", "a", "1=0", "2=0" )
rounds = register_cvar("amx_roundstovote", "28")
register_logevent("round_end", 2, "1=Round_End") //register round end event 

register_clcmd("say /nextvote", "shownextvote") 
register_clcmd("say nextvote", "shownextvote") 
}

public shownextvote(id)
{
ColorChat( id, "There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds", get_pcvar_num(rounds) - g_szRoundVotemap); 
} 

public NewRound()
{
g_szRoundVotemap++;
ColorChat( 0, "There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds", get_pcvar_num(rounds) - g_szRoundVotemap);

if(g_szRoundVotemap >= get_pcvar_num(rounds))
set_task( 1.0, "ActionSpecial" );
} 

public round_end()
{
if(g_lastround)
server_cmd("changelevel %s", g_nextmap)
} 

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

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

Timer = 17

client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"") 
set_task( 17.0, "checkvotesd",1700 ); 
countdown2();
}

public ChangeMaps(client)
{
static szMap[128]; 
new st[ 3 ];
formatex(szMap, charsmax(szMap)-1, "\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 k = 0; k < MAX_MAPS; k++ ) // show selected maps + votes
{
num_to_str( k, st, 2 );
formatex( szMap, charsmax( szMap ), "\w%s \d[\y%i\w Votes\d]", g_maps[k] , g_szKind[k]);
menu_additem( menu, szMap, st );
}

menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER );
menu_display(client,menu);
}

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

ColorChat( 0, "%s ^4Won ^1the vote with ^3%i ^1 Votes", g_maps[ Winner ], g_szKind[ Winner ] );
new map[30]
format(map, 29, "%s", g_maps[Winner])
set_task(5.0, "changemap_", _, map, 30) // change map in 5 seconds from vote end
}

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

public handlerdddd( client, menu, item )
{
if( Voted[ client ] == true )
{
ChangeMaps( client);
return
}

new szName[ 32 ];
get_user_name( client, szName, 31 ); 

ColorChat( 0, "^3%s^1 has^4 Voted ^1for^4 %s", szName, g_maps[ item ] )
g_szKind[ item ]++;

Voted[ client ] = true;
ChangeMaps(client);
return
}

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

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

for (new i = 0; i < count; i++)
{
if(is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
return
}
please tell me if vote ended so map will change next round

but what diffrent >
PHP Code:
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 Votes"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

>
PHP Code:
public round_end()
{
if(
g_lastround)
server_cmd("changelevel %s"g_nextmap)

^SmileY Code, not working..

Last edited by YamiKaitou; 04-19-2014 at 15:53.
Snitch is offline
Send a message via Skype™ to Snitch
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-15-2014 , 18:24   Re: [help] votemaps
Reply With Quote #15

Again: Use last snapshot compiler with plugin

http://www.amxmodx.org/snapshots.php
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-15-2014 , 20:31   Re: [help] votemaps
Reply With Quote #16

PHP Code:
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 Votes"g_mapsWinner ], g_szKindWinner ] );
    
format(g_nextmap29"%s"g_maps[Winner])   // set winner as nextmap
    
g_lastround true                                        // last round set to true, in round end will change the map

Andddd I'm not sure of which is your line 151, but try this:
PHP Code:
public handlerddddclientmenuitem )
{
    if( 
Votedclient ] == true )
    {
        
ChangeMapsclient);
        return
    }
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)
    new 
key str_to_num(data) - 1

    
new szName32 ];
    
get_user_nameclientszName31 );  
    
    
ColorChat0"^3%s^1 has^4 Voted ^1for^4 %s"szNameg_mapskey ] )
    
g_szKindkey ]++;
    
    
Votedclient ] = true;
    
ChangeMaps(client);
    return

This is the only way I know to handle menu's
NikKOo31 is offline
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 04-16-2014 , 09:08   Re: [help] votemaps
Reply With Quote #17

Code:
Plugin called menu_display when item=MENU_EXIT
[AMXX] Displaying debug trace (plugin "NewVoteMaps.amxx")
[AMXX] Run time error 10: native error (native "menu_display")
[AMXX] [0] NewVoteMaps.sma::ChangeMaps (line 110)
[AMXX] [1] NewVoteMaps.sma::countdown2 (line 163)
what wrong?
PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define MAX_MAPS 4

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

new bool:g_lastround=false
new g_nextmap[30

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",
"jail_revolution",
"jail_p1tma",
"Jb_mini",
"jail_rixsus_v2",
"jb_unknown",
"jail_toys",
"jail_eltos"
}

public 
plugin_init()
{
register_plugin("Simple VoteMap""1.0""AMXX"
register_event"HLTV""NewRound""a""1=0""2=0" )
rounds register_cvar("amx_roundstovote""26")
register_logevent("round_end"2"1=Round_End"//register round end event 

register_clcmd("say /nextvote""shownextvote"
register_clcmd("say nextvote""shownextvote"
}

public 
shownextvote(id)
{
ColorChatid"There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds"get_pcvar_num(rounds) - g_szRoundVotemap); 


public 
NewRound()
{
g_szRoundVotemap++;
ColorChat0"There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds"get_pcvar_num(rounds) - g_szRoundVotemap);

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


public 
round_end()
{
if(
g_lastround)
server_cmd("changelevel %s"g_nextmap)
}

public 
ActionSpecial()
{
for( new 
0MAX_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)-1"\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 ), "\d%s \w[\y%i\d Votes\w]"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 Votes"g_mapsWinner ], g_szKindWinner ] );
format(g_nextmap29"%s"g_maps[Winner]) // set winner as nextmap
g_lastround true // last round set to true, in round end will change the map


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

public 
handlerddddclientmenuitem )
{
if( 
Votedclient ] == true )
{
ChangeMapsclient);
return
}
new 
data[6], iName[64]
new 
accesscallback
menu_item_getinfo
(menuitemaccessdata,5iName63callback)
new 
key str_to_num(data) - 1

new szName32 ];
get_user_nameclientszName31 ); 

ColorChat0"^3%s^1 has^4 Voted ^1for^4 %s"szNameg_mapskey ] )
g_szKindkey ]++;

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

i need display >
Code:
public changemap_(param[])
server_cmd("changelevel %s", param)
because i delete
PHP Code:
set_task(5.0"changemap_"_map30

Last edited by YamiKaitou; 04-19-2014 at 15:53.
Snitch is offline
Send a message via Skype™ to Snitch
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-16-2014 , 13:30   Re: [help] votemaps
Reply With Quote #18

You can delete changemap_ function ^^ it's not needed anymore

Quote:
Code:
Plugin called menu_display when item=MENU_EXIT
I thought you don't have an exit key

Quote:
PHP Code:
menu_setpropmenuMPROP_EXITMEXIT_NEVER ); 
What does this code do? I thought it was to hide the exit key :/
Anyway you can try this:

PHP Code:
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) && voted[i]) //will only refresh to clients that already voted
                
ChangeMaps(i)
    }

NikKOo31 is offline
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 04-17-2014 , 01:29   Re: [help] votemaps
Reply With Quote #19

Quote:
Originally Posted by NikKOo31 View Post
You can delete changemap_ function ^^ it's not needed anymore



I thought you don't have an exit key



What does this code do? I thought it was to hide the exit key :/
Anyway you can try this:

PHP Code:
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) && voted[i]) //will only refresh to clients that already voted
                
ChangeMaps(i)
    }

Kk thank about that, but still change map after vote, and i want after round, and u did public roundend.

Last edited by Snitch; 04-17-2014 at 08:34.
Snitch is offline
Send a message via Skype™ to Snitch
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-17-2014 , 11:28   Re: [help] votemaps
Reply With Quote #20

You can change the event where the map changes
You can use:
PHP Code:
register_logevent("round_start"2"1=Round_Start"
or
PHP Code:
register_event"new_round""new_round""a""1=0""2=0" ); 
And then
PHP Code:
public new_round()
{
    if(
g_lastround)
        
server_cmd("changelevel %s"g_nextmap)

or
PHP Code:
public round_start()
{
    if(
g_lastround)
        
server_cmd("changelevel %s"g_nextmap)

Here you have the common round events if you like to read ^^
NikKOo31 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 23:01.


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