Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <fakemeta>
- #define PLUGIN_VERSION "1.1"
- #define CMD_MULTI -69
- new Trie:g_tArgs
- public plugin_init()
- {
- register_plugin("Command Targeting Plus", PLUGIN_VERSION, "OciXCrom")
- register_cvar("CRXCMDTarget", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
- g_tArgs = TrieCreate()
- ReadFile()
- }
- public plugin_end()
- TrieDestroy(g_tArgs)
- ReadFile()
- {
- new szConfigsName[256], szFilename[256]
- get_configsdir(szConfigsName, charsmax(szConfigsName))
- formatex(szFilename, charsmax(szFilename), "%s/CMDTargetPlus.ini", szConfigsName)
- new iFilePointer = fopen(szFilename, "rt")
- if(iFilePointer)
- {
- new szData[64], szCommand[60], szArg[3]
- while(!feof(iFilePointer))
- {
- fgets(iFilePointer, szData, charsmax(szData)); trim(szData)
- switch(szData[0])
- {
- case EOS, ';', '/': continue
- default:
- {
- parse(szData, szCommand, charsmax(szCommand), szArg, charsmax(szArg))
- TrieSetCell(g_tArgs, szCommand, szArg[0] == EOS ? 1 : str_to_num(szArg))
- register_concmd(szCommand, "OnCommand")
- szArg[0] = EOS
- }
- }
- }
- fclose(iFilePointer)
- }
- }
- public OnCommand(id)
- {
- new szCmd[32], szArg[32], iArgNum
- read_argv(0, szCmd, charsmax(szCmd))
- TrieGetCell(g_tArgs, szCmd, iArgNum)
- read_argv(iArgNum, szArg, charsmax(szArg))
- if(szArg[0] == '@')
- {
- new szFullCmd[128]
- read_args(szFullCmd, charsmax(szFullCmd))
- format(szFullCmd, charsmax(szFullCmd), "%s %s", szCmd, szFullCmd)
- if(is_this_command(id, szArg, "aim", false, false))
- {
- new iPlayer, iBody
- get_user_aiming(id, iPlayer, iBody)
- if(iPlayer) { do_cmd_by_index(id, iPlayer, szFullCmd, szArg); }
- }
- else if(is_this_command(id, szArg, "spectating", false, false))
- {
- new iPlayer = pev(id, pev_iuser2)
- if(iPlayer) { do_cmd_by_index(id, iPlayer, szFullCmd, szArg); }
- }
- else if(is_this_command(id, szArg, "alive", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "a"); }
- else if(is_this_command(id, szArg, "alivect", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "ae", "CT"); }
- else if(is_this_command(id, szArg, "alivet", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "ae", "TERRORIST"); }
- else if(is_this_command(id, szArg, "all", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg); }
- else if(is_this_command(id, szArg, "bots", false, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "d"); }
- else if(is_this_command(id, szArg, "ct", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "e", "CT"); }
- else if(is_this_command(id, szArg, "dead", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "b"); }
- else if(is_this_command(id, szArg, "deadct", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "be", "CT"); }
- else if(is_this_command(id, szArg, "deadt", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "be", "T"); }
- else if(is_this_command(id, szArg, "humans", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "ch"); }
- else if(is_this_command(id, szArg, "me", false, false)) { do_cmd_by_index(id, id, szFullCmd, szArg); }
- else if(is_this_command(id, szArg, "spec", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "e", "SPECTATOR"); }
- else if(is_this_command(id, szArg, "t", true, true)) { do_cmd_by_index(id, CMD_MULTI, szFullCmd, szArg, "e", "TERRORIST"); }
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- do_cmd_by_index(id, iPlayer, szCmd[], szArg[], szFlags[] = "", szTeam[] = "")
- {
- if(iPlayer == CMD_MULTI)
- {
- new iPlayers[32], iPnum, bool:bNoSelf = szArg[1] == '!'
- get_players(iPlayers, iPnum, szFlags, szTeam)
- for(new i, iPlayer; i < iPnum; i++)
- {
- iPlayer = iPlayers[i]
- if(id == iPlayer && bNoSelf)
- continue
- create_and_execute(id, iPlayer, szCmd, szArg)
- }
- }
- else create_and_execute(id, iPlayer, szCmd, szArg)
- }
- create_and_execute(id, iPlayer, szCmd[], szArg[])
- {
- new szFullCmd[128], szId[16]
- copy(szFullCmd, charsmax(szFullCmd), szCmd)
- formatex(szId, charsmax(szId), "#%i", get_user_userid(iPlayer))
- replace(szFullCmd, charsmax(szFullCmd), szArg, szId)
- client_cmd(id, szFullCmd)
- }
- bool:is_this_command(id, szArg[], szCommand[], bool:bNoSelf, bool:bAllowServer)
- {
- if(!bAllowServer && !is_user_connected(id))
- return false
- return (equali(szArg[1], szCommand) || (bNoSelf && szArg[1] == '!' && equali(szArg[2], szCommand)))
- }
Add Comment
Please, Sign In to add comment