[Half-Life AMXX] / admincmd.sma Repository:
ViewVC logotype

Diff of /admincmd.sma

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 16, Fri Nov 16 15:12:40 2007 UTC revision 17, Fri Nov 16 15:29:57 2007 UTC
# Line 35  Line 35 
35  #include <amxmodx>  #include <amxmodx>
36  #include <amxmisc>  #include <amxmisc>
37    
38  #define MAXRCONCVARS 16  // This is not a dynamic array because it would be bad for 24/7 map servers.
39    #define OLD_CONNECTION_QUEUE 10
40    
 new g_cvarRcon[MAXRCONCVARS][32]  
 new g_cvarRconNum  
41  new g_pauseCon  new g_pauseCon
42  new Float:g_pausAble  new Float:g_pausAble
43  new bool:g_Paused  new bool:g_Paused
44  new bool:g_PauseAllowed = false  new bool:g_PauseAllowed = false
45  new g_addCvar[] = "amx_cvar add %s"  new g_addCvar[] = "amx_cvar add %s"
46    
47    new pausable;
48    new rcon_password;
49    
50    // Old connection queue
51    new g_Names[OLD_CONNECTION_QUEUE][32];
52    new g_SteamIDs[OLD_CONNECTION_QUEUE][32];
53    new g_IPs[OLD_CONNECTION_QUEUE][32];
54    new g_Access[OLD_CONNECTION_QUEUE];
55    new g_Tracker;
56    new g_Size;
57    
58    stock InsertInfo(id)
59    {
60    
61            // Scan to see if this entry is the last entry in the list
62            // If it is, then update the name and access
63            // If it is not, then insert it again.
64    
65            if (g_Size > 0)
66            {
67                    new ip[32]
68                    new auth[32];
69    
70                    get_user_authid(id, auth, charsmax(auth));
71                    get_user_ip(id, ip, charsmax(ip), 1/*no port*/);
72    
73                    new last = 0;
74    
75                    if (g_Size < sizeof(g_SteamIDs))
76                    {
77                            last = g_Size - 1;
78                    }
79                    else
80                    {
81                            last = g_Tracker - 1;
82    
83                            if (last < 0)
84                            {
85                                    last = g_Size - 1;
86                            }
87                    }
88    
89                    if (equal(auth, g_SteamIDs[last]) &&
90                            equal(ip, g_IPs[last])) // need to check ip too, or all the nosteams will while it doesn't work with their illegitimate server
91                    {
92                            get_user_name(id, g_Names[last], charsmax(g_Names[]));
93                            g_Access[last] = get_user_flags(id);
94    
95                            return;
96                    }
97            }
98    
99            // Need to insert the entry
100    
101            new target = 0;  // the slot to save the info at
102    
103            // Queue is not yet full
104            if (g_Size < sizeof(g_SteamIDs))
105            {
106                    target = g_Size;
107    
108                    ++g_Size;
109    
110            }
111            else
112            {
113                    target = g_Tracker;
114    
115                    ++g_Tracker;
116                    // If we reached the end of the array, then move to the front
117                    if (g_Tracker == sizeof(g_SteamIDs))
118                    {
119                            g_Tracker = 0;
120                    }
121            }
122    
123            get_user_authid(id, g_SteamIDs[target], charsmax(g_SteamIDs[]));
124            get_user_name(id, g_Names[target], charsmax(g_Names[]));
125            get_user_ip(id, g_IPs[target], charsmax(g_IPs[]), 1/*no port*/);
126    
127            g_Access[target] = get_user_flags(id);
128    
129    }
130    stock GetInfo(i, name[], namesize, auth[], authsize, ip[], ipsize, &access)
131    {
132            if (i >= g_Size)
133            {
134                    abort(AMX_ERR_NATIVE, "GetInfo: Out of bounds (%d:%d)", i, g_Size);
135            }
136    
137            new target = (g_Tracker + i) % sizeof(g_SteamIDs);
138    
139            copy(name, namesize, g_Names[target]);
140            copy(auth, authsize, g_SteamIDs[target]);
141            copy(ip,   ipsize,   g_IPs[target]);
142            access = g_Access[target];
143    
144    }
145    public client_disconnect(id)
146    {
147            if (!is_user_bot(id))
148            {
149                    InsertInfo(id);
150            }
151    }
152    
153  public plugin_init()  public plugin_init()
154  {  {
155          register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team")          register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team")
156    
157          register_dictionary("admincmd.txt")          register_dictionary("admincmd.txt")
158          register_dictionary("common.txt")          register_dictionary("common.txt")
159            register_dictionary("adminhelp.txt")
160    
161    
162          register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")          register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")
163          register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]")          register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
164          register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]")          register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
165          register_concmd("amx_addban", "cmdAddBan", ADMIN_RCON, "<authid or ip> <minutes> [reason]")          register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<^"authid^" or ip> <minutes> [reason]")
166          register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<authid or ip>")          register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<^"authid^" or ip>")
167          register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")          register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")
168          register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]")          register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]")
169          register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]")          register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]")
# Line 66  Line 175 
175          register_concmd("amx_map", "cmdMap", ADMIN_MAP, "<mapname>")          register_concmd("amx_map", "cmdMap", ADMIN_MAP, "<mapname>")
176          register_concmd("amx_cfg", "cmdCfg", ADMIN_CFG, "<filename>")          register_concmd("amx_cfg", "cmdCfg", ADMIN_CFG, "<filename>")
177          register_concmd("amx_nick", "cmdNick", ADMIN_SLAY, "<name or #userid> <new nick>")          register_concmd("amx_nick", "cmdNick", ADMIN_SLAY, "<name or #userid> <new nick>")
178            register_concmd("amx_last", "cmdLast", ADMIN_BAN, "- list the last few disconnected clients info");
179          register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")          register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")
180          register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>")          register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>")
181          register_clcmd("pauseAck", "cmdLBack")          register_clcmd("pauseAck", "cmdLBack")
182    
183    
184            rcon_password=get_cvar_pointer("rcon_password");
185            pausable=get_cvar_pointer("pausable");
186    
187    
188  }  }
189    
190  public plugin_cfg()  public plugin_cfg()
# Line 82  Line 198 
198          server_cmd(g_addCvar, "amx_reserved_slots")          server_cmd(g_addCvar, "amx_reserved_slots")
199          server_cmd(g_addCvar, "amx_reservation")          server_cmd(g_addCvar, "amx_reservation")
200          server_cmd(g_addCvar, "amx_conmotd_file")          server_cmd(g_addCvar, "amx_conmotd_file")
201            server_cmd(g_addCvar, "amx_sql_table");
202            server_cmd(g_addCvar, "amx_sql_host");
203            server_cmd(g_addCvar, "amx_sql_user");
204            server_cmd(g_addCvar, "amx_sql_pass");
205            server_cmd(g_addCvar, "amx_sql_db");
206            server_cmd(g_addCvar, "amx_sql_type");
207    
208  }  }
209    
210  public cmdKick(id, level, cid)  public cmdKick(id, level, cid)
# Line 91  Line 214 
214    
215          new arg[32]          new arg[32]
216          read_argv(1, arg, 31)          read_argv(1, arg, 31)
217          new player = cmd_target(id, arg, 1)          new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
218    
219          if (!player)          if (!player)
220                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 108  Line 231 
231    
232          log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)          log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)
233    
234          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_2", name, name2)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_1", name2)  
         }  
235    
236          if (is_user_bot(player))          if (is_user_bot(player))
237                  server_cmd("kick #%d", userid2)                  server_cmd("kick #%d", userid2)
# Line 149  Line 268 
268    
269          get_user_name(id, name, 31)          get_user_name(id, name, 31)
270    
271          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_2", name, arg)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_1", arg)  
         }  
272    
273          get_user_authid(id, authid, 31)          get_user_authid(id, authid, 31)
274          log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)          log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)
# Line 161  Line 276 
276          return PLUGIN_HANDLED          return PLUGIN_HANDLED
277  }  }
278    
279    /* amx_addban is a special command now.
280     * If a user with rcon uses it, it bans the user.  No questions asked.
281     * If a user without rcon but with ADMIN_BAN uses it, it will scan the old
282     * connection queue, and if it finds the info for a player in it, it will
283     * check their old access.  If they have immunity, it will not ban.
284     * If they do not have immunity, it will ban.  If the user is not found,
285     * it will refuse to ban the target.
286     */
287    
288  public cmdAddBan(id, level, cid)  public cmdAddBan(id, level, cid)
289  {  {
290          if (!cmd_access(id, level, cid, 3))          if (!cmd_access(id, level, cid, 3, true)) // check for ADMIN_BAN access
291                  return PLUGIN_HANDLED          {
292                    if (get_user_flags(id) & level) // Getting here means they didn't input enough args
293                    {
294                            return PLUGIN_HANDLED;
295                    }
296                    if (!cmd_access(id, ADMIN_RCON, cid, 3)) // If somehow they have ADMIN_RCON without ADMIN_BAN, continue
297                    {
298                            return PLUGIN_HANDLED;
299                    }
300            }
301    
302          new arg[32], authid[32], name[32], minutes[32], reason[32]          new arg[32], authid[32], name[32], minutes[32], reason[32]
303    
# Line 172  Line 305 
305          read_argv(2, minutes, 31)          read_argv(2, minutes, 31)
306          read_argv(3, reason, 31)          read_argv(3, reason, 31)
307    
308    
309            if (!(get_user_flags(id) & ADMIN_RCON))
310            {
311                    new bool:canban = false;
312                    new bool:isip = false;
313                    // Limited access to this command
314                    if (equali(arg, "STEAM_ID_PENDING") ||
315                            equali(arg, "STEAM_ID_LAN") ||
316                            equali(arg, "HLTV") ||
317                            equali(arg, "4294967295") ||
318                            equali(arg, "VALVE_ID_LAN") ||
319                            equali(arg, "VALVE_ID_PENDING"))
320                    {
321                            // Hopefully we never get here, so ML shouldn't be needed
322                            console_print(id, "Cannot ban %s", arg);
323                            return PLUGIN_HANDLED;
324                    }
325    
326                    if (contain(arg, ".") != -1)
327                    {
328                            isip = true;
329                    }
330    
331                    // Scan the disconnection queue
332                    if (isip)
333                    {
334                            new IP[32];
335                            new Name[32];
336                            new dummy[1];
337                            new Access;
338                            for (new i = 0; i < g_Size; i++)
339                            {
340                                    GetInfo(i, Name, charsmax(Name), dummy, 0, IP, charsmax(IP), Access);
341    
342                                    if (equal(IP, arg))
343                                    {
344                                            if (Access & ADMIN_IMMUNITY)
345                                            {
346                                                    console_print(id, "[AMXX] %s : %L", IP, id, "CLIENT_IMM", Name);
347    
348                                                    return PLUGIN_HANDLED;
349                                            }
350                                            // User did not have immunity
351                                            canban = true;
352                                    }
353                            }
354                    }
355                    else
356                    {
357                            new Auth[32];
358                            new Name[32];
359                            new dummy[1];
360                            new Access;
361                            for (new i = 0; i < g_Size; i++)
362                            {
363                                    GetInfo(i, Name, charsmax(Name), Auth, charsmax(Auth), dummy, 0, Access);
364    
365                                    if (equal(Auth, arg))
366                                    {
367                                            if (Access & ADMIN_IMMUNITY)
368                                            {
369                                                    console_print(id, "[AMXX] %s : %L", Auth, id, "CLIENT_IMM", Name);
370    
371                                                    return PLUGIN_HANDLED;
372                                            }
373                                            // User did not have immunity
374                                            canban = true;
375                                    }
376                            }
377                    }
378    
379                    if (!canban)
380                    {
381                            console_print(id, "[AMXX] You may only ban recently disconnected clients.  Use ^"amx_last^" to view.");
382    
383                            return PLUGIN_HANDLED;
384                    }
385    
386            }
387    
388            // User has access to ban their target
389          if (contain(arg, ".") != -1)          if (contain(arg, ".") != -1)
390          {          {
391                  server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, arg)                  server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, arg)
# Line 183  Line 397 
397    
398          get_user_name(id, name, 31)          get_user_name(id, name, 31)
399    
400          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_2", name, arg)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_1", arg)  
         }  
