Пример #1
0
        static void TpaCommand(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /tpa <playerName>");
                return;
            }

            string plName = args[0].ToString();

            if (plName == player.Name)
            {
                player.SendMessage("[WARN] You can't just teleport to yourself!");
                return;
            }

            foreach (OakwoodPlayer p in Oakwood.Players)
            {
                if (plName == p.Name)
                {
                    ((OakPlayerData)p.PlayerData).TpaID = player.ID;

                    player.HUD.Message($"Sending teleport request to {p.Name}...", 0xFFFFFF);

                    p.SendMessage($"[TPA] Player {player.Name} wants to teleport to you:");
                    p.SendMessage($"  > Write '/tpaccept' to accept the request.");
                    p.SendMessage($"  > Or just ignore it, if you want to reject the request.");

                    return;
                }
            }

            player.SendMessage($"[WARN] Player '{plName}' was not found.");
        }
Пример #2
0
 static void ShowPlayersCommand(OakwoodPlayer player, object[] args)
 {
     player.SendMessage("[INFO] Player list:");
     foreach (OakwoodPlayer pl in Oakwood.Players)
     {
         player.SendMessage($" > {pl.Name}#{pl.ID}");
     }
 }
Пример #3
0
        internal static void OnChat(object[] args)
        {
            int    playerID = int.Parse(args[0].ToString());
            string msg      = (string)args[1];

            OakwoodPlayer player = null;

            foreach (OakwoodPlayer pl in Oakwood.Players)
            {
                if (pl.ID == playerID)
                {
                    player = pl;
                    break;
                }
            }

            if (msg.StartsWith("/"))
            {
                string[] t       = msg.Split(' ');
                string   cmd     = t[0];
                string[] cmdargs = t.Skip(1).ToArray();

                if (cmd.Substring(1) == "shwood")
                {
                    player.HUD.Message($"SharpWood {Oakwood.GetVersion()} made by Sevenisko & NanobotZ.", OakColor.White);
                }
                else if (cmd.Substring(1) == "help")
                {
                    player.SendMessage($"Command help:");
                    for (int i = 0; i < OakwoodCommandSystem.cmdDescriptions.Count; i++)
                    {
                        string[] welp = OakwoodCommandSystem.cmdDescriptions[i].Split(new string[] { " - " }, StringSplitOptions.None);
                        player.SendMessage($"> {welp[0]}");
                        player.SendMessage($" {{888888}}-> {{cccccc}}{welp[1]}");
                    }
                }
                else if (!OakwoodCommandSystem.ExecuteCommand(player, cmd.Substring(1), cmdargs))
                {
                    OakwoodCommandSystem.CallEvent("unknownCommand", new object[] { player, cmd.Substring(1) });
                }
            }
            else
            {
                if (OnPlayerChat != null)
                {
                    OnPlayerChat(player, msg);
                }
            }
        }
Пример #4
0
        static void SaveLoc(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /saveloc <locName>");
                return;
            }

            string locName = args[0].ToString();

            string file = Environment.CurrentDirectory + @"\savedLocations\" + $"{locName}.txt";

            if (!Directory.Exists(Path.GetDirectoryName(file)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file));
            }

            OakVec3 playerPos = player.Position;
            OakVec3 playerDir = player.Direction;

            if (playerPos.x != 0 && playerPos.y != 0 && playerPos.z != 0 && playerDir.x != 0 && playerDir.z != 0)
            {
                File.WriteAllText(file, $"{playerPos.x};{playerPos.y};{playerPos.z};{playerDir.x};{playerDir.y};{playerDir.z}");

                player.HUD.Message($"Location '{locName}' saved!", 0xFFFFFF);
            }
            else
            {
                player.HUD.Message("Cannot save location!", 0xFF0000);
            }
        }
Пример #5
0
        static void LoadLoc(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /loadloc <locName>");
                return;
            }

            string locName = args[0].ToString();

            string file = Environment.CurrentDirectory + @"\savedLocations\" + $"{locName}.txt";

            if (File.Exists(file))
            {
                string[] pos    = File.ReadAllText(file).Split(';');
                OakVec3  newPos = new OakVec3(float.Parse(pos[0]), float.Parse(pos[1]), float.Parse(pos[2]));
                OakVec3  newDir = new OakVec3(float.Parse(pos[3]), float.Parse(pos[4]), float.Parse(pos[5]));
                player.Position  = newPos;
                player.Direction = newDir;
                player.HUD.Message($"Teleported to '{locName}'!", 0xFFFFFF);
            }
            else
            {
                player.HUD.Message($"Location '{locName}' doesn't exist!", 0xFF0000);
            }
        }
Пример #6
0
        static void SetSkin(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /skin <skinID>");
                return;
            }

            int skinID = int.Parse(args[0].ToString());

            OakwoodVehicle car = player.Vehicle;

            if (car == null)
            {
                if (skinID >= 0 && skinID < OakwoodResources.PlayerModels.Length - 1)
                {
                    player.SetModel(OakwoodResources.PlayerModels[skinID].Modelname);
                    player.HUD.Message("Skin successfully changed!", 0xFFFFFF);
                }
                else
                {
                    player.HUD.Message("Skin ID you provided is wrong!", 0xFCB603);
                }
            }
            else
            {
                player.HUD.Message("You can't be inside the vehicle!", 0xFF0000);
            }
        }
