X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fbanning.qc;h=794854deddf1daa3b6e9b35b316f0d7fb1d3e443;hb=4d88a13318f21331b958f0d7e374c132869a2b85;hp=cb878e75f35de42337f3b3ea48c520a7fd32ffaf;hpb=90a55e6effec111873e53457032c6ccfb3d52bd0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index cb878e75f..794854ded 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -14,9 +14,9 @@ void BanCommand_ban(float request, float argc, string command) string ip = argv(1); float reason_arg, bantime; string reason; - - reason_arg = 2; - + + reason_arg = 2; + GET_BAN_ARG(bantime, autocvar_g_ban_default_bantime); GET_BAN_REASON(reason, "No reason provided"); @@ -24,7 +24,7 @@ void BanCommand_ban(float request, float argc, string command) return; } } - + default: print("Incorrect parameters for ^2ban^7\n"); case CMD_REQUEST_USAGE: @@ -48,7 +48,7 @@ void BanCommand_banlist(float request) Ban_View(); return; } - + default: case CMD_REQUEST_USAGE: { @@ -72,26 +72,26 @@ void BanCommand_kickban(float request, float argc, string command) float accepted = VerifyClientEntity(client, TRUE, FALSE); float reason_arg, bantime, masksize; string reason; - - if(accepted > 0) + + if(accepted > 0) { - reason_arg = next_token; + reason_arg = next_token; GET_BAN_ARG(bantime, autocvar_g_ban_default_bantime); GET_BAN_ARG(masksize, autocvar_g_ban_default_masksize); GET_BAN_REASON(reason, "No reason provided"); Ban_KickBanClient(client, bantime, masksize, reason); - + return; } else { - print("kickban: ", GetClientErrorString(accepted, argv(1)), ".\n"); + print("kickban: ", GetClientErrorString(accepted, argv(1)), ".\n"); } } } - + default: print("Incorrect parameters for ^2kickban^7\n"); case CMD_REQUEST_USAGE: @@ -107,21 +107,36 @@ void BanCommand_kickban(float request, float argc, string command) } } -void BanCommand_mute(float request, float argc, string command) +void BanCommand_mute(float request, float argc, string command) // TODO: Add a sort of mute-"ban" which allows players to be muted based on IP/cryptokey { switch(request) { case CMD_REQUEST_COMMAND: { - - return; + if(argc >= 2) + { + entity client = GetFilteredEntity(argv(1)); + float accepted = VerifyClientEntity(client, TRUE, FALSE); + + if(accepted > 0) + { + client.muted = TRUE; + return; + } + else + { + print("mute: ", GetClientErrorString(accepted, argv(1)), ".\n"); + } + } } - + default: + print("Incorrect parameters for ^2mute^7\n"); case CMD_REQUEST_USAGE: { - print("\nUsage:^3 sv_cmd mute\n"); - print(" No arguments required.\n"); + print("\nUsage:^3 sv_cmd mute client\n"); + print(" 'client' is the entity number or name of the player to mute.\n"); + print("See also: ^2unmute^7\n"); return; } } @@ -135,11 +150,40 @@ void BanCommand_unban(float request, float argc) { if(argv(1)) { - Ban_Delete(stof(argv(1))); - return; + float tmp_number = -1; + string tmp_string; + + if(substring(argv(1), 0, 1) == "#") + { + tmp_string = substring(argv(1), 1, -1); + + if(tmp_string != "") // is it all one token? like #1 + { + tmp_number = stof(tmp_string); + } + else if(argc > 2) // no, it's two tokens? # 1 + { + tmp_number = stof(argv(2)); + } + else + tmp_number = -1; + } + else // maybe it's ONLY a number? + { + tmp_number = stof(argv(1)); + + if((tmp_number == 0) && (argv(1) != "0")) + { tmp_number = -1; } + } + + if(tmp_number >= 0) + { + Ban_Delete(tmp_number); + return; + } } } - + default: case CMD_REQUEST_USAGE: { @@ -157,15 +201,30 @@ void BanCommand_unmute(float request, float argc) { case CMD_REQUEST_COMMAND: { - - return; + if(argc >= 2) + { + entity client = GetFilteredEntity(argv(1)); + float accepted = VerifyClientEntity(client, TRUE, FALSE); + + if(accepted > 0) + { + client.muted = FALSE; + return; + } + else + { + print("unmute: ", GetClientErrorString(accepted, argv(1)), ".\n"); + } + } } - + default: + print("Incorrect parameters for ^2mute^7\n"); case CMD_REQUEST_USAGE: { - print("\nUsage:^3 sv_cmd unmute\n"); - print(" No arguments required.\n"); + print("\nUsage:^3 sv_cmd unmute client\n"); + print(" 'client' is the entity number or name of the player to unmute.\n"); + print("See also: ^2mute^7\n"); return; } } @@ -179,10 +238,10 @@ void BanCommand_(float request) { case CMD_REQUEST_COMMAND: { - + return; } - + default: case CMD_REQUEST_USAGE: { @@ -213,10 +272,10 @@ void BanCommand_macro_help() { #define BAN_COMMAND(name,function,description) \ { if(strtolower(description) != "") { print(" ^2", name, "^7: ", description, "\n"); } } - + BAN_COMMANDS(0, 0, "") #undef BAN_COMMAND - + return; } @@ -224,10 +283,10 @@ float BanCommand_macro_command(float argc, string command) { #define BAN_COMMAND(name,function,description) \ { if(name == strtolower(argv(0))) { function; return TRUE; } } - + BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command) #undef BAN_COMMAND - + return FALSE; } @@ -235,10 +294,10 @@ float BanCommand_macro_usage(float argc) { #define BAN_COMMAND(name,function,description) \ { if(name == strtolower(argv(1))) { function; return TRUE; } } - + BAN_COMMANDS(CMD_REQUEST_USAGE, argc, "") #undef BAN_COMMAND - + return FALSE; } @@ -246,26 +305,26 @@ void BanCommand_macro_write_aliases(float fh) { #define BAN_COMMAND(name,function,description) \ { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_sv", name, description); } } - + BAN_COMMANDS(0, 0, "") #undef BAN_COMMAND - + return; } float BanCommand(string command) { float argc = tokenize_console(command); - + // Guide for working with argc arguments by example: // argc: 1 - 2 - 3 - 4 - // argv: 0 - 1 - 2 - 3 + // argv: 0 - 1 - 2 - 3 // cmd vote - master - login - password if(BanCommand_macro_command(argc, command)) // continue as usual and scan for normal commands { return TRUE; // handled by one of the above GenericCommand_* functions } - + return FALSE; -} \ No newline at end of file +}