Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- new cmd_Vote,bool:start_vote[33]=false,Timer,g_Timer;
- const KEYSMENU = MENU_KEY_1|MENU_KEY_2
- public plugin_init(){
- register_plugin("Simple Vote RR","1.0","Seroff");
- register_clcmd("say /vote_rr","vt_rr");
- register_clcmd("say_team /vote_rr","vt_rr");
- g_Timer=register_cvar("vote_rr_time","30");
- register_menucmd(register_menuid("votemenu",0),KEYSMENU,"menu_vote");
- }
- public client_putinserver(id){
- start_vote[id]=false;
- }
- public vt_rr(id){
- if(start_vote[id]==false){
- cmd_Vote=0;
- Timer=get_pcvar_num(g_Timer);
- for(new i=1;i<33;i++){
- if(is_user_connected(i)){
- vote_menu(i);
- }
- if(i==32){
- set_task(Float: get_pcvar_float(g_Timer),"check_vote");
- }
- }
- start_vote[id]=true;
- set_task(1.0,"timer_reset",id,_,_,"a",Timer);
- }else{
- ChatColor(id,"^3Внимание^1: ^4Вы недавно уже вызывали голосование, теперь прейдется ждать (%d сек.)^1!",Timer);
- }
- }
- public vote_menu(id){
- static menu[512], len;
- len = 0;
- len += formatex(menu[len], charsmax(menu) - len, "\r Голосование за рестарт раунда^n^n");
- len += formatex(menu[len], charsmax(menu) - len, "\y1. \rДа^n");
- len += formatex(menu[len], charsmax(menu) - len, "\y2. \wНет^n");
- show_menu(id, KEYSMENU, menu, get_pcvar_num(g_Timer), "votemenu");
- return 0;
- }
- public menu_vote(id, key)
- {
- switch(key)
- {
- case 0:
- {
- cmd_Vote++
- }
- case 1:
- {
- menu_cancel(id);
- }
- }
- return 1;
- }
- public check_vote(){
- new duser=get_playersnum()/2;
- if(cmd_Vote!=0&&cmd_Vote>duser){
- ChatColor(0,"^3Внимание^1: ^4Большинством голосов принято было сделать рестарт раунда [%d/%d]^1!",cmd_Vote,get_playersnum());
- server_cmd("sv_restart 1");
- }else{
- ChatColor(0,"^3Внимание^1: ^4Так как мало было голосов, рестрат раунда отменен [%d/%d]^1!",cmd_Vote,get_playersnum());
- }
- cmd_Vote=0;
- }
- public timer_reset(id){
- if(Timer==1){
- start_vote[id]=false;
- }
- Timer--;
- }
- stock ChatColor(const id, const input[], any:...) {
- new count = 1, players[32];
- static msg[191];
- vformat(msg, 190, input, 3);
- replace_all(msg, 190, "!g", "^4") // Green Color
- replace_all(msg, 190, "!y", "^1") // Default Color
- replace_all(msg, 190, "!team", "^3") // Team Color
- 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, get_user_msgid("SayText"), _, players[i])
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment