/// <summary> /// Host_Noclip_f /// </summary> private static void Noclip_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Progs.GlobalStruct.deathmatch > 0 && !Host.HostClient.privileged) { return; } if (Server.Player.v.movetype != Movetypes.MOVETYPE_NOCLIP) { Host.NoClipAngleHack = true; Server.Player.v.movetype = Movetypes.MOVETYPE_NOCLIP; Server.ClientPrint("noclip ON\n"); } else { Host.NoClipAngleHack = false; Server.Player.v.movetype = Movetypes.MOVETYPE_WALK; Server.ClientPrint("noclip OFF\n"); } }
/// <summary> /// Host_Pause_f /// </summary> private static void Pause_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (_Pausable.Value == 0) { Server.ClientPrint("Pause not allowed.\n"); } else { Server.sv.paused = !Server.sv.paused; if (Server.sv.paused) { Server.BroadcastPrint("{0} paused the game\n", Progs.GetString(Server.Player.v.netname)); } else { Server.BroadcastPrint("{0} unpaused the game\n", Progs.GetString(Server.Player.v.netname)); } // send notification to all clients Server.sv.reliable_datagram.WriteByte(Protocol.svc_setpause); Server.sv.reliable_datagram.WriteByte(Server.sv.paused ? 1 : 0); } }
/// <summary> /// Host_Ping_f /// </summary> private static void Ping_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } Server.ClientPrint("Client ping times:\n"); for (int i = 0; i < Server.svs.maxclients; i++) { client_t client = Server.svs.clients[i]; if (!client.active) { continue; } float total = 0; for (int j = 0; j < Server.NUM_PING_TIMES; j++) { total += client.ping_times[j]; } total /= Server.NUM_PING_TIMES; Server.ClientPrint("{0,4} {1}\n", (int)(total * 1000), client.name); } }
// Host_Tell_f static void Tell_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Cmd.Argc < 3) { return; } string text = Host.HostClient.name + ": "; string p = Cmd.Args; // remove quotes if present if (p.StartsWith("\"")) { p = p.Substring(1, p.Length - 2); } text += p + "\n"; client_t save = Host.HostClient; for (int j = 0; j < Server.svs.maxclients; j++) { client_t client = Server.svs.clients[j]; if (!client.active || !client.spawned) { continue; } if (client.name == Cmd.Argv(1)) { continue; } Host.HostClient = client; Server.ClientPrint(text); break; } Host.HostClient = save; }
/// <summary> /// Host_Kill_f /// </summary> private static void Kill_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Server.Player.v.health <= 0) { Server.ClientPrint("Can't suicide -- allready dead!\n"); return; } Progs.GlobalStruct.time = (float)Server.sv.time; Progs.GlobalStruct.self = Server.EdictToProg(Server.Player); Progs.Execute(Progs.GlobalStruct.ClientKill); }
/// <summary> /// Host_Notarget_f /// </summary> private static void Notarget_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged) { return; } Server.Player.v.flags = (int)Server.Player.v.flags ^ EdictFlags.FL_NOTARGET; if (((int)Server.Player.v.flags & EdictFlags.FL_NOTARGET) == 0) { Server.ClientPrint("notarget OFF\n"); } else { Server.ClientPrint("notarget ON\n"); } }
/// <summary> /// Host_God_f /// Sets client to godmode /// </summary> static void God_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged) { return; } Server.Player.v.flags = (int)Server.Player.v.flags ^ EdictFlags.FL_GODMODE; if (((int)Server.Player.v.flags & EdictFlags.FL_GODMODE) == 0) { Server.ClientPrint("godmode OFF\n"); } else { Server.ClientPrint("godmode ON\n"); } }
/// <summary> /// Host_Fly_f /// Sets client to flymode /// </summary> private static void Fly_f() { if (Cmd.Source == cmd_source_t.src_command) { Cmd.ForwardToServer(); return; } if (Progs.GlobalStruct.deathmatch > 0 && !Host.HostClient.privileged) { return; } if (Server.Player.v.movetype != Movetypes.MOVETYPE_FLY) { Server.Player.v.movetype = Movetypes.MOVETYPE_FLY; Server.ClientPrint("flymode ON\n"); } else { Server.Player.v.movetype = Movetypes.MOVETYPE_WALK; Server.ClientPrint("flymode OFF\n"); } }
/// <summary> /// Host_Status_f /// </summary> private static void Status_f() { bool flag = true; if (Cmd.Source == cmd_source_t.src_command) { if (!Server.sv.active) { Cmd.ForwardToServer(); return; } } else { flag = false; } StringBuilder sb = new StringBuilder(256); sb.Append(String.Format("host: {0}\n", Cvar.GetString("hostname"))); sb.Append(String.Format("version: {0:F2}\n", QDef.VERSION)); if (Net.TcpIpAvailable) { sb.Append("tcp/ip: "); sb.Append(Net.MyTcpIpAddress); sb.Append('\n'); } sb.Append("map: "); sb.Append(Server.sv.name); sb.Append('\n'); sb.Append(String.Format("players: {0} active ({1} max)\n\n", Net.ActiveConnections, Server.svs.maxclients)); for (int j = 0; j < Server.svs.maxclients; j++) { client_t client = Server.svs.clients[j]; if (!client.active) { continue; } int seconds = (int)(Net.Time - client.netconnection.connecttime); int hours, minutes = seconds / 60; if (minutes > 0) { seconds -= (minutes * 60); hours = minutes / 60; if (hours > 0) { minutes -= (hours * 60); } } else { hours = 0; } sb.Append(String.Format("#{0,-2} {1,-16} {2} {2}:{4,2}:{5,2}", j + 1, client.name, (int)client.edict.v.frags, hours, minutes, seconds)); sb.Append(" "); sb.Append(client.netconnection.address); sb.Append('\n'); } if (flag) { Con.Print(sb.ToString()); } else { Server.ClientPrint(sb.ToString()); } }
/// <summary> /// Host_Say /// </summary> private static void Say(bool teamonly) { bool fromServer = false; if (Cmd.Source == cmd_source_t.src_command) { if (Client.cls.state == cactive_t.ca_dedicated) { fromServer = true; teamonly = false; } else { Cmd.ForwardToServer(); return; } } if (Cmd.Argc < 2) { return; } client_t save = Host.HostClient; string p = Cmd.Args; // remove quotes if present if (p.StartsWith("\"")) { p = p.Substring(1, p.Length - 2); } // turn on color set 1 string text; if (!fromServer) { text = (char)1 + save.name + ": "; } else { text = (char)1 + "<" + Net.HostName + "> "; } text += p + "\n"; for (int j = 0; j < Server.svs.maxclients; j++) { client_t client = Server.svs.clients[j]; if (client == null || !client.active || !client.spawned) { continue; } if (Host.TeamPlay != 0 && teamonly && client.edict.v.team != save.edict.v.team) { continue; } Host.HostClient = client; Server.ClientPrint(text); } Host.HostClient = save; }
/// <summary> /// Host_Kick_f /// Kicks a user off of the server /// </summary> private static void Kick_f() { if (Cmd.Source == cmd_source_t.src_command) { if (!Server.sv.active) { Cmd.ForwardToServer(); return; } } else if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged) { return; } client_t save = Host.HostClient; bool byNumber = false; int i; if (Cmd.Argc > 2 && Cmd.Argv(1) == "#") { i = (int)Common.atof(Cmd.Argv(2)) - 1; if (i < 0 || i >= Server.svs.maxclients) { return; } if (!Server.svs.clients[i].active) { return; } Host.HostClient = Server.svs.clients[i]; byNumber = true; } else { for (i = 0; i < Server.svs.maxclients; i++) { Host.HostClient = Server.svs.clients[i]; if (!Host.HostClient.active) { continue; } if (Common.SameText(Host.HostClient.name, Cmd.Argv(1))) { break; } } } if (i < Server.svs.maxclients) { string who; if (Cmd.Source == cmd_source_t.src_command) { if (Client.cls.state == cactive_t.ca_dedicated) { who = "Console"; } else { who = Client.Name; } } else { who = save.name; } // can't kick yourself! if (Host.HostClient == save) { return; } string message = null; if (Cmd.Argc > 2) { message = Common.Parse(Cmd.Args); if (byNumber) { message = message.Substring(1); // skip the # message = message.Trim(); // skip white space message = message.Substring(Cmd.Argv(2).Length); // skip the number } message = message.Trim(); } if (!String.IsNullOrEmpty(message)) { Server.ClientPrint("Kicked by {0}: {1}\n", who, message); } else { Server.ClientPrint("Kicked by {0}\n", who); } Server.DropClient(false); } Host.HostClient = save; }