source: binary-improvements/7dtd-server-fixes/src/CustomCommands/Kill.cs@ 197

Last change on this file since 197 was 130, checked in by alloc, 10 years ago

Fixes

File size: 1.0 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
6 public class Kill : ConsoleCommand
7 {
8 public Kill (ConsoleSdtd cons) : base(cons)
9 {
10 }
11
12 public override string Description ()
13 {
14 return "kill a given player (entity id or name)";
15 }
16
17 public override string[] Names ()
18 {
19 return new string[] { "kill", string.Empty };
20 }
21
22 public override void Run (string[] _params)
23 {
24 try {
25 if (_params.Length != 1) {
26 m_Console.SendResult ("Usage: kill <playername|entityid>");
27 return;
28 }
29
30 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false);
31
32 if (ci == null) {
33 m_Console.SendResult ("Playername or entity id not found.");
34 return;
35 }
36
37 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci);
38 p.DamageEntity (new DamageSource (EnumDamageSourceType.Bullet), 9999);
39 m_Console.SendResult ("Killed player " + _params [0]);
40 } catch (Exception e) {
41 Log.Out ("Error in Kill.Run: " + e);
42 }
43 }
44 }
45}
Note: See TracBrowser for help on using the repository browser.