Raised This Month: $ Target: $400
 0% 

Targets list in menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-20-2016 , 07:38   Targets list in menu
Reply With Quote #1

Hey,
I want to add to my menu targets list how can I do this?
this is my menu:
PHP Code:
#include <sourcemod>
#include <sdktools>
public void OnPluginStart()
{
   
RegConsoleCmd("sm_menu"Menu);
}
 
public 
Action Menu(int clientint args)
{
    if(!
IsValidClient(client))
        return 
Plugin_Handled;
       
    
Handle menu CreateMenu(MenuHandelr);
    
SetMenuTitle(menu"MENU");

    
AddMenuItem(menu"OPTION1""OPTION1");
    
DisplayMenu(menuclient15);
    return 
Plugin_Continue;
}
 
public 
int MenuHandelr(Menu menuMenuAction actionint clientint itemNum)
{
    if(
action == MenuAction_End || !IsValidClient(client))
        
CloseHandle(menu);
   
    if(
action == MenuAction_Select)
    {
        switch(
itemNum)
        {
            case 
0:
            {
            
//Here I want to do the targets menu
            
}
    

__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests

Last edited by asherkin; 10-25-2018 at 17:24. Reason: Restore to previous version.
BraveFox is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-20-2016 , 09:56   Re: Targets list in menu
Reply With Quote #2

help please
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 05-20-2016 , 11:31   Re: Targets list in menu
Reply With Quote #3

This should help you:
https://forums.alliedmods.net/showthread.php?t=276715
Phil25 is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-21-2016 , 07:24   Re: Targets list in menu
Reply With Quote #4

//bump
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 05-21-2016 , 13:47   Re: Targets list in menu
Reply With Quote #5

PHP Code:
bool bIsWierdo[MAXPLAYERS+1] = {false, ...};

public 
void menu(int client)
{
    
Handle hMenu CreateMenu(PlayerMenuHandler);
    
    
SetMenuTitle(hMenu"Wierdos on this Server:");
    
    
AddMenuItem(hMenu"""Mark All");
    
AddMenuItem(hMenu"""Unmark All");    
    
    for (
int iMaxClientsi++)
    {
        if (!
IsValidClient(i))
            continue;
        
        
char name[MAX_NAME_LENGTH], userid[64];
        
        
IntToString(GetClientUserId(i), useridsizeof(userid));
        
Format(namesizeof(name), "%s %N"bIsWierdo[i] ? "[✓]" "[  ]"i);    
        
AddMenuItem(hMenuuseridname);
    }
    
    
DisplayMenu(hMenuclient0);
    return;    
}

public 
int PlayerMenuHandler(Handle menuMenuAction actionint clientint option
{
    if (
action == MenuAction_Select)
    {
        if (
option == 0)
        {
            
//Mark all
        
}
        else if (
option == 1)
        {
            
//Unmark all
        
}
    
        
char szUserid[64];
        
GetMenuItem(menuoptionszUseridsizeof(szUserid));
        
int userid StringToInt(szUserid);
        
        
ServerCommand("sm_<command> #%i"userid); //Run whatever command you need to run (#%i being the selected player's userid)
    
}    
    
    if (
action == MenuAction_End)
        
CloseHandle(menu);
}

stock bool IsValidClient(int client)
{
    if (
client || client MaxClients)
        return 
false;
    if (!
IsClientConnected(client))
        return 
false;
    if (!
IsClientInGame(client))
        return 
false;
    if (
IsFakeClient(client))
        return 
false;

    return 
true;


Last edited by Addicted.; 05-21-2016 at 13:53.
Addicted. is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 05-21-2016 , 14:40   Re: Targets list in menu
Reply With Quote #6

There's actually a function that does it all for you that most people don't use; AddTargetsToMenu
Farbror Godis is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-21-2016 , 14:59   Re: Targets list in menu
Reply With Quote #7

Quote:
Originally Posted by oaaron99 View Post
PHP Code:
bool bIsWierdo[MAXPLAYERS+1] = {false, ...};

public 
void menu(int client)
{
    
Handle hMenu CreateMenu(PlayerMenuHandler);
    
    
SetMenuTitle(hMenu"Wierdos on this Server:");
    
    
AddMenuItem(hMenu"""Mark All");
    
AddMenuItem(hMenu"""Unmark All");    
    
    for (
int iMaxClientsi++)
    {
        if (!
IsValidClient(i))
            continue;
        
        
char name[MAX_NAME_LENGTH], userid[64];
        
        
IntToString(GetClientUserId(i), useridsizeof(userid));
        
Format(namesizeof(name), "%s %N"bIsWierdo[i] ? "[✓]" "[  ]"i);    
        
AddMenuItem(hMenuuseridname);
    }
    
    
DisplayMenu(hMenuclient0);
    return;    
}

public 
int PlayerMenuHandler(Handle menuMenuAction actionint clientint option
{
    if (
action == MenuAction_Select)
    {
        if (
option == 0)
        {
            
//Mark all
        
}
        else if (
option == 1)
        {
            
//Unmark all
        
}
    
        
char szUserid[64];
        
GetMenuItem(menuoptionszUseridsizeof(szUserid));
        
int userid StringToInt(szUserid);
        
        
ServerCommand("sm_<command> #%i"userid); //Run whatever command you need to run (#%i being the selected player's userid)
    
}    
    
    if (
action == MenuAction_End)
        
CloseHandle(menu);
}

stock bool IsValidClient(int client)
{
    if (
client || client MaxClients)
        return 
false;
    if (!
IsClientConnected(client))
        return 
false;
    if (!
IsClientInGame(client))
        return 
false;
    if (
IsFakeClient(client))
        return 
false;

    return 
true;

how can I put it in my menu?
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 05-21-2016 , 15:05   Re: Targets list in menu
Reply With Quote #8

Quote:
Originally Posted by BraveFox View Post
how can I put it in my menu?


PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
RegConsoleCmd("sm_menu"Menu);
}
 
public 
Action Menu(int clientint args)
{
    
Handle hMenu CreateMenu(PlayerMenuHandler); 
     
    
SetMenuTitle(hMenu"Wierdos on this Server:"); 
     
    
AddMenuItem(hMenu"""Mark All"); 
    
AddMenuItem(hMenu"""Unmark All");     
     
    for (
int iMaxClientsi++) 
    { 
        if (!
IsValidClient(i)) 
            continue; 
         
        
char name[MAX_NAME_LENGTH], userid[64]; 
         
        
IntToString(GetClientUserId(i), useridsizeof(userid)); 
        
Format(namesizeof(name), "%s %N"bIsWierdo[i] ? "[✓]" "[  ]"i);     
        
AddMenuItem(hMenuuseridname); 
    } 
     
    
DisplayMenu(hMenuclient0); 
    return;     


public 
int PlayerMenuHandler(Handle menuMenuAction actionint clientint option)  

    if (
action == MenuAction_Select
    { 
        if (
option == 0
        { 
            
//Mark all 
        

        else if (
option == 1
        { 
            
//Unmark all 
        

     
        
char szUserid[64]; 
        
GetMenuItem(menuoptionszUseridsizeof(szUserid)); 
        
int userid StringToInt(szUserid); 
         
        
ServerCommand("sm_<command> #%i"userid); //Run whatever command you need to run (#%i being the selected player's userid) 
    
}     
     
    if (
action == MenuAction_End
        
CloseHandle(menu); 


stock bool IsValidClient(int client

    if (
client || client MaxClients
        return 
false
    if (!
IsClientConnected(client)) 
        return 
false
    if (!
IsClientInGame(client)) 
        return 
false
    if (
IsFakeClient(client)) 
        return 
false

    return 
true

Addicted. is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-22-2016 , 00:03   Re: Targets list in menu
Reply With Quote #9

Quote:
Originally Posted by oaaron99 View Post


PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
RegConsoleCmd("sm_menu"Menu);
}
 
public 
Action Menu(int clientint args)
{
    
Handle hMenu CreateMenu(PlayerMenuHandler); 
     
    
SetMenuTitle(hMenu"Wierdos on this Server:"); 
     
    
AddMenuItem(hMenu"""Mark All"); 
    
AddMenuItem(hMenu"""Unmark All");     
     
    for (
int iMaxClientsi++) 
    { 
        if (!
IsValidClient(i)) 
            continue; 
         
        
char name[MAX_NAME_LENGTH], userid[64]; 
         
        
IntToString(GetClientUserId(i), useridsizeof(userid)); 
        
Format(namesizeof(name), "%s %N"bIsWierdo[i] ? "[✓]" "[  ]"i);     
        
AddMenuItem(hMenuuseridname); 
    } 
     
    
DisplayMenu(hMenuclient0); 
    return;     


public 
int PlayerMenuHandler(Handle menuMenuAction actionint clientint option)  

    if (
action == MenuAction_Select
    { 
        if (
option == 0
        { 
            
//Mark all 
        

        else if (
option == 1
        { 
            
//Unmark all 
        

     
        
char szUserid[64]; 
        
GetMenuItem(menuoptionszUseridsizeof(szUserid)); 
        
int userid StringToInt(szUserid); 
         
        
ServerCommand("sm_<command> #%i"userid); //Run whatever command you need to run (#%i being the selected player's userid) 
    
}     
     
    if (
action == MenuAction_End
        
CloseHandle(menu); 


stock bool IsValidClient(int client

    if (
client || client MaxClients
        return 
false
    if (!
IsClientConnected(client)) 
        return 
false
    if (!
IsClientInGame(client)) 
        return 
false
    if (
IsFakeClient(client)) 
        return 
false

    return 
true

Bro if I can't add it to my menu this code is not helping me
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 05-22-2016 , 00:19   Re: Targets list in menu
Reply With Quote #10

Quote:
Originally Posted by Farbror Godis View Post
There's actually a function that does it all for you that most people don't use; AddTargetsToMenu
But how can I do that when I will choose player from the list(if I am using it) it will do command on him!????????
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox 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 18:04.


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