1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using UnityEngine;
|
---|
4 |
|
---|
5 | namespace CoppisAdditions.CustomCommands
|
---|
6 | {
|
---|
7 | public class GiveXP : ConsoleCmdAbstract
|
---|
8 | {
|
---|
9 | public override string GetDescription ()
|
---|
10 | {
|
---|
11 | return "give XP to the skill of a player";
|
---|
12 | }
|
---|
13 |
|
---|
14 | public override string GetHelp ()
|
---|
15 | {
|
---|
16 | return "Give XP to the skill of a player\n" +
|
---|
17 | "Usage:\n" +
|
---|
18 | " givexp <name / entity id> <amount xp> <skill name>\n" +
|
---|
19 | "Skills names are: Athletics, Scavenging, Clothing, Light_Armor, Heavy_Armor, Blunt_Weapons, Blade_Weapons, Mining_Tools, Construction_Tools, Pistols, Shotguns, Rifles, Archery, Medicine, Weapon_Smithing, Tool_Smithing, Gun_Smithing, Science, Tailoring, Leatherworking, Armor_Smithing, Miscellaneous_Crafting, Quality_Joe";
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override string[] GetCommands ()
|
---|
23 | {
|
---|
24 | return new string[] { "givexp" };
|
---|
25 | }
|
---|
26 |
|
---|
27 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
|
---|
28 | {
|
---|
29 | try {
|
---|
30 | if (_params.Count != 3) {
|
---|
31 | SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3, found " + _params.Count + ".");
|
---|
32 | return;
|
---|
33 | }
|
---|
34 |
|
---|
35 | ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]);
|
---|
36 | if (ci == null) {
|
---|
37 | SdtdConsole.Instance.Output ("Playername or entity id not found.");
|
---|
38 | return;
|
---|
39 | }
|
---|
40 |
|
---|
41 | int xp = int.MinValue;
|
---|
42 | int.TryParse (_params [1], out xp);
|
---|
43 |
|
---|
44 | if (xp <= 0) {
|
---|
45 | SdtdConsole.Instance.Output ("The amount of XP is not a valid positive integer.");
|
---|
46 | return;
|
---|
47 | }
|
---|
48 |
|
---|
49 | String skillName = _params [2].Replace ('_', ' ');
|
---|
50 |
|
---|
51 | Skill skill = new Skills ().GetSkillByName (skillName);
|
---|
52 | if (skill == null) {
|
---|
53 | SdtdConsole.Instance.Output ("Invalid skill name: \"" + skillName + "\"");
|
---|
54 | return;
|
---|
55 | }
|
---|
56 |
|
---|
57 | ci.SendPackage (new NetPackageConsoleCmdClient ("giveselfskillxp " + skillName + " " + xp, true));
|
---|
58 |
|
---|
59 | SdtdConsole.Instance.Output (xp + " xp was given on skill " + skillName + " to player " + ci.playerName);
|
---|
60 | } catch (Exception e) {
|
---|
61 | Log.Out ("Error in GiveXP.Execute: " + e);
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|