Aliases (amx plugin)

Od HLDS.pl
Skocz do: nawigacji, wyszukiwania

Spis treści

Opis

Plugin pozwala na zdefiniowanie aliasów komend dla graczy adminów oraz komend w konsoli serwera (np poprez rcon) Dzięki nim zaoszczędzimy pisania długich komend.

Więcej o dodatku niżej, w opisie w nagłówku pliku .sma, oraz przykłady aliasów w pliku aliases.cfg

Jeśli skorzystacie z podanych aliases.cfg to poniżej przykłady komend (uwaga, komendy zależą od praw admina)

  • atb 0/1 - ustawia auto team balance
  • lv nazwa_mapy - zmienia mapę :)
  • lv2 nazwa_mapy wymusza u graczy ponowne podłączenie się do serwera oraz załadowanie mapy (wymagany plugin clexec w zmodyfikowanej wersji)
  • fcc 0/1/2 - ustawia force chase cam
  • ff 0/1 - ustawia friendly fire
  • ftp 0/1 - ustawia fade to black
  • mr <numer> - ustawia max rounds
  • nm nazwa_mapy - ustawia nextmap, zamiast pisac amx_rcon amx_nextmap nazwa_mapy (albo zamiast amx_rcon amx_cvar), piszemy: nm nazwa_mapy
  • pw haslo - ustawia hasło ans serwerze
  • pwr <numer> - jeśli masz plugin amx_rndpass generuje na serwerze losowe hasło oz danej długości znaków
  • rl <numer> - ustawia round limit, maxrounds
  • rr - restart rundy, jak sv_restart 1
  • rr3 - trzy restarty, ale ja uzywam amx_rr 3 :)
  • tkp 0/1 - ustawia teammate kill punishment
  • tl <numer> - ustawia time limit, limit czasu mapy - kiedyś problemem było wpisanie pod sam koniec mapy podczas odliczania amx_cvar mp_timelimit 0 - teraz starczą 4 znaki : tl 0
  • cfg nazwa_pliku - wykonuje plik konfiga
  • st - jesli masz swap teams , zmieni drużyny miejscami
  • money <numer> - ustawia ilość kasy na starcie
  • cash <numer> - podobnie jak money
  • say_lo3 - wyświetla komunikat ze zaraz restarty
  • lo3 - wykona w rzeczywistości say_lo3 oraz rr3 - czyli wyświetli napis i 3 resy


Aliasy do konsoli serwera, np w rconie poprzez hlsw

  • lvl nazwa_mapy - zmiana mapy, zamiast changelevel , uzyteczne jak nie siedzimy poprzez HLSW ale inny program rcon
  • m nazwa_mapy - zmiana mapy z kickniecie graczy
  • nlvl - zmana mapy na mape zdefiniwoana w amx_nextmap (albo ogolnie z mapcycle), w rzeczywistosci zadzial po pierwszej minucie od startu rozgrywki, bo zmienia mp_timelimit na 1
  • cpu - wystwietla statystyki obciazenia serwera, czyli stats

Oczywisice mozna dodawac swoje aliasy, aliasy sa tez widoczne w komendach amx_help

Instalacja

  • Skopiowac zawartość aliases.sma i wkleić do addons/amxmodx/scripting/aliases.sma
  • skompilowac plugin, plik wynikowy z amxmodx/compiled/aliases.amxx wrzucic do amxmodx/plugins/
  • dodać do amxmodx/plugins.ini na dole (albo w innym ulubionym mijescu) linijkę
aliases.amxx
  • stworzyć plik amxmodx/aliases.cfg i wkleić do niego zawartośc z aliases.cfg
  • po zmianie mapy plugin sam powinen załadowac plik cfg i aliasy powinny działać.

aliases.sma

/* AMX Mod script. 
* 
* Command Aliasing 
*  by JustinHoMi 
* 
* This script is intended to mimic clanmod-style aliasing (cm_alias) 
* 
* Usage: amx_alias "alias" "command" flags 
* 
 
Allows you to set aliases for server commands. It allows you to alias rcon or client commands. This plugin is intended to behave like clanmod-style aliasing. It allows you to ease into using amx from adminmod or clanmod. 
 
Use: amx_alias "alias" "command" <level and flags> 
 
The admin level must be specified first, and then the flags. The only currently available flag is "l", which runs the specified command on the admin who calls the alias. 
 
Place aliases in moddir/addons/amxmodx/configs/aliases.cfg 
 
Examples: 
 
amx_alias "admin_map" "amx_map" Fl 
amx_alias "cl" "changelevel" F 
amx_alias "rr" "sv_restart 1" G 
 
As you can see, client-side commands require the "l" flag, whereas rcon commands do not. F is the flag for ADMIN_MAP and G is the flag for ADMIN_CVAR. More examples are included in the post. 
 
PS Note that "l" is "L". 
 
amx_alias "admin_map" "amx_map" Fl 
amx_alias "admin_kick" "amx_kick" Cl 
amx_alias "admin_ban" "amx_ban" Dl 
amx_alias "admin_help" "amx_help" Bl 
 
amx_alias "clanmodmenu" "amx_menu" Bl 
amx_alias "cl" "changelevel" F 
amx_alias "rr" "sv_restartround 1" G 
amx_alias "rr3" "sv_restart 1;sv_restart 4;sv_restart 7" G 
amx_alias "tl" "mp_timelimit" G 
amx_alias "fcc" "mp_forcechasecam" G 
amx_alias "ftb" "mp_fadetoblack" G 
amx_alias "tkp" "mp_tkpunish" G 
amx_alias "ff" "mp_friendlyfire" G 
amx_alias "atb" "mp_autoteambalance" G 
amx_alias "pw" "sv_password" K 
amx_alias "cm" " " L 
amx_alias "cm_bury" "amx_bury" Il 
amx_alias "cm_unbury" "amx_unbury" Il 
 
*/ 
 
