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

ProcessTargetString/AddMultiTargetFilter, who ran the command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-27-2014 , 14:42   ProcessTargetString/AddMultiTargetFilter, who ran the command
Reply With Quote #1

Alright, so I'm trying to create some custom targeting filters that target based on the client using the command. For example, "sm_resize @10m .5" or whathaveyou should resize all players within 10 meters of me to half of normal size.

There are three built in filters that do this (@me, @!me, @aim), so I'm guessing that this is possible. I just can't figure it out.

tl;dr, help me create a multitargetfilter that "knows" what client ran the command


PHP Code:
public OnPluginStart()
{
    
//other stuff

    
AddMultiTargetFilter("@example"t_filter"example filter"false);

    
//other stuff
}

public 
OnPluginEnd()
{
    
//other stuff

    
RemoveMultiTargetFilter("@example"t_filter);

    
//other stuff
}

public 
bool:t_filter(const String:pattern[], Handle:clients) {
    new 
client //put the client who used the command here
    
    //other stuff that uses "client"

__________________

Last edited by ddhoward; 01-27-2014 at 14:45.
ddhoward is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-27-2014 , 15:48   Re: ProcessTargetString/AddMultiTargetFilter, who ran the command
Reply With Quote #2

It's possible for @me, @!me, and @aim to do it because they're part of ProcessTargetString and aren't a MultiTargetFilter callback.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-27-2014 , 15:55   Re: ProcessTargetString/AddMultiTargetFilter, who ran the command
Reply With Quote #3

Okay. I'll have to do my other idea then: to create a variable that holds the client index of the last player to run a command (through OnClientCommand()), and then have the callback reference that variable. I'm fairly certain that OnClientCommand would be called before the actual command's code would be executed. I'm just wondering if this is done consistently.

EDIT: okay, yeah, using OnClientCommand() to store the index of the player should work perfectly

PHP Code:
new OCCclient;

public 
OnPluginStart()
{
    
AddMultiTargetFilter("@example"t_filter"example filter"false);
}

public 
OnPluginEnd()
{
    
RemoveMultiTargetFilter("@example"t_filter);
}

public 
Action:OnClientCommand(clientargs) {
    
OCCclient client;
}

public 
bool:t_filter(const String:pattern[], Handle:clients) {
    new 
client OCCclient;
    
    
//other stuff that uses "client"
    //depending on this code, checking if client == 0 may be necessary

__________________

Last edited by ddhoward; 01-27-2014 at 16:29.
ddhoward is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-19-2014 , 12:19   Re: ProcessTargetString/AddMultiTargetFilter, who ran the command
Reply With Quote #4

Quote:
Originally Posted by ddhoward View Post
Okay. I'll have to do my other idea then: to create a variable that holds the client index of the last player to run a command (through OnClientCommand()), and then have the callback reference that variable. I'm fairly certain that OnClientCommand would be called before the actual command's code would be executed. I'm just wondering if this is done consistently.

EDIT: okay, yeah, using OnClientCommand() to store the index of the player should work perfectly

PHP Code:
new OCCclient;

public 
OnPluginStart()
{
    
AddMultiTargetFilter("@example"t_filter"example filter"false);
}

public 
OnPluginEnd()
{
    
RemoveMultiTargetFilter("@example"t_filter);
}

public 
Action:OnClientCommand(clientargs) {
    
OCCclient client;
}

public 
bool:t_filter(const String:pattern[], Handle:clients) {
    new 
client OCCclient;
    
    
//other stuff that uses "client"
    //depending on this code, checking if client == 0 may be necessary

Cool, ill add this to my super targeting plugin!
Mitchell 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 00:38.


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