Raised This Month: $32 Target: $400
 8% 

[REQ] 11 player for Vote


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 04-14-2020 , 11:59   [REQ] 11 player for Vote
Reply With Quote #1

When 11 players are present, voting is done automatically
Like the example below:
Code:
 Vote For Swap

1. Yes
2. No
PHP Code:
Yes server_cmd("amx_swap")
No client_print(idprint_chat,"Vote: No"
When 7 players are present, the following command is executed automatically
PHP Code:
7 Player server_cmd("amx_warm"

Last edited by alferd; 04-14-2020 at 11:59.
alferd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-14-2020 , 17:33   Re: [REQ] 11 player for Vote
Reply With Quote #2

Untested

PHP Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <cstrike>

#define VOTEID 123987

#pragma semicolon 1

new const szVersion[] = "1.0";

new 
iTerPlayers;
new 
iCtPlayers;
new 
iTotalPlayers;

new 
iVoteMenu;
new 
iYes;
new 
iNo;

new 
CsTeams:userTeam[33];

public 
plugin_init() {
    
register_plugin("VoteSwap"szVersion"NapoleoN#");

    
register_event("TeamInfo""TeamInfo""a");
}

#if AMXX_VERSION_NUM < 190
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    switch(
userTeam[id]) {
        case 
CS_TEAM_TiTerPlayers--;
        case 
CS_TEAM_CTiCtPlayers--;
    }
    
userTeam[id] = CS_TEAM_UNASSIGNED;
}

public 
TeamInfo() {
    new 
idszTeam[2];

    
id read_data(1);
    
read_data(2szTeamcharsmax(szTeam));

    switch(
szTeam[0]) {
        case 
'T': {
            if(
userTeam[id] == CS_TEAM_CT) {
                
iCtPlayers--;
            }

            
iTerPlayers++;
            
userTeam[id] = CS_TEAM_T;
        }

        case 
'C': {
            if(
userTeam[id] == CS_TEAM_T) {
                
iTerPlayers--;
            }

            
iCtPlayers++;
            
userTeam[id] = CS_TEAM_CT;
            
iTotalPlayers iTerPlayers iCtPlayers;
        }

        default: return 
PLUGIN_HANDLED;
    }

    if(
iTotalPlayers == 11) {
        
VoteSwap();
    }

    else if(
iTotalPlayers == 7) {
        
server_cmd("amx_warm");
    }

    return 
PLUGIN_HANDLED;
}

public 
VoteSwap() {
    if(!
task_exists(VOTEID)) {
        
set_task(15.0"EndVote"VOTEID);

        
iVoteMenu menu_create("Vote For Swap:""VoteHandler");

        
menu_additem(iVoteMenu"Yes.");
        
menu_additem(iVoteMenu"No.");

        new 
iPlayers[32], iNum;
        
get_players(iPlayersiNum);

        for(new 
iiNumi++) {
            
menu_display(iPlayers[i], iVoteMenu);
        }
    }
}

public 
VoteHandler(idiVoteMenuitem) {
    switch(
item) {
        case 
0iYes++;
        case 
1iNo++;
    }
}

public 
EndVote() {
    if(
iYes iNo) {
        
server_cmd("amx_swap");
    }

    else if(
iYes iNo) {
        
client_print(0print_chat"Vote: No");
    }

    else {
        
client_print(0print_chat"Yes: %i - No: %i"iYesiNo);
        
client_print(0print_chat"Casting revote...");
        
set_task(0.5"VoteSwap");
    }

    
iYes 0;
    
iNo 0;
    
menu_destroy(iVoteMenu);

__________________

Last edited by Napoleon_be; 04-14-2020 at 17:35.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 04-15-2020 , 07:33   Re: [REQ] 11 player for Vote
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Untested

PHP Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <cstrike>

#define VOTEID 123987

#pragma semicolon 1

new const szVersion[] = "1.0";

new 
iTerPlayers;
new 
iCtPlayers;
new 
iTotalPlayers;

new 
iVoteMenu;
new 
iYes;
new 
iNo;

new 
CsTeams:userTeam[33];

public 
plugin_init() {
    
register_plugin("VoteSwap"szVersion"NapoleoN#");

    
register_event("TeamInfo""TeamInfo""a");
}

#if AMXX_VERSION_NUM < 190
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    switch(
userTeam[id]) {
        case 
CS_TEAM_TiTerPlayers--;
        case 
CS_TEAM_CTiCtPlayers--;
    }
    
userTeam[id] = CS_TEAM_UNASSIGNED;
}

public 
TeamInfo() {
    new 
idszTeam[2];

    
id read_data(1);
    
read_data(2szTeamcharsmax(szTeam));

    switch(
szTeam[0]) {
        case 
'T': {
            if(
userTeam[id] == CS_TEAM_CT) {
                
iCtPlayers--;
            }

            
iTerPlayers++;
            
userTeam[id] = CS_TEAM_T;
        }

        case 
'C': {
            if(
userTeam[id] == CS_TEAM_T) {
                
iTerPlayers--;
            }

            
iCtPlayers++;
            
userTeam[id] = CS_TEAM_CT;
            
iTotalPlayers iTerPlayers iCtPlayers;
        }

        default: return 
PLUGIN_HANDLED;
    }

    if(
iTotalPlayers == 11) {
        
VoteSwap();
    }

    else if(
iTotalPlayers == 7) {
        
server_cmd("amx_warm");
    }

    return 
PLUGIN_HANDLED;
}

public 
VoteSwap() {
    if(!
task_exists(VOTEID)) {
        
set_task(15.0"EndVote"VOTEID);

        
iVoteMenu menu_create("Vote For Swap:""VoteHandler");

        
menu_additem(iVoteMenu"Yes.");
        
menu_additem(iVoteMenu"No.");

        new 
iPlayers[32], iNum;
        
get_players(iPlayersiNum);

        for(new 
iiNumi++) {
            
menu_display(iPlayers[i], iVoteMenu);
        }
    }
}

public 
VoteHandler(idiVoteMenuitem) {
    switch(
item) {
        case 
0iYes++;
        case 
1iNo++;
    }
}

public 
EndVote() {
    if(
iYes iNo) {
        
server_cmd("amx_swap");
    }

    else if(
iYes iNo) {
        
client_print(0print_chat"Vote: No");
    }

    else {
        
client_print(0print_chat"Yes: %i - No: %i"iYesiNo);
        
client_print(0print_chat"Casting revote...");
        
set_task(0.5"VoteSwap");
    }

    
iYes 0;
    
iNo 0;
    
menu_destroy(iVoteMenu);

not work
alferd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-15-2020 , 16:49   Re: [REQ] 11 player for Vote
Reply With Quote #4

What doesn't work? Tell me if the plugin is running, tell me if u have error logs with debug enabled etc.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 04-16-2020 , 01:56   Re: [REQ] 11 player for Vote
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
What doesn't work? Tell me if the plugin is running, tell me if u have error logs with debug enabled etc.
There is no error, (but I tested the plugin with bot)
alferd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-16-2020 , 06:24   Re: [REQ] 11 player for Vote
Reply With Quote #6

Quote:
Originally Posted by alferd View Post
There is no error, (but I tested the plugin with bot)
what doesn't work..?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 04-16-2020 , 06:56   Re: [REQ] 11 player for Vote
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
what doesn't work..?
When 11 players are present, the voting menu does not open,

When 7 players are present, it does not execute the following command

Code:
amx_warm
alferd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-16-2020 , 13:43   Re: [REQ] 11 player for Vote
Reply With Quote #8

Quote:
Originally Posted by alferd View Post
When 11 players are present, the voting menu does not open,

When 7 players are present, it does not execute the following command

Code:
amx_warm
is amx_warm a cvar?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 04-16-2020 , 13:53   Re: [REQ] 11 player for Vote
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
is amx_warm a cvar?
yes
alferd 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 07:39.


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