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

Сообщения
157
Реакции
279
cmd_targetex() - Advanced Command Targeting

chat_preview.png

☄ 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]
    • @аim - targets the player that the admin is aiming at
    • @аll - targets all players
    • @аlive - targets alive players
    • @bоts - targets all bots
    • @deаd - targets dead players
    • @humаns - targets all humans
    • @mе - targets the admin himself
    • @spectаting - targets the client that the admin is spectating
    • @viеw - 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 flagsargument.
    • 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_OBEY_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.

    C++:
    #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(id, iLevel, iCid)
    {
        if(!cmd_access(id, iLevel, iCid, 2))
        {
            return PLUGIN_HANDLED
        }
    
        new szArg[32], szTarget[32]
        read_argv(1, szArg, charsmax(szArg))
    
        new iPlayers[32], iPnum = cmd_targetex(id, szArg, iPlayers, szTarget, charsmax(szTarget), TARGETEX_OBEY_IMM_SINGLE)
    
        if(!iPnum)
        {
            return PLUGIN_HANDLED
        }
        
        for(new i; i < iPnum; i++)
        {
            user_slap(iPlayers[i], 0)
        }
    
        new szName[32]
        get_user_name(id, szName, charsmax(szName))
        client_print(0, print_chat, "ADMIN %s slapped %s", szName, szTarget)
        return PLUGIN_HANDLED
    }
  • Example usage:
    • test_slap @me
    • test_slap all
    • test_slap OciXCrom
    • test_slap "STEAM_ID"
    • test_slap #userid
    • test_slap @!alivect

DOWNLOAD
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу