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

[INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2021 , 10:02   [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #1



cmd_targetex() - Advanced Command Targeting


Description
  • This .inc file adds an advanced version of the default cmd_target() function which allows you to create admin commands that can target players that meet certain criteria.

API Documentation

Available Arguments
  • Below is a list of all arguments admins can use when using a command created with cmd_targetex().
  • The global format for the arguments is: @[!]<argument>[team]
    • @aim - targets the player that the admin is aiming at
    • @all - targets all players
    • @alive - targets alive players
    • @bots - targets all bots
    • @dead - targets dead players
    • @humans - targets all humans
    • @me - targets the admin himself
    • @spectating - targets the client that the admin is spectating
    • @view - targets all clients in the admin's field of view
  • In addition, you can also specify a team name if the argument is used to target more than one player, e.g. @alivect or @viewt.
  • The admin can also use ! to exclude himself from the target group, e.g. @!all will target all players except the admin who used the command.

Target Flags
  • Just like the default cmd_target() function, cmd_targetex() also offers a variety of targeting flags that can be added in the flags argument.
    • TARGETEX_NONE - don't use any special flags
    • TARGETEX_OBEY_IMM_SINGLE - immunity will be obeyed when using arguments that target a single client
    • TARGETEX_OBEY_IMM_GROUP - immunity will be obeyed when using arguments that target a group of clients
    • TARGETEX_NO_SELF - doesn't allow the admin to target himself
    • TARGETEX_NO_GROUPS - doesn't allow usage of arguments that target a group of clients
    • TARGETEX_NO_BOTS - doesn't allow targeting bots
    • TARGETEX_NO_ALIVE - doesn't allow targeting alive clients
    • TARGETEX_NO_DEAD - doesn't allow targeting dead clients
  • Multiple flags can be specified per usage, e.g. TARGETEX_NO_SELF|TARGETEX_NO_ALIVE|TARGETEX_O BEY_IMM_SINGLE

Example
  • Here's an example code of how this .inc file can be used to create a simple slap command that supports advanced targeting.

    PHP Code:
    #include <amxmodx>
    #include <amxmisc>
    #include <targetex>

    public plugin_init()
    {
        
    register_plugin("MyPlugin""1.0""OciXCrom")
        
    register_clcmd("test_slap""Cmd_Slap"ADMIN_SLAY"<player|group>")
    }

    public 
    Cmd_Slap(idiLeveliCid)
    {
        if(!
    cmd_access(idiLeveliCid2))
        {
            return 
    PLUGIN_HANDLED
        
    }

        new 
    szArg[32], szTarget[32]
        
    read_argv(1szArgcharsmax(szArg))

        new 
    iPlayers[32], iPnum cmd_targetex(idszArgiPlayersszTargetcharsmax(szTarget), TARGETEX_OBEY_IMM_SINGLE)

        if(!
    iPnum)
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        for(new 
    iiPnumi++)
        {
            
    user_slap(iPlayers[i], 0)
        }

        new 
    szName[32]
        
    get_user_name(idszNamecharsmax(szName))
        
    client_print(0print_chat"ADMIN %s slapped %s"szNameszTarget)
        return 
    PLUGIN_HANDLED

  • Example usage:
    • test_slap @me
    • test_slap @all
    • test_slap OciXCrom
    • test_slap "STEAM_ID"
    • test_slap #userid
    • test_slap @!alivect

Additional information and download link


__________________

Last edited by OciXCrom; 03-02-2021 at 14:50.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2021 , 14:17   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #2

Update v1.1 - the 1.9/1.10 requirement has been dropped. TargetEx can now be used in AMXX 1.8.2 as well.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-02-2021 , 15:21   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #3

Great job on this one, easy to use and effective, thanks for sharing.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
nacho312
Member
Join Date: Mar 2020
Old 03-02-2021 , 21:42   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #4

Much appreciated, thanks Oci!
nacho312 is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2021 , 07:09   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post


cmd_targetex() - Advanced Command Targeting


Description
  • This .inc file adds an advanced version of the default cmd_target() function which allows you to create admin commands that can target players that meet certain criteria.

API Documentation

Available Arguments
  • Below is a list of all arguments admins can use when using a command created with cmd_targetex().
  • The global format for the arguments is: @[!]<argument>[team]
    • @aim - targets the player that the admin is aiming at
    • @all - targets all players
    • @alive - targets alive players
    • @bots - targets all bots
    • @dead - targets dead players
    • @humans - targets all humans
    • @me - targets the admin himself
    • @spectating - targets the client that the admin is spectating
    • @view - targets all clients in the admin's field of view
  • In addition, you can also specify a team name if the argument is used to target more than one player, e.g. @alivect or @viewt.
  • The admin can also use ! to exclude himself from the target group, e.g. @!all will target all players except the admin who used the command.

Target Flags
  • Just like the default cmd_target() function, cmd_targetex() also offers a variety of targeting flags that can be added in the flags argument.
    • TARGETEX_NONE - don't use any special flags
    • TARGETEX_OBEY_IMM_SINGLE - immunity will be obeyed when using arguments that target a single client
    • TARGETEX_OBEY_IMM_GROUP - immunity will be obeyed when using arguments that target a group of clients
    • TARGETEX_NO_SELF - doesn't allow the admin to target himself
    • TARGETEX_NO_GROUPS - doesn't allow usage of arguments that target a group of clients
    • TARGETEX_NO_BOTS - doesn't allow targeting bots
    • TARGETEX_NO_ALIVE - doesn't allow targeting alive clients
    • TARGETEX_NO_DEAD - doesn't allow targeting dead clients
  • Multiple flags can be specified per usage, e.g. TARGETEX_NO_SELF|TARGETEX_NO_ALIVE|TARGETEX_O BEY_IMM_SINGLE

Example
  • Here's an example code of how this .inc file can be used to create a simple slap command that supports advanced targeting.

    PHP Code:
    #include <amxmodx>
    #include <amxmisc>
    #include <targetex>

    public plugin_init()
    {
        
    register_plugin("MyPlugin""1.0""OciXCrom")
        
    register_clcmd("test_slap""Cmd_Slap"ADMIN_SLAY"<player|group>")
    }

    public 
    Cmd_Slap(idiLeveliCid)
    {
        if(!
    cmd_access(idiLeveliCid2))
        {
            return 
    PLUGIN_HANDLED
        
    }

        new 
    szArg[32], szTarget[32]
        
    read_argv(1szArgcharsmax(szArg))

        new 
    iPlayers[32], iPnum cmd_targetex(idszArgiPlayersszTargetcharsmax(szTarget), TARGETEX_OBEY_IMM_SINGLE)

        if(!
    iPnum)
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        for(new 
    iiPnumi++)
        {
            
    user_slap(iPlayers[i], 0)
        }

        new 
    szName[32]
        
    get_user_name(idszNamecharsmax(szName))
        
    client_print(0print_chat"ADMIN %s slapped %s"szNameszTarget)
        return 
    PLUGIN_HANDLED

  • Example usage:
    • test_slap @me
    • test_slap @all
    • test_slap OciXCrom
    • test_slap "STEAM_ID"
    • test_slap #userid
    • test_slap @!alivect

Additional information and download link


Good job. However, if u want this include to be added to AMXX, it's better if u can provide support for games other than CS 1.6 and CZero, as in CS, for example, spectator is a team, but on HL1 and other goldsrc games it isn't, and from what I've seen teams are only supported on CS. TFC, for example, uses 4 teams, blue, red, yellow and green, however, on most games spectator is detected if pev -> iuser1 and iuser2 are not 0, but on TFC, if pev->team is 0, it means the player is a spectator. So perhaps check if modname is cstrike or czero use the CS teams, otherwise provide support for up to 4 teams, by providing @team1, @team2, @team3 and @team4. If TFC is detected, it could instead be @blue, @red, @yellow and @green, otherwise, up to 4 teams if neither TFC or CS are detected. And I recommend making szModName a static char, and only call get_modname if the string has no size, aka if(!szModName[0]).
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-03-2021 , 09:09   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #6

I'm aware of this, but I wasn't able to find a complete list of team names in all games. I did add only "cstrike" teams that work only when modname is "cstrike". You can easily add more:

Code:
static TargetEx_Teams[][TargetExTeamStructure] = {     { "ct", "CT" },     { "t", "TERRORIST" },     { "spec", "SPECTATOR" } }

Code:
if(equal(szModName, "cstrike")) {     TargetEx_TeamStart = 0;     TargetEx_TeamEnd = 2; }

I will fully expand this if I get to such a list.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2021 , 11:25   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
I'm aware of this, but I wasn't able to find a complete list of team names in all games. I did add only "cstrike" teams that work only when modname is "cstrike". You can easily add more:

Code:
static TargetEx_Teams[][TargetExTeamStructure] = {     { "ct", "CT" },     { "t", "TERRORIST" },     { "spec", "SPECTATOR" } }

Code:
if(equal(szModName, "cstrike")) {     TargetEx_TeamStart = 0;     TargetEx_TeamEnd = 2; }

I will fully expand this if I get to such a list.
What I can tell you for now is that TFC supports up to 4 teams, DoD and OP4 2 teams (not sure if spectator is a team on DoD, if it is, then 3), but OP4 is either deathmatch or team-based black mesa vs HECU marines CTF. But for sure, in DoD there can't be less than 2 teams.
DarthMan is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 03-07-2021 , 04:48   Re: [INC] cmd_targetex(): @all, @ct, @t, @me, @view & more!
Reply With Quote #8

Thanks for sharing
very attractive
amirwolf 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 18:56.


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