401    
402          get_user_authid(id, authid, 31)          get_user_authid(id, authid, 31)
403          log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)          log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)
# Line 206  Line 416 
416          read_argv(2, minutes, 7)          read_argv(2, minutes, 7)
417          read_argv(3, reason, 63)          read_argv(3, reason, 63)
418    
419          new player = cmd_target(id, target, 9)          new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
420    
421          if (!player)          if (!player)
422                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 234  Line 444 
444          else          else
445                  server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)                  server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)
446    
         new activity = get_cvar_num("amx_show_activity")  
         if (activity != 0)  
         {  
                 new players[32], pnum, msg[256], len  
                 get_players(players, pnum, "c")  
   
                 for (new i = 0; i < pnum; i++)  
                 {  
                         len = format(msg, 255, "%L", players[i], "ADMIN")  
   
                         if (activity == 1)  
                                 len += copy(msg[len], 255-len, ":")  
                         else  
                                 len += format(msg[len], 255-len, " %s:", name)  
447    
448                          len += format(msg[len], 255-len, " %L", players[i], "BAN")          // Display the message to all clients
                         len += format(msg[len], 255-len, " %s ", name2)  
449    
450            new msg[256];
451            new len;
452            new maxpl = get_maxplayers();
453            for (new i = 1; i <= maxpl; i++)
454            {
455                    if (is_user_connected(i) && !is_user_bot(i))
456                    {
457                            len = formatex(msg, charsmax(msg), "%L", i, "BAN");
458                            len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
459                          if (nNum)                          if (nNum)
460                                  format(msg[len], 255-len, "%L", players[i], "FOR_MIN", minutes)                          {
461                                    formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
462                            }
463                          else                          else
464                                  format(msg[len], 255-len, "%L", players[i], "PERM")                          {
465                                    formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
                         client_print(players[i], print_chat, "%s", msg)  
466                  }                  }
467                            if (strlen(reason) > 0)
468                            {
469                                    formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
470          }          }
471                            show_activity_id(i, id, name, msg);
472                    }
473            }
474    
475          console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)          console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
476    
477          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 276  Line 488 
488          read_argv(2, minutes, 7)          read_argv(2, minutes, 7)
489          read_argv(3, reason, 63)          read_argv(3, reason, 63)
490    
491          new player = cmd_target(id, target, 9)          new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
492    
493          if (!player)          if (!player)
494            {
495                    // why is this here?
496                    player = cmd_target(id, target, 9);
497                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
498            }
499    
500          new authid[32], name2[32], authid2[32], name[32]          new authid[32], name2[32], authid2[32], name[32]
501          new userid2 = get_user_userid(player)          new userid2 = get_user_userid(player)
# Line 306  Line 522 
522          else          else
523                  server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)                  server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)
524    
525          new activity = get_cvar_num("amx_show_activity")          // Display the message to all clients
         if (activity != 0)  
         {  
                 new players[32], pnum, msg[256], len  
                 get_players(players, pnum, "c")  
526    
527                  for (new i = 0; i < pnum; i++)          new msg[256];
528            new len;
529            new maxpl = get_maxplayers();
530            for (new i = 1; i <= maxpl; i++)
531                  {                  {
532                          len = format(msg, 255, "%L", players[i], "ADMIN")                  if (is_user_connected(i) && !is_user_bot(i))
533                    {
534                          if (activity == 1)                          len = formatex(msg, charsmax(msg), "%L", i, "BAN");
535                                  len += copy(msg[len], 255-len, ":")                          len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
                         else  
                                 len += format(msg[len], 255-len, " %s:", name)  
   
                         len += format(msg[len], 255-len, " %L", players[i], "BAN")  
                         len += format(msg[len], 255-len, " %s ", name2)  
   
536                          if (nNum)                          if (nNum)
537                                  format(msg[len], 255-len, "%L", players[i], "FOR_MIN", minutes)                          {
538                                    formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes);
539                            }
540                          else                          else
541                                  format(msg[len], 255-len, "%L", players[i], "PERM")                          {
542                                    formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM");
543                          client_print(players[i], print_chat, "%s", msg)                          }
544                            if (strlen(reason) > 0)
545                            {
546                                    formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason);
547                  }                  }
548                            show_activity_id(i, id, name, msg);
549          }          }
550            }
551    
552          console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)          console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
553    
554          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 346  Line 563 
563    
564          read_argv(1, arg, 31)          read_argv(1, arg, 31)
565    
566          new player = cmd_target(id, arg, 5)          new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
567    
568          if (!player)          if (!player)
569                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 362  Line 579 
579    
580          log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)          log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
581    
582          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2);
583          {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_2", name, name2)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_1", name2)  
         }  
584          console_print(id, "[AMXX] %L", id, "CLIENT_SLAYED", name2)          console_print(id, "[AMXX] %L", id, "CLIENT_SLAYED", name2)
585    
586          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 380  Line 594 
594          new arg[32]          new arg[32]
595    
596          read_argv(1, arg, 31)          read_argv(1, arg, 31)
597          new player = cmd_target(id, arg, 5)          new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
598    
599          if (!player)          if (!player)
600                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 400  Line 614 
614    
615          log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, damage, name2, get_user_userid(player), authid2)          log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, damage, name2, get_user_userid(player), authid2)
616    
617          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, damage);
618          {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_2", name, name2, damage)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_1", name2, damage)  
         }  
619          console_print(id, "[AMXX] %L", id, "CLIENT_SLAPED", name2, damage)          console_print(id, "[AMXX] %L", id, "CLIENT_SLAPED", name2, damage)
620    
621          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 434  Line 645 
645          get_user_authid(id, authid, 31)          get_user_authid(id, authid, 31)
646          get_user_name(id, name, 31)          get_user_name(id, name, 31)
647    
648          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_MAP_1", "ADMIN_MAP_2", name, arg);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_2", name, arg)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_1", arg)  
         }  
649    
650          log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg)          log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg)
651    
# Line 456  Line 663 
663          return PLUGIN_HANDLED          return PLUGIN_HANDLED
664  }  }
665    
666  onlyRcon(name[])  stock bool:onlyRcon(const name[])
667    {
668            new ptr=get_cvar_pointer(name);
669            if (ptr && get_pcvar_flags(ptr) & FCVAR_PROTECTED)
670  {  {
671          for (new a = 0; a < g_cvarRconNum; ++a)                  return true;
672                  if (equali(g_cvarRcon[a], name))          }
673                          return 1          return false;
         return 0  
674  }  }
675    
676  public cmdCvar(id, level, cid)  public cmdCvar(id, level, cid)
# Line 474  Line 683 
683          read_argv(1, arg, 31)          read_argv(1, arg, 31)
684          read_argv(2, arg2, 63)          read_argv(2, arg2, 63)
685    
686            new pointer;
687    
688          if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))          if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))
689          {          {
690                  if (cvar_exists(arg2))                  if ((pointer=get_cvar_pointer(arg2))!=0)
691                  {                  {
692                          if (g_cvarRconNum < MAXRCONCVARS)                          new flags=get_pcvar_flags(pointer);
693                                  copy(g_cvarRcon[g_cvarRconNum++], 31, arg2)  
694                          else                          if (!(flags & FCVAR_PROTECTED))
695                                  console_print(id, "[AMXX] %L", id, "NO_MORE_CVARS")                          {
696                                    set_pcvar_flags(pointer,flags | FCVAR_PROTECTED);
697                            }
698                  }                  }
699                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
700          }          }
701    
702          if (!cvar_exists(arg))          if ((pointer=get_cvar_pointer(arg))==0)
703          {          {
704                  console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg)                  console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg)
705                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 494  Line 707 
707    
708          if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON))          if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON))
709          {          {
710                  console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")                  // Exception for the new onlyRcon rules:
711                  return PLUGIN_HANDLED                  //   sv_password is allowed to be modified by ADMIN_PASSWORD
712          }                  if (!(equali(arg,"sv_password") && (get_user_flags(id) & ADMIN_PASSWORD)))
         else if (equal(arg, "sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD))  
713          {          {
714                  console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")                  console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
715                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
716          }          }
717            }
718    
719          if (read_argc() < 3)          if (read_argc() < 3)
720          {          {
721                  get_cvar_string(arg, arg2, 63)                  get_pcvar_string(pointer, arg2, 63)
722                  console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)                  console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)
723                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
724          }          }
# Line 518  Line 731 
731          log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2)          log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2)
732          set_cvar_string(arg, arg2)          set_cvar_string(arg, arg2)
733    
         new activity = get_cvar_num("amx_show_activity")  
         if (activity != 0)  
         {  
                 new players[32], pnum, admin[64], cvar_val[64], len  
                 get_players(players, pnum, "c")  
   
                 for (new i = 0; i < pnum; i++)  
                 {  
                         len = format(admin, 255, "%L", players[i], "ADMIN")  
734    
735                          if (activity == 1)          // Display the message to all clients
                                 len += copy(admin[len], 255-len, ":")  
                         else  
                                 len += format(admin[len], 255-len, " %s:", name)  
736    
737                          if (equal(arg, "rcon_password") || equal(arg, "sv_password"))          new cvar_val[64];
738                                  format(cvar_val, 63, "*** %L ***", players[i], "PROTECTED")          new maxpl = get_maxplayers();
739            for (new i = 1; i <= maxpl; i++)
740            {
741                    if (is_user_connected(i) && !is_user_bot(i))
742                    {
743                            if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg, "rcon_password"))
744                            {
745                                    formatex(cvar_val, charsmax(cvar_val), "*** %L ***", i, "PROTECTED");
746                            }
747                          else                          else
748                                  copy(cvar_val, 63, arg2)                          {
749                                    copy(cvar_val, charsmax(cvar_val), arg2);
750                          client_print(players[i], print_chat, "%L", players[i], "SET_CVAR_TO", admin, arg, arg2)                          }
751                            show_activity_id(i, id, name, "%L", i, "SET_CVAR_TO", "", arg, cvar_val);
752                  }                  }
753          }          }
754    
755          console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)          console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)
756    
757          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 551  Line 762 
762          if (!cmd_access(id, level, cid, 1))          if (!cmd_access(id, level, cid, 1))
763                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
764    
765            if (id==0) // If server executes redirect this to "amxx plugins" for more in depth output
766            {
767                    server_cmd("amxx plugins");
768                    server_exec();
769                    return PLUGIN_HANDLED;
770            }
771    
772          new name[32], version[32], author[32], filename[32], status[32]          new name[32], version[32], author[32], filename[32], status[32]
773          new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]          new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
774    
# Line 560  Line 778 
778          format(lFile, 31, "%L", id, "FILE")          format(lFile, 31, "%L", id, "FILE")
779          format(lStatus, 31, "%L", id, "STATUS")          format(lStatus, 31, "%L", id, "STATUS")
780    
781            new StartPLID=0;
782            new EndPLID;
783    
784            new Temp[96]
785    
786          new num = get_pluginsnum()          new num = get_pluginsnum()
787    
788            if (read_argc() > 1)
789            {
790                    read_argv(1,Temp,sizeof(Temp)-1);
791                    StartPLID=str_to_num(Temp)-1; // zero-based
792            }
793    
794            EndPLID=min(StartPLID + 10, num);
795    
796          new running = 0          new running = 0
797    
798          console_print(id, "%L:", id, "LOADED_PLUGINS")          console_print(id, "----- %L -----", id, "LOADED_PLUGINS")
799          console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)          console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
800    
801          for (new i = 0; i <num; i++)          new i=StartPLID;
802            while (i <EndPLID)
803          {          {
804                  get_plugin(i, filename, 31, name, 31, version, 31, author, 31, status, 31)                  get_plugin(i++, filename, 31, name, 31, version, 31, author, 31, status, 31)
805                  console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)                  console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)
806    
807                  if (status[0]=='d' || status[0]=='r') // "debug" or "running"                  if (status[0]=='d' || status[0]=='r') // "debug" or "running"
808                          running++                          running++
809          }          }
810          console_print(id, "%L", id, "PLUGINS_RUN", num, running)          console_print(id, "%L", id, "PLUGINS_RUN", EndPLID-StartPLID, running)
811            console_print(id, "----- %L -----",id,"HELP_ENTRIES",StartPLID + 1,EndPLID,num);
812    
813            if (EndPLID < num)
814            {
815                    formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_MORE", EndPLID + 1);
816                    replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins");
817                    console_print(id,"%s",Temp);
818            }
819            else
820            {
821                    formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_BEGIN");
822                    replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins");
823                    console_print(id,"%s",Temp);
824            }
825    
826          return PLUGIN_HANDLED          return PLUGIN_HANDLED
827  }  }
# Line 585  Line 832 
832                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
833    
834          new name[32], version[32], author[32], status, sStatus[16]          new name[32], version[32], author[32], status, sStatus[16]
835          new lName[32], lVersion[32], lAuthor[32]          new lName[32], lVersion[32], lAuthor[32], lStatus[32];
836    
837          format(lName, 31, "%L", id, "NAME")          format(lName, 31, "%L", id, "NAME")
838          format(lVersion, 31, "%L", id, "VERSION")          format(lVersion, 31, "%L", id, "VERSION")
839          format(lAuthor, 31, "%L", id, "AUTHOR")          format(lAuthor, 31, "%L", id, "AUTHOR")
840            format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
841    
842          new num = get_modulesnum()          new num = get_modulesnum()
843    
844          console_print(id, "%L:", id, "LOADED_MODULES")          console_print(id, "%L:", id, "LOADED_MODULES")
845          console_print(id, "%-23.22s %-8.7s %-20.19s", lName, lVersion, lAuthor)          console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", lName, lVersion, lAuthor, lStatus)
846    
847          for (new i = 0; i < num; i++)          for (new i = 0; i < num; i++)
848          {          {
# Line 603  Line 851 
851                  switch (status)                  switch (status)
852                  {                  {
853                          case module_loaded: copy(sStatus, 15, "running")                          case module_loaded: copy(sStatus, 15, "running")
854                          default: copy(sStatus, 15, "error")                          default:
855                            {
856                                    copy(sStatus, 15, "bad load");
857                                    copy(name, charsmax(name), "unknown");
858                                    copy(author, charsmax(author), "unknown");
859                                    copy(version, charsmax(version), "unknown");
860                            }
861                  }                  }
862    
863                  console_print(id, "%-23.22s %-8.7s %-20.19s", name, version, author)                  console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", name, version, author, sStatus)
864          }          }
865          console_print(id, "%L", id, "NUM_MODULES", num)          console_print(id, "%L", id, "NUM_MODULES", num)
866    
# Line 637  Line 891 
891          console_print(id, "[AMXX] Executing file ^"%s^"", arg)          console_print(id, "[AMXX] Executing file ^"%s^"", arg)
892          server_cmd("exec %s", arg)          server_cmd("exec %s", arg)
893    
894          switch(get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_CONF_1", "ADMIN_CONF_2", name, arg);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_2", name, arg)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_1", arg)  
         }  
