Raised This Month: $ Target: $400
 0% 

[INC] Menu Targeting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-21-2018 , 05:35   Re: [INC] Menu Targeting
Reply With Quote #1

Or, you could just use ProcessTargetString, which is what FindTarget calls internally.

Edit: For an example of how to use it:

PHP Code:
// Somewhere earlier on, such as OnPluginStart
    
LoadTranslations("common.phrases");

public 
Action Command_SelectTargetint clientint args )
{
    
// Note: We changed this char length; this is defined in commandfilters.inc
    
char target[MAX_TARGET_LENGTH];
    
GetCmdArgStringtargetsizeof(target) );
    
    
int displayTo[MaxClients];

    
// Since this is intended to display a menu:
    // Filters say to ignore admin immunity levels and also not select bots
    
int count ProcessTargetString(targetclientdisplayTosizeof(displayTo), COMMAND_FILTER_NO_IMMUNITY|COMMAND_FILTER_NO_BOTS);
    if (
count 1)
    {
        
// This handles "target not found" and the like
        
ReplyToTargetError(clientcount);
        return 
Plugin_Handled;
    }

    
// displayTo[0] through displayTo[count-1] now contain client indexes of all matching clients that you can iterate through using a for loop
    
for (int i 0counti++)
    {
        
// Do something with displayTo[i]
        
PrintToChatdisplayTo[i], "[SM] This is boring and uses a for loop instead of a callback :(" );
    }
    return 
Plugin_Handled;

__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-21-2018 at 05:57.
Powerlord 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 22:39.


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