#include <amxmodx> 
#include <amxmisc>
 
#define MAX_ALIASES 128      // max num of aliases to load 
 
new alias[MAX_ALIASES][32] 
new cmds[MAX_ALIASES][32] 
new cflags[MAX_ALIASES][5]   // cmd flags 
new uflags[MAX_ALIASES]      // user flags 
new anum = 0 
new g_aliasesFile[64]
// load and register the alias 
public admin_alias(){ 
   read_argv(1,alias[anum],31) 
   read_argv(2,cmds[anum],31) 
   read_argv(3,cflags[anum],31) 
 
   // seperate user flag and cmd flags 
   new user_flags[6] 
   format(user_flags,2,"%c",tolower(cflags[anum][0])) 
   uflags[anum] = read_flags(user_flags) 
   copy(user_flags,5,cflags[anum]) 
 
   // get the description of the original command 
   new cflag,ccmd[32],cinfo[64],description[64] 
   new cmdn = get_concmdsnum(-1) 
   for(new i=0;i<cmdn;i++) 
   { 
         get_concmd(i,ccmd,31,cflag,cinfo,63,-1) 
         if (equal(cmds[anum],ccmd)) 
      { 
         copy(description,63,cinfo) 
         i=500 // break out of the loop 
      } 
   } 
 
   // replace the name of the original cmd with the name of the alias in the desc 
   new tmp[32] 
   format(tmp,31,"%s ",alias[anum]) 
   replace(description,63,ccmd,tmp); 
 
   // fix for when registered commands have no description 
   if (contain(ccmd,description)!=-1) 
      copy(description,31,alias[anum]) 
 
   // if it's a server-side cmd then it won't have a desc, so just show the cmd it aliases 
   new   desc[32] 
   if (description[0]) 
      format(desc,63,"%s",description) 
   else 
      format(desc,31,"%s (%s)",alias[anum],cmds[anum]) 
 
   // and we register the command with proper flags and description 
   register_concmd(alias[anum],"alias_run",uflags[anum],desc) 
//   server_print("[AMXX] Alias ^"%s^" added",alias[anum]) 
   log_message("[AMXX] Alias ^"%s^" added",alias[anum])
   anum++ 
 
   return PLUGIN_CONTINUE 
} 
 
// run the alias 
public alias_run(id){ 
   new thecmd[32] 
   read_argv(0,thecmd,32)                        // the name of the alias 
   new args[64] 
   read_args(args,64)                            // read the rest of the args 
 
   for (new i=0; i<anum; i++)                     // cycle through the stored aliases 
   { 
      if (equal(thecmd,alias[i]))                // if called alias == stored alias 
      { 
         if (get_user_flags(id)&uflags[i])         // compare user flags 
         { 
            new command[64] 
            format(command,63,"%s %s",cmds[i],args)   // put the new command and the args together 
            if (contain(cflags[i],"l") != -1)      // client command 
               client_cmd(id,command) 
            else                           // server command 
               server_cmd("%s",command) 
         } 
         else client_print(id,print_console,"[AMXX] You do not have access to this command") 
      } 
   } 
 
   return PLUGIN_HANDLED 
} 
 
public plugin_init() 
{ 
   register_plugin("Command Aliases","0.8","JustinHoMi") 
   register_srvcmd("amx_alias","admin_alias")    
   get_configsdir(g_aliasesFile, 63)
   format(g_aliasesFile, 63, "%s/aliases.cfg", g_aliasesFile) 
   server_cmd("exec ^"%s^"", g_aliasesFile)
//   server_cmd("exec addons/amxmodx/configs/aliases.cfg") 
   return PLUGIN_CONTINUE 
}

aliases.cfg

amx_alias "atb" "mp_autoteambalance" G 
amx_alias "lv" "amx_map" Fl 
amx_alias "lv2" "amx_clexec2 * retry;amx_map" Fl 
amx_alias "fcc" "mp_forcechasecam" G 
amx_alias "ff" "mp_friendlyfire" G 
amx_alias "ftb" "mp_fadetoblack" G 
amx_alias "mr" "mp_maxrounds" G 
amx_alias "nm" "amx_nextmap" F 
amx_alias "pw" "sv_password" K 
amx_alias "pwr" "amx_rndpass" Kl 
amx_alias "rl" "mp_maxrounds" G 
amx_alias "rr" "sv_restart 1" G 
amx_alias "rr" "sv_restartround 1" G 
amx_alias "rr3" "sv_restart 1;sv_restart 4;sv_restart 7" G
amx_alias "tkp" "mp_tkpunish" G 
amx_alias "tl" "mp_timelimit" G 
amx_alias "cfg" "amx_rcon exec" Ll 
amx_alias "st" "amx_swapteams" Ll 
amx_alias "money" "amx_cvar mp_startmoney" Ll 
amx_alias "cash" "amx_cvar mp_startmoney" Ll 
amx_alias "say_lo3" "amx_tsay green 3 Restarts" G 
amx_alias "lo3" "say_lo3;rr3" G
 
//hlds console specific aliases
amx_alias "lvl" "changelevel" F
amx_alias "m" "map" F
amx_alias "nlvl" "mp_timelimit 1" F
amx_alias "cpu" "stats" G
Osobiste
Przestrzenie nazw
Warianty
Działania
HLDS.pl - Menu:
Inne
IRC
Inne sekcje:
Znajomi:
Narzędzia