mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 21:51:19 -04:00
Added /skin so operators can change the skins of other players.
This commit is contained in:
parent
39249a8de1
commit
4dae4025ae
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands {
|
||||
isBot = false;
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
}
|
||||
}
|
||||
} else if (p == null) {
|
||||
Player.SendMessage(p, "Console can't use this command on itself."); return;
|
||||
}
|
||||
|
75
Commands/CPE/CmdSkin.cs
Normal file
75
Commands/CPE/CmdSkin.cs
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
public class CmdSkin : Command {
|
||||
|
||||
public override string name { get { return "skin"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
static char[] trimChars = { ' ' };
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") message = "normal";
|
||||
Player who = p;
|
||||
PlayerBot pBot = null;
|
||||
bool isBot = message.CaselessStarts("bot ");
|
||||
string[] args = message.Split(trimChars, isBot ? 3 : 2);
|
||||
|
||||
if (args.Length > 1) {
|
||||
if (isBot && args.Length > 2) {
|
||||
pBot = PlayerBot.Find(args[1]);
|
||||
if (pBot == null) { Player.SendMessage(p, "There is no bot with that name."); return; }
|
||||
} else {
|
||||
isBot = false;
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
}
|
||||
} else if (p == null) {
|
||||
Player.SendMessage(p, "Console can't use this command on itself."); return;
|
||||
}
|
||||
|
||||
string skin = args[args.Length - 1];
|
||||
if (!Player.ValidName(skin)) {
|
||||
Player.SendMessage(p, "\"" + skin + "\" is not a valid skin name."); return;
|
||||
}
|
||||
|
||||
if (isBot) {
|
||||
pBot.skinName = skin;
|
||||
pBot.GlobalDespawn();
|
||||
pBot.GlobalSpawn();
|
||||
Player.GlobalMessage("Bot " + pBot.name + "'s %Sskin was changed to &c" + skin);
|
||||
} else {
|
||||
who.skinName = skin;
|
||||
Player.GlobalDespawn(who, true);
|
||||
Player.GlobalSpawn(who, true);
|
||||
Player.GlobalMessage(who.color + who.DisplayName + "'s %Sskin was changed to &c" + skin);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/skin [name] [skin] - Sets the skin of that player.");
|
||||
Player.SendMessage(p, "/skin bot [name] [model] - Sets the model of that bot.");
|
||||
Player.SendMessage(p, "For example, the player \"Test\" by default has the skin \"Test\".");
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false);
|
||||
if (p.level == Server.zombie.CurLevel)
|
||||
Server.zombie.PlayerJoinedLevel(p, Server.zombie.CurLevel, Server.zombie.CurLevel);
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], true, "");
|
||||
Player.GlobalSpawn(p, true, "");
|
||||
} else {
|
||||
Player.SendChatFrom(p, p.FullName + " %Sis now a referee", false);
|
||||
Server.zombie.PlayerLeftServer(p);
|
||||
|
@ -77,7 +77,7 @@ namespace MCGalaxy.Commands {
|
||||
who.group = Group.findPerm(LevelPermission.Banned);
|
||||
who.color = who.group.color;
|
||||
Player.GlobalDespawn(who, false);
|
||||
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
|
||||
Player.GlobalSpawn(who, false);
|
||||
}
|
||||
|
||||
string oldgroup = group.name.ToString();
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands
|
||||
Server.IRC.Say(p.DisplayName + " left the game (" + discMsg + ")");
|
||||
if (messageOps && !p.opchat) opchat.Use(p, message);
|
||||
} else {
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||
Player.GlobalSpawn(p, false);
|
||||
if (messageOps)
|
||||
Chat.GlobalMessageOps("To Ops -" + p.color + p.DisplayName + "%S- is now &8visible%S.");
|
||||
|
||||
|
@ -63,9 +63,8 @@ namespace MCGalaxy.Commands
|
||||
Player.GlobalDespawn(who, false);
|
||||
|
||||
who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");
|
||||
who.SendUserType(Block.canPlace(who.group.Permission, Block.blackrock));
|
||||
|
||||
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
|
||||
who.SendUserType(Block.canPlace(who.group.Permission, Block.blackrock));
|
||||
Player.GlobalSpawn(who, false);
|
||||
}
|
||||
Server.IRC.Say(rankMsg);
|
||||
}
|
||||
|
@ -135,8 +135,9 @@ namespace MCGalaxy.Commands
|
||||
Server.s.Log("UNBANNED: by console");
|
||||
Server.IRC.Say(message + " was unbanned by console.");
|
||||
}
|
||||
who.group = Group.standard; who.color = who.group.color; Player.GlobalDespawn(who, false);
|
||||
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
|
||||
who.group = Group.standard; who.color = who.group.color;
|
||||
Player.GlobalDespawn(who, false);
|
||||
Player.GlobalSpawn(who, false);
|
||||
Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace MCGalaxy.Commands {
|
||||
Database.executeQuery(query, "UPDATE Players SET color = @Color WHERE name = @Name");
|
||||
}
|
||||
Player.GlobalDespawn(who, false);
|
||||
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
|
||||
Player.GlobalSpawn(who, false);
|
||||
who.SetPrefix();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
Player.GlobalDespawn(who, false);
|
||||
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
|
||||
Player.GlobalSpawn(who, false);
|
||||
PlayerDB.Save(who);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace MCGalaxy.Games
|
||||
p.prefix = p.color + "[" + Colors.Name("&" + color).ToUpper() + "] ";
|
||||
players.Add(p);
|
||||
mapOn.ChatLevel(p.FullName + " %Shas joined the " + teamstring + ".");
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||
Player.GlobalSpawn(p, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ namespace MCGalaxy.Games
|
||||
p.Game.hasflag = null;
|
||||
players.Remove(p);
|
||||
mapOn.ChatLevel(p.FullName + " %Shas left the " + teamstring + ".");
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||
Player.GlobalSpawn(p, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ namespace MCGalaxy.Games {
|
||||
if (p.Game.lastSpawnColor == color) return;
|
||||
p.Game.lastSpawnColor = color;
|
||||
Player.GlobalDespawn(p, true);
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], true);
|
||||
Player.GlobalSpawn(p, true);
|
||||
}
|
||||
|
||||
void EndRound(object sender, ElapsedEventArgs e) {
|
||||
@ -309,7 +309,7 @@ namespace MCGalaxy.Games {
|
||||
int money = GetMoney(pl, alive, rand);
|
||||
|
||||
Player.GlobalDespawn(pl, true);
|
||||
Player.GlobalSpawn(pl, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], true);
|
||||
Player.GlobalSpawn(pl, true);
|
||||
if (money == -1) {
|
||||
pl.SendMessage("You may not hide inside a block! No " + Server.moneys + " for you."); money = 0;
|
||||
} else if (money > 0) {
|
||||
|
@ -174,6 +174,7 @@
|
||||
<Compile Include="Commands\CPE\CmdCustomColors.cs" />
|
||||
<Compile Include="Commands\CPE\CmdModel.cs" />
|
||||
<Compile Include="Commands\CPE\CmdReachDistance.cs" />
|
||||
<Compile Include="Commands\CPE\CmdSkin.cs" />
|
||||
<Compile Include="Commands\Economy\CmdAward.cs" />
|
||||
<Compile Include="Commands\Economy\CmdAwardMod.cs" />
|
||||
<Compile Include="Commands\Economy\CmdAwards.cs" />
|
||||
|
@ -275,6 +275,7 @@ namespace MCGalaxy {
|
||||
byte version = message[0];
|
||||
name = enc.GetString(message, 1, 64).Trim();
|
||||
truename = name;
|
||||
skinName = name;
|
||||
|
||||
lock (pendingLock) {
|
||||
pendingNames.Add(name);
|
||||
|
@ -58,7 +58,7 @@ namespace MCGalaxy {
|
||||
|
||||
public static bool storeHelp = false;
|
||||
public static string storedHelp = "";
|
||||
internal string truename;
|
||||
internal string truename, skinName;
|
||||
internal bool dontmindme = false;
|
||||
public Socket socket;
|
||||
System.Timers.Timer timespent = new System.Timers.Timer(1000);
|
||||
@ -477,13 +477,17 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public static void GlobalSpawn(Player p, bool self, string possession = "") {
|
||||
GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], self, possession);
|
||||
}
|
||||
|
||||
public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z,
|
||||
byte rotx, byte roty, bool self, string possession = "") {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
p.Game.lastSpawnColor = p.Game.Infected ? ZombieGame.InfectCol : p.color;
|
||||
foreach (Player other in players) {
|
||||
if ((other.Loading && p != other) || p.level != other.level) continue;
|
||||
if ((p.hidden || p.Game.Referee) && !self) continue;
|
||||
if ((other.Loading && p != other) || p.level != other.level) continue;
|
||||
if ((p.hidden || p.Game.Referee) && !self) continue;
|
||||
|
||||
if (p != other) {
|
||||
other.SpawnEntity(p, p.id, x, y, z, rotx, roty, possession);
|
||||
@ -503,24 +507,25 @@ namespace MCGalaxy {
|
||||
col = "&" + Colors.GetFallback(col[1]);
|
||||
|
||||
if (hasExtList) {
|
||||
SendExtAddEntity2(id, p.truename, col + p.truename + possession, x, y, z, rotx, roty);
|
||||
SendExtAddPlayerName(id, p.truename, col + p.truename, "&fPlayers", 0);
|
||||
SendExtAddEntity2(id, p.skinName, col + p.truename + possession, x, y, z, rotx, roty);
|
||||
SendExtAddPlayerName(id, p.skinName, col + p.truename, "&fPlayers", 0);
|
||||
} else {
|
||||
SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty);
|
||||
SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
string spawnName = p.truename;
|
||||
if (Server.zombie.ZombieName != "" && !Game.Aka)
|
||||
spawnName = Server.zombie.ZombieName;
|
||||
|
||||
if (hasExtList) {
|
||||
SendExtAddEntity2(id, spawnName, Colors.red + spawnName + possession, x, y, z, rotx, roty);
|
||||
SendExtAddPlayerName(id, spawnName, Colors.red + spawnName, "&cZombies", 0);
|
||||
} else {
|
||||
SendSpawn(id, Colors.red + spawnName + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
string name = p.truename, skinName = p.skinName;
|
||||
if (Server.zombie.ZombieName != "" && !Game.Aka) {
|
||||
name = Server.zombie.ZombieName; skinName = name;
|
||||
}
|
||||
|
||||
if (hasExtList) {
|
||||
SendExtAddEntity2(id, skinName, Colors.red + name + possession, x, y, z, rotx, roty);
|
||||
SendExtAddPlayerName(id, skinName, Colors.red + name, "&cZombies", 0);
|
||||
} else {
|
||||
SendSpawn(id, Colors.red + name + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
|
||||
if (hasChangeModel && id != 0xFF)
|
||||
SendChangeModel(id, "zombie");
|
||||
@ -528,10 +533,10 @@ namespace MCGalaxy {
|
||||
|
||||
internal void SpawnEntity(PlayerBot b) {
|
||||
if (hasExtList) {
|
||||
SendExtAddEntity2(b.id, b.name, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
SendExtAddPlayerName(b.id, b.name, b.color + b.name, "Bots", 0);
|
||||
SendExtAddEntity2(b.id, b.skinName, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
SendExtAddPlayerName(b.id, b.skinName, b.color + b.name, "Bots", 0);
|
||||
} else {
|
||||
SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
SendSpawn(b.id, b.color + b.skinName, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -558,7 +563,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
GlobalDespawn(this, true);
|
||||
GlobalSpawn(this, pos[0], pos[1], pos[2], rot[0], rot[1], true, marker);
|
||||
GlobalSpawn(this, true, marker);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy {
|
||||
public bool hunt = false, kill = false;
|
||||
|
||||
public string AIName = "";
|
||||
public string name;
|
||||
public string name, skinName;
|
||||
public string model = "humanoid";
|
||||
public byte id;
|
||||
public string color;
|
||||
@ -57,6 +57,7 @@ namespace MCGalaxy {
|
||||
#region == constructors ==
|
||||
public PlayerBot(string n, Level lvl, ushort x, ushort y, ushort z, byte rotx, byte roty) {
|
||||
name = n;
|
||||
skinName = n;
|
||||
color = "&1";
|
||||
id = FreeId();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user