Also do something similiar for QueueLevel economy item

This commit is contained in:
UnknownShadow200 2021-07-18 19:26:01 +10:00
parent 3b11059f0e
commit 341df3498a
4 changed files with 28 additions and 26 deletions

View File

@ -32,21 +32,9 @@ namespace MCGalaxy.Commands.Fun {
string value = args[1];
if (args[0].CaselessEq("zombie")) {
Player who = PlayerInfo.FindMatches(p, value);
if (who == null) return;
p.Message(value + " was queued.");
ZSGame.Instance.QueuedZombie = who.name;
if (ZSGame.Instance.Map != null)
ZSGame.Instance.Map.Message(who.ColoredName + " &Swas queued as the next zombie.");
ZSGame.Instance.SetQueuedZombie(p, value);
} else if (args[0].CaselessEq("level")) {
string map = Matcher.FindMaps(p, value);
if (map == null) return;
p.Message(map + " was queued.");
ZSGame.Instance.Picker.QueuedMap = map.ToLower();
if (ZSGame.Instance.Map != null)
ZSGame.Instance.Map.Message(map + " was queued as the next map.");
ZSGame.Instance.SetQueuedLevel(p, value);
} else {
Help(p);
}

View File

@ -89,13 +89,6 @@ namespace MCGalaxy.Eco {
}
}
protected static void UseCommand(Player p, string cmd, string args) {
CommandData data = default(CommandData);
data.Rank = LevelPermission.Nobody;
data.Context = CommandContext.Purchase;
Command.Find(cmd).Use(p, args, data);
}
protected static bool CheckPrice(Player p, int price, string item) {
if (p.money < price) {
p.Message("&WYou don't have enough &3{1} &Wto buy {0}.", item, Server.Config.Currency);

View File

@ -66,12 +66,10 @@ namespace MCGalaxy.Eco {
}
if (args.Length == 0) { OnStoreCommand(p); return; }
string map = Matcher.FindMaps(p, args);
if (map == null) return;
if (!CheckPrice(p)) return;
UseCommand(p, "Queue", "level " + map);
Economy.MakePurchase(p, Price, "%3QueueLevel: " + map);
if (!ZSGame.Instance.SetQueuedLevel(p, args)) return;
Economy.MakePurchase(p, Price, "%3QueueLevel: " + args);
}
protected internal override void OnStoreCommand(Player p) {

View File

@ -298,5 +298,28 @@ namespace MCGalaxy.Games {
string state = ", you are " + (Get(p).Infected ? "&cdead" : "&aalive");
return money + state;
}
public bool SetQueuedZombie(Player p, string name) {
Player target = PlayerInfo.FindMatches(p, name);
if (target == null) return false;
p.Message("{0} was queued.", p.FormatNick(target));
QueuedZombie = target.name;
if (Map != null) Map.Message(target.ColoredName + " &Swas queued as the next zombie.");
return true;
}
public bool SetQueuedLevel(Player p, string name) {
string map = Matcher.FindMaps(p, name);
if (map == null) return false;
p.Message(map + " was queued.");
Picker.QueuedMap = map.ToLower();
if (Map != null) Map.Message(map + " was queued as the next map.");
return true;
}
}
}