mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-28 07:56:20 -04:00
Cleanup /pay.
This commit is contained in:
parent
24b220ff7d
commit
21ea77eba9
@ -41,48 +41,36 @@ namespace MCGalaxy.Commands
|
||||
Player.SendMessage(p, "Amount must be an integer."); return;
|
||||
}
|
||||
if (amount < 0) { Player.SendMessage(p, "Cannot pay negative %3" + Server.moneys); return; }
|
||||
if (p != null && p == who) { Player.SendMessage(p, "You cannot pay yourself %3" + Server.moneys); return; }
|
||||
string target = null;
|
||||
|
||||
if (who == null)
|
||||
{ //player is offline
|
||||
OfflinePlayer off = PlayerInfo.FindOffline(message.Split()[0]);
|
||||
if (off == null) { Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return; }
|
||||
|
||||
if (who == null) {
|
||||
OfflinePlayer off = PlayerInfo.FindOffline(args[0]);
|
||||
if (off == null) { Player.SendMessage(p, "The player \"&a" + args[0] + "%S\" was not found at all."); return; }
|
||||
payer = Economy.RetrieveEcoStats(p.name);
|
||||
receiver = Economy.RetrieveEcoStats(message.Split()[0]);
|
||||
receiver = Economy.RetrieveEcoStats(args[0]);
|
||||
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
|
||||
|
||||
p.money -= amount;
|
||||
|
||||
payer.money = p.money;
|
||||
receiver.money += amount;
|
||||
|
||||
payer.payment = "%f" + amount + " %3" + Server.moneys + " to " + off.color + off.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||
receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
Economy.UpdateEcoStats(payer);
|
||||
Economy.UpdateEcoStats(receiver);
|
||||
|
||||
target = off.color + off.name;
|
||||
Player.GlobalMessage(p.FullName + " %Spaid %f" + off.color + off.name + "%S(offline) %f" + amount + " %3" + Server.moneys);
|
||||
return;
|
||||
}
|
||||
if (who == p) { Player.SendMessage(p, "%cYou can't pay yourself %3" + Server.moneys); return; }
|
||||
|
||||
} else {
|
||||
payer = Economy.RetrieveEcoStats(p.name);
|
||||
receiver = Economy.RetrieveEcoStats(who.name);
|
||||
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
|
||||
|
||||
p.money -= amount;
|
||||
who.money += amount;
|
||||
|
||||
payer.money = p.money;
|
||||
receiver.money = who.money;
|
||||
who.money += amount;
|
||||
target = who.color + who.name;
|
||||
Player.GlobalMessage(p.FullName + " %Spaid " + who.FullName + " %f" + amount + " %3" + Server.moneys);
|
||||
}
|
||||
|
||||
payer.payment = "%f" + amount + " %3" + Server.moneys + " to " + who.color + who.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||
payer.payment = "%f" + amount + " %3" + Server.moneys + " to " + target + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||
receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
receiver.money += amount;
|
||||
p.money -= amount;
|
||||
payer.money = p.money;
|
||||
Economy.UpdateEcoStats(payer);
|
||||
Economy.UpdateEcoStats(receiver);
|
||||
Player.GlobalMessage(p.FullName + " %Spaid " + who.FullName + " %f" + amount + " %3" + Server.moneys);
|
||||
}
|
||||
|
||||
bool IsLegalPayment(Player p, int payer, int receiver, int amount) {
|
||||
@ -92,7 +80,8 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "%f/pay [player] <amount> " + Server.DefaultColor + "- Pays <amount> " + Server.moneys + " to [player]");
|
||||
Player.SendMessage(p, "%T/pay [player] [amount] ");
|
||||
Player.SendMessage(p, "%HPays <amount> %3" + Server.moneys + " %Hto [player]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user