Пример #7
0
        static void Warp(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                string List = "";

                foreach (string f in Directory.GetFiles(Environment.CurrentDirectory + @"\Warps"))
                {
                    List += $"{Path.GetFileNameWithoutExtension(f)}, ";
                }

                player.SendMessage($"[WARPS ({Directory.GetFiles(Environment.CurrentDirectory + @"\Warps").Length})] {List}");
                return;
            }

            string locName = args[0].ToString();

            string file = Environment.CurrentDirectory + @"\Warps\" + $"{locName}.txt";

            if (File.Exists(file))
            {
                player.HUD.Message($"Warping you to '{locName}'...", 0xFFFFFF);
                string[] pos    = File.ReadAllText(file).Split(';');
                OakVec3  newPos = new OakVec3(float.Parse(pos[0]), float.Parse(pos[1]), float.Parse(pos[2]));
                OakVec3  newDir = new OakVec3(float.Parse(pos[3]), float.Parse(pos[4]), float.Parse(pos[5]));
                player.Position  = newPos;
                player.Direction = newDir;
            }
            else
            {
                player.HUD.Message($"Warp '{locName}' doesn't exist!", 0xFF0000);
            }
        }
Пример #8
0
        private static void PlUnknownCmd(object[] args)
        {
            OakwoodPlayer player = (OakwoodPlayer)args[0];
            string        cmd    = args[1].ToString();

            player.SendMessage($"[CMD] Command '{cmd}' was not found.");
        }
Пример #9
0
        static void ClearChatCommand(OakwoodPlayer player, object[] args)
        {
            for (int x = 0; x < 24; x++)
            {
                player.SendMessage("\n");
            }

            player.HUD.Message("Chat cleared.", 0xFFFFFF);
        }
Пример #10
0
        static void PmCommand(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /pm <playerName> <message>");
                return;
            }

            string plName = args[0].ToString();

            object[] msg = args.Skip(1).ToArray();

            string message = "";

            foreach (object m in msg)
            {
                if (message == "")
                {
                    message = $"{m.ToString()} ";
                }
                else
                {
                    message += $"{m.ToString()} ";
                }
            }

            if (plName == player.Name)
            {
                player.SendMessage("[WARN] You can't just send PM to yourself!");
                return;
            }

            foreach (OakwoodPlayer p in Oakwood.Players)
            {
                if (plName == p.Name)
                {
                    player.SendMessage($"[Me -> {p.Name}] {message}");
                    p.SendMessage($"[{player.Name} -> Me] {message}");
                    return;
                }
            }

            player.SendMessage($"[WARN] Player '{plName}' was not found.");
        }
Пример #11
0
        static void TpacceptCommand(OakwoodPlayer player, object[] args)
        {
            if (((OakPlayerData)player.PlayerData).TpaID != -1)
            {
                foreach (OakwoodPlayer p in Oakwood.Players)
                {
                    if (p.ID == ((OakPlayerData)player.PlayerData).TpaID)
                    {
                        p.Position = player.Position;
                        p.HUD.Message("Your teleport request was accepted.", 0xFFFFFF);
                        ((OakPlayerData)player.PlayerData).TpaID = -1;
                        ((OakPlayerData)p.PlayerData).TpaID      = -1;
                        return;
                    }
                }
            }

            player.SendMessage("[TPA] There's no teleport request.");
        }
Пример #12
0
        static void DeleteWarp(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /deletewarp <locName>");
                return;
            }

            string locName = args[0].ToString();

            string file = Environment.CurrentDirectory + @"\Warps\" + $"{locName}.txt";

            if (File.Exists(file))
            {
                File.Delete(file);
                player.HUD.Message($"Warp '{locName}' deleted.", OakColor.White);
            }
            else
            {
                player.HUD.Message($"Warp '{locName}' doesn't exist!", OakColor.Red);
            }
        }
Пример #13
0
        static void CreateWarp(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /createwarp <locName>");
                return;
            }

            string locName = args[0].ToString();

            string file = Environment.CurrentDirectory + @"\Warps\" + $"{locName}.txt";

            if (!Directory.Exists(Path.GetDirectoryName(file)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file));
            }

            if (!File.Exists(file))
            {
                OakVec3 playerPos = player.Position;
                OakVec3 playerDir = player.Direction;

                if (playerPos.x != 0 && playerPos.y != 0 && playerPos.z != 0 && playerDir.x != 0 && playerDir.z != 0)
                {
                    File.WriteAllText(file, $"{playerPos.x};{playerPos.y};{playerPos.z};{playerDir.x};{playerDir.y};{playerDir.z}");

                    player.HUD.Message($"Warp '{locName}' created!", 0xFFFFFF);
                }
                else
                {
                    player.HUD.Message("Cannot create warp!", 0xFF0000);
                }
            }
            else
            {
                player.HUD.Message($"Warp '{locName}' already exists!", OakColor.Red);
            }
        }
Пример #14
0
        static void SpawnCar(OakwoodPlayer player, object[] args)
        {
            if (args.Length == 0)
            {
                player.SendMessage("[USAGE] /car <carID>");
                return;
            }

            int carID = int.Parse(args[0].ToString());

            if (carID >= 0 && carID < OakwoodResources.VehicleModels.Length - 1)
            {
                OakVec3 plPos = player.Position;

                OakVec3 plDir = player.Direction;

                OakwoodVehicle sCar = OakwoodVehicle.Spawn(OakwoodResources.VehicleModels[carID], plPos, plDir.x / 360.0f);

                if (sCar != null)
                {
                    player.VehicleManipulation.Put(sCar, VehicleSeat.FrontLeft);

                    player.HUD.Message("Car successfully spawned!", 0xFFFFFF);
                    return;
                }
                else
                {
                    player.HUD.Message("Cannot spawn car!", 0xFF0000);
                    return;
                }
            }
            else
            {
                player.HUD.Message("Car ID you provided is wrong!", 0xFCB603);
                return;
            }
        }
Пример #15
0
 static void TestCommand(OakwoodPlayer player, object[] args)
 {
     player.SendMessage($"SharpWood testing command.");
 }