Skip to content
Permalink
Browse files

Fix +ophax disabling hacks in MOTD, add +/-thirdperson to MOTD, -opha…

…x disables hacks for staff, -/+ophax only applies when player is staff
  • Loading branch information...
UnknownShadow200 committed Oct 23, 2017
1 parent 6ff0e68 commit 901676a2c03c72f90420eb902613e29864cfa4f6
Showing with 20 additions and 15 deletions.
  1. +20 −15 fCraft/Player/PlayerHacks.cs
@@ -5,42 +5,47 @@ namespace fCraft {
public static class PlayerHacks {

public static Packet MakePacket(Player p, string motd) {
bool canFly = true, canNoClip = true, canSpeed = true, canRespawn = true;
bool canFly = true, canNoClip = true, canSpeed = true, canRespawn = true, canThird = true;
short jumpHeight = -1;
bool useMotd = GetHacksFromMotd(p, motd, ref canFly, ref canNoClip,
ref canSpeed, ref canRespawn, ref jumpHeight);
ref canSpeed, ref canRespawn, ref canThird, ref jumpHeight);

if (useMotd)
return Packet.HackControl(canFly, canNoClip, canSpeed, canRespawn, canNoClip, jumpHeight);
return Packet.HackControl(canFly, canNoClip, canSpeed, canRespawn, canThird, jumpHeight);

return Packet.HackControl(p.Info.AllowFlying, p.Info.AllowNoClip, p.Info.AllowSpeedhack,
p.Info.AllowRespawn, p.Info.AllowThirdPerson, p.Info.JumpHeight);
}

static bool GetHacksFromMotd(Player p, string motd, ref bool fly, ref bool noclip,
ref bool speed, ref bool respawn, ref short jumpHeight) {
ref bool speed, ref bool respawn, ref bool third, ref short jumpHeight) {
if (String.IsNullOrEmpty(motd)) return false;
bool useMotd = false;

foreach (string part in motd.ToLower().Split()) {
if (part == "-fly" || part == "+fly") {
fly = part == "+fly";
fly = part == "+fly";
} else if (part == "-noclip" || part == "+noclip") {
noclip = part == "+noclip";
noclip = part == "+noclip";
} else if (part == "-speed" || part == "+speed") {
speed = part == "+speed";
speed = part == "+speed";
} else if (part == "-respawn" || part == "+respawn") {
respawn = part == "+respawn";
} else if (part == "-hax" || part == "+ophax") {
fly = part == "+hax";
noclip = part == "+hax";
speed = part == "+hax";
} else if (part == "-thirdperson" || part == "+thirdperson") {
third = part == "+thirdperson";
} else if (part == "-hax" || part == "+hax") {
fly = part == "+hax";
noclip = part == "+hax";
speed = part == "+hax";
respawn = part == "+hax";
third = part == "+hax";
} else if (part == "-ophax" || part == "+ophax") {
fly = p.IsStaff;
noclip = p.IsStaff;
speed = p.IsStaff;
respawn = p.IsStaff;
if (!p.IsStaff) { useMotd = true; continue; }
fly = part == "+ophax";
noclip = part == "+ophax";
speed = part == "+ophax";
respawn = part == "+ophax";
third = part == "+ophax";
} else if (part.StartsWith("jumpheight=")) {
string heightPart = part.Substring(part.IndexOf('=') + 1);
float value;

0 comments on commit 901676a

Please sign in to comment.
You can’t perform that action at this time.