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

Solved Simple Votekick with hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
666
Senior Member
Join Date: Mar 2015
Old 09-20-2019 , 12:09   Simple Votekick with hud
Reply With Quote #1

I need a simple vote, for the player to activate using the say /votekick command, show a menu of all connected players, once the player selects a player, show the options yes or no and a hud with the result and the remaining time for finalize the vote, once the vote is over, kick the player and the hud disappears
__________________

Last edited by 666; 09-25-2019 at 00:28.
666 is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-20-2019 , 21:23   Re: Simple Votekick with hud
Reply With Quote #2

__________________
DJEarthQuake is offline
666
Senior Member
Join Date: Mar 2015
Old 09-23-2019 , 14:50   Re: Simple Votekick with hud
Reply With Quote #3

here I have the menu of connected players now I don't know how to make another menu to eject the selected player as I do

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say .pp""cs_display_player_menu");
}

public 
cs_display_player_menu(id)
{
    new 
menu menu_create("\yPlayers","cs_handle_player_menu");
    
    new 
Players[MAX_PLAYERS],Num,Tempid;
    new 
szName[MAX_NAME_LENGTH],szUserId[MAX_PLAYERS];
    
get_players(Players,Num,"h");
    
    for ( new 
i;Numi++ )
    {
        
Tempid Players[i];
        
        if((
Tempid != id) && !is_user_admin(Tempid))
        {
            
get_user_name(Tempid,szName,charsmax(szName));
            
            
formatex(szUserId,charsmax(szUserId),"%d",get_user_userid(Tempid));
            
            
menu_additem(menu,szName,szUserId,0);
        }
    }
    
    
menu_display(id,menu,0);
}

public 
cs_handle_player_menu(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
szData[6], szName[64], szAccessitem_callback;
    
menu_item_getinfo(menu,item,szAccess,szData,charsmax(szData),szName,charsmax(szName),item_callback);
    
    new 
Userid str_to_numszData );
    
    
client_print_color(id,1,"selected player is %s",szName);

__________________
666 is offline
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 09-23-2019 , 20:59   Re: Simple Votekick with hud
Reply With Quote #4

Since you're going the scripting route, you'll have to carry the selected player to a different function. You're going to have to make a new menu to ask for players vote, after that in the vote results function you're going to kick the player if the vote passes.
Moody92 is offline
666
Senior Member
Join Date: Mar 2015
Old 09-24-2019 , 18:13   Re: Simple Votekick with hud
Reply With Quote #5

Quote:
Originally Posted by Moody92 View Post
Since you're going the scripting route, you'll have to carry the selected player to a different function. You're going to have to make a new menu to ask for players vote, after that in the vote results function you're going to kick the player if the vote passes.
Could you tell me how to create the function and get the names of the one who initiated the vote and the one selected?
__________________
666 is offline
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 09-25-2019 , 17:49   Re: Simple Votekick with hud
Reply With Quote #6

Quote:
Originally Posted by 666 View Post
Could you tell me how to create the function and get the names of the one who initiated the vote and the one selected?
Look at the last :
szPlayer_Name = the guy vote started againts.
szName = the guy who started the vote.


Code:
public on_ShowMenu(id) {     new szMenuTitle[64]     formatex(szMenuTitle , charsmax(szMenuTitle) , "Vote Kick Menu :")     new menu = menu_create(szMenuTitle , "Menu_Handler")     new Players[32] ,iNum , tempid     new Name[32] , Userid[32]     get_players(Players , iNum)     for (new i; i<iNum; i++)     {         tempid = Players[i]         get_user_name(tempid , Name , charsmax(Name))         formatex(Userid , charsmax(Userid) , "%d" , get_user_userid(tempid))         menu_additem(menu , Name , Userid , 0)     }     menu_display(id , menu , 0) } public Menu_Handler(id , menu , item) {     if (item == MENU_EXIT)     {         menu_destroy(menu)         return PLUGIN_HANDLED     }     new szData[6] , Name[64]     new _access , item_callback     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), Name,charsmax( Name ), item_callback )     new userid = str_to_num(szData)     new player = find_player("k" , userid)     if (player && is_user_connected(player))     {         new szPlayer_Name[32] , szName[32]         get_user_name(player , szPlayer_Name , charsmax(szPlayer_Name))         get_user_name(id , szName , charsmax(szName))     } }

Last edited by LearninG; 09-25-2019 at 17:53.
LearninG is offline
thEsp
BANNED
Join Date: Aug 2017
Old 09-26-2019 , 14:06   Re: Simple Votekick with hud
Reply With Quote #7

@learning
Avoid memory leaks, please. You should always destroy a menu when you don't need it anymore...
thEsp is offline
Reply


Thread Tools
Display Modes

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 09:40.


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