895    
896          return PLUGIN_HANDLED          return PLUGIN_HANDLED
897  }  }
# Line 675  Line 925 
925    
926          get_user_authid(id, authid, 31)          get_user_authid(id, authid, 31)
927          get_user_name(id, name, 31)          get_user_name(id, name, 31)
928          g_pausAble = get_cvar_float("pausable")          if (pausable!=0)
929            {
930                    g_pausAble = get_pcvar_float(pausable)
931            }
932    
933          if (!slayer)          if (!slayer)
934                  slayer = find_player("h")                  slayer = find_player("h")
# Line 694  Line 947 
947    
948          console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING")          console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING")
949    
950          new activity = get_cvar_num("amx_show_activity")          // Display the message to all clients
         if (activity != 0)  
         {  
                 new players[32], pnum, msg[128], len  
                 get_players(players, pnum, "c")  
951    
952                  for (new i = 0; i < pnum; i++)          new maxpl = get_maxplayers();
953            for (new i = 1; i <= maxpl; i++)
954                  {                  {
955                          len = format(msg, 127, "%L", players[i], "ADMIN")                  if (is_user_connected(i) && !is_user_bot(i))
956                    {
957                          if (activity == 1)                          show_activity_id(i, id, name, "%L server", i, g_Paused ? "UNPAUSE" : "PAUSE");
                                 len += copy(msg[len], 127-len, ": ")  
                         else  
                                 len += format(msg[len], 127-len, " %s: ", name)  
   
                         format(msg[len], 127-len, "%L", players[i], g_Paused ? "UNPAUSE" : "PAUSE")  
                         client_print(players[i], print_chat, "%s server", msg)  
958                  }                  }
959          }          }
960    
961          g_pauseCon = id          g_pauseCon = id
962    
963          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 725  Line 970 
970    
971          new password[64]          new password[64]
972    
973          get_cvar_string("rcon_password", password, 63)          get_pcvar_string(rcon_password, password, 63)
974    
975          if (!password[0])          if (!password[0])
976          {          {
# Line 862  Line 1107 
1107          get_user_name(id, name, 31)          get_user_name(id, name, 31)
1108          log_amx("Kick: ^"%s<%d><%s><>^" leave some group (tag1 ^"%s^") (tag2 ^"%s^") (tag3 ^"%s^") (tag4 ^"%s^")", name, get_user_userid(id), authid, ltags[0], ltags[1], ltags[2], ltags[3])          log_amx("Kick: ^"%s<%d><%s><>^" leave some group (tag1 ^"%s^") (tag2 ^"%s^") (tag3 ^"%s^") (tag4 ^"%s^")", name, get_user_userid(id), authid, ltags[0], ltags[1], ltags[2], ltags[3])
1109    
1110          switch(get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_LEAVE_1", "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3]);
         {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3])  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_1", ltags[0], ltags[1], ltags[2], ltags[3])  
         }  
1111    
1112          return PLUGIN_HANDLED          return PLUGIN_HANDLED
1113  }  }
# Line 881  Line 1122 
1122          read_argv(1, arg1, 31)          read_argv(1, arg1, 31)
1123          read_argv(2, arg2, 31)          read_argv(2, arg2, 31)
1124    
1125          new player = cmd_target(id, arg1, 1)          new player = cmd_target(id, arg1, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
1126    
1127          if (!player)          if (!player)
1128                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
# Line 895  Line 1136 
1136    
1137          log_amx("Cmd: ^"%s<%d><%s><>^" change nick to ^"%s^" ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, arg2, name2, get_user_userid(player), authid2)          log_amx("Cmd: ^"%s<%d><%s><>^" change nick to ^"%s^" ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, arg2, name2, get_user_userid(player), authid2)
1138    
1139          switch (get_cvar_num("amx_show_activity"))          show_activity_key("ADMIN_NICK_1", "ADMIN_NICK_2", name, name2, arg2);
1140          {  
                 case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_2", name, name2, arg2)  
                 case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_1", name2, arg2)  
         }  
1141          console_print(id, "[AMXX] %L", id, "CHANGED_NICK", name2, arg2)          console_print(id, "[AMXX] %L", id, "CHANGED_NICK", name2, arg2)
1142    
1143          return PLUGIN_HANDLED          return PLUGIN_HANDLED
1144  }  }
1145    
1146    public cmdLast(id, level, cid)
1147    {
1148            if (!cmd_access(id, level, cid, 1))
1149            {
1150                    return PLUGIN_HANDLED;
1151            }
1152    
1153            new name[32];
1154            new authid[32];
1155            new ip[32];
1156            new flags[32];
1157            new access;
1158    
1159    
1160            // This alignment is a bit weird (it should grow if the name is larger)
1161            // but otherwise for the more common shorter name, it'll wrap in server console
1162            // Steam client display is all skewed anyway because of the non fixed font.
1163            console_print(id, "%19s %20s %15s %s", "name", "authid", "ip", "access");
1164    
1165            for (new i = 0; i < g_Size; i++)
1166            {
1167                    GetInfo(i, name, charsmax(name), authid, charsmax(authid), ip, charsmax(ip), access);
1168    
1169                    get_flags(access, flags, charsmax(flags));
1170    
1171                    console_print(id, "%19s %20s %15s %s", name, authid, ip, flags);
1172            }
1173    
1174            console_print(id, "%d old connections saved.", g_Size);
1175    
1176            return PLUGIN_HANDLED;
1177    }

Legend:
Removed from v.16  
changed lines
  Added in v.17

Contact
ViewVC Help
Powered by ViewVC 1.0.4