From: Samual Date: Tue, 13 Dec 2011 10:38:24 +0000 (-0500) Subject: Whoops -- ACTUALLY commit those new files too ;) X-Git-Tag: xonotic-v0.6.0~188^2~28^2~147 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3c721715e5070e8f60256541ae88732bf8d523ac;p=xonotic%2Fxonotic-data.pk3dir.git Whoops -- ACTUALLY commit those new files too ;) --- diff --git a/qcsrc/server/command/ipban.qc b/qcsrc/server/command/ipban.qc new file mode 100644 index 000000000..45b7f2197 --- /dev/null +++ b/qcsrc/server/command/ipban.qc @@ -0,0 +1,75 @@ +float GameCommand_Ban(string command) +{ + float argc; + float bantime; + entity client; + float entno; + float masksize; + string reason; + float reasonarg; + + argc = tokenize_console(command); + if(argv(0) == "help") + { + print(" kickban # n m p reason - kickban player n for m seconds, using mask size p (1 to 4)\n"); + print(" ban ip m reason - ban an IP or range (incomplete IP, like 1.2.3) for m seconds\n"); + print(" bans - list all existing bans\n"); + print(" unban n - delete the entry #n from the bans list\n"); + return TRUE; + } + if(argv(0) == "kickban") + { +#define INITARG(c) reasonarg = c +#define GETARG(v,d) if((argc > reasonarg) && ((v = stof(argv(reasonarg))) != 0)) ++reasonarg; else v = d +#define RESTARG(v) if(argc > reasonarg) v = substring(command, argv_start_index(reasonarg), strlen(command) - argv_start_index(reasonarg)); else v = "" + if(argc >= 3) + { + entno = stof(argv(2)); + if(entno > maxclients || entno < 1) + return TRUE; + client = edict_num(entno); + + INITARG(3); + GETARG(bantime, autocvar_g_ban_default_bantime); + GETARG(masksize, autocvar_g_ban_default_masksize); + RESTARG(reason); + + Ban_KickBanClient(client, bantime, masksize, reason); + return TRUE; + } + } + else if(argv(0) == "ban") + { + if(argc >= 2) + { + string ip; + ip = argv(1); + + INITARG(2); + GETARG(bantime, autocvar_g_ban_default_bantime); + RESTARG(reason); + + Ban_Insert(ip, bantime, reason, 1); + return TRUE; + } +#undef INITARG +#undef GETARG +#undef RESTARG + } + else if(argv(0) == "bans") + { + Ban_View(); + return TRUE; + } + else if(argv(0) == "unban") + { + if(argc >= 2) + { + float who; + who = stof(argv(1)); + Ban_Delete(who); + return TRUE; + } + } + return FALSE; +} \ No newline at end of file diff --git a/qcsrc/server/command/ipban.qh b/qcsrc/server/command/ipban.qh new file mode 100644 index 000000000..58e7b405c --- /dev/null +++ b/qcsrc/server/command/ipban.qh @@ -0,0 +1,4 @@ +void Ban_KickBanClient(entity client, float bantime, float masksize, string reason); +float Ban_Insert(string ip, float bantime, string reason, float dosync); +void Ban_View(); +float Ban_Delete(float i); \ No newline at end of file