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

Menu with a list of players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tibaus
Junior Member
Join Date: Apr 2020
Old 06-02-2020 , 08:33   Menu with a list of players
Reply With Quote #1

Hi dear,

I need a menu with a list of players on a server, then select one player, do something from another function. How can I do this?

Best regards!
Tibaus is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 06-02-2020 , 09:10   Re: Menu with a list of players
Reply With Quote #2

How to create a menu: https://wiki.alliedmods.net/Menu_API...od)#Basic_Menu

Instead of menu.AddItem() you can use AddTargetsToMenu2 to add a list of players. There are working examples in SourceMod's scripting folder.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 06-02-2020 , 11:11   Re: Menu with a list of players
Reply With Quote #3

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>



public Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_showmenu"showmenu);
}
public 
Action showmenu(int client,int args)
{
    if(
IsClientInGame(client)&&!IsFakeClient(client))
    
ShowMainMenu(client);
    return 
Plugin_Handled;
}
void ShowMainMenu(int client)
{
    
Menu PlayersMenu = new Menu(menuHandler_PlayersMenu);
    
PlayersMenu.SetTitle("Online Players");
    for(
int i 1<= MaxClients;i++)
    {
    if(
IsClientInGame(i)&&!IsFakeClient(i))
    
PlayersMenu.AddItem("%N","%N",i);
    }
    
PlayersMenu.ExitButton true;
    
PlayersMenu.Display(clientMENU_TIME_FOREVER);
}
public 
int menuHandler_PlayersMenu(Menu menuMenuAction actionint clientint itemNUM)
{
    if (
action == MenuAction_Select)
    {
        
char sztarget[MAX_NAME_LENGTH];
        
menu.GetItem(itemNUM,sztargetsizeof(sztarget));
        
int itarget FindTarget(clientsztargettruefalse);
         
//your function goes here. use itarget as your targeted player
    
}


Last edited by SSheriFF; 06-02-2020 at 11:19.
SSheriFF 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 12:22.


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