///////////////////
// SPAWN HOOK
//////////////
        private void SpawnMyMinicopter(BasePlayer player)
        {
            Vector3 position = player.transform.position + (player.transform.forward * 5);

            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleMini = (BaseVehicle)GameManager.server.CreateEntity(prefab, position, new Quaternion());

            if (vehicleMini == null)
            {
                return;
            }
            BaseEntity Minientity = vehicleMini as BaseEntity;

            Minientity.OwnerID = player.userID;
            vehicleMini.Spawn();
            Player.Message(player, $"{lang.GetMessage("SpawnedMsg", this, player.UserIDString)}", Prefix, SteamIDIcon);
            uint minicopteruint = vehicleMini.net.ID;

            if (debug)
            {
                Puts($"SPAWNED MINICOPTER {minicopteruint.ToString()} for player {player.displayName} OWNER {Minientity.OwnerID}");
            }
            storedData.playerminiID.Remove(player.userID);
            storedData.playerminiID.Add(player.userID, minicopteruint);
            baseplayerminicop.Remove(player);
            baseplayerminicop.Add(player, vehicleMini);
        }
Esempio n. 2
0
        private void SpawnMinicopter(string id)
        {
            // Use find incase they put their username
            BasePlayer player = BasePlayer.Find(id);

            if (player == null)
            {
                return;
            }

            if (_data.playerMini.ContainsKey(player.UserIDString))
            {
                player.ChatMessage(lang.GetMessage("mini_current", this, player.UserIDString));
                return;
            }

            // Credit Original MyMinicopter Plugin
            Quaternion rotation = player.GetNetworkRotation();
            Vector3    forward  = rotation * Vector3.forward;
            Vector3    straight = Vector3.Cross(Vector3.Cross(Vector3.up, forward), Vector3.up).normalized;
            Vector3    position = player.transform.position + straight * 5f;

            position.y = player.transform.position.y + 2f;

            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleMini = (BaseVehicle)GameManager.server.CreateEntity(_config.assetPrefab, position, new Quaternion());

            if (vehicleMini == null)
            {
                return;
            }
            vehicleMini.OwnerID = player.userID;
            vehicleMini.Spawn();
            // End

            _data.playerMini.Add(player.UserIDString, vehicleMini.net.ID);

            if (permission.UserHasPermission(player.UserIDString, _noFuel))
            {
                MiniCopter minicopter = vehicleMini as MiniCopter;

                if (minicopter == null)
                {
                    return;
                }

                minicopter.fuelPerSec = 0f;

                StorageContainer fuelContainer = minicopter.GetFuelSystem().GetFuelContainer();
                ItemManager.CreateByItemID(-946369541, 1)?.MoveToContainer(fuelContainer.inventory);
                fuelContainer.SetFlag(BaseEntity.Flags.Locked, true);
            }
        }
Esempio n. 3
0
        // Spawn hook
        private void SpawnMyMinicopter(BasePlayer player)
        {
            if (player.IsBuildingBlocked() & !allowWhenBlocked)
            {
                PrintMsgL(player, "BlockedMsg");
                return;
            }

            Vector3 position = player.transform.position + (player.transform.forward * 5);

            position.y = player.transform.position.y + 2f;
            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleMini = (BaseVehicle)GameManager.server.CreateEntity(prefab, position, new Quaternion());

            if (vehicleMini == null)
            {
                return;
            }
            BaseEntity miniEntity = vehicleMini as BaseEntity;
            MiniCopter miniCopter = vehicleMini as MiniCopter;

            miniEntity.OwnerID = player.userID;

            if (permission.UserHasPermission(player.UserIDString, MinicopterUnlimited))
            {
                miniCopter.fuelPerSec = 0f;
            }
            vehicleMini.Spawn();

            PrintMsgL(player, "SpawnedMsg");
            uint minicopteruint = vehicleMini.net.ID;

            if (debug)
            {
                Puts($"SPAWNED MINICOPTER {minicopteruint.ToString()} for player {player.displayName} OWNER {miniEntity.OwnerID}");
            }
            storedData.playerminiID.Remove(player.userID);
            storedData.playerminiID.Add(player.userID, minicopteruint);
            SaveData();
            baseplayerminicop.Remove(player.userID);
            baseplayerminicop.Add(player.userID, vehicleMini);

            miniEntity = null;
            miniCopter = null;
        }
Esempio n. 4
0
        // Spawn hook
        private void SpawnMyMinicopter(BasePlayer player)
        {
            if (player.IsBuildingBlocked() & !allowWhenBlocked)
            {
                PrintMsgL(player, "BlockedMsg");
                return;
            }

            Quaternion rotation = player.GetNetworkRotation();
            Vector3    forward  = rotation * Vector3.forward;
            // Make straight perpendicular to up axis so we don't spawn into ground or above player's head.
            Vector3 straight = Vector3.Cross(Vector3.Cross(Vector3.up, forward), Vector3.up).normalized;
            Vector3 position = player.transform.position + straight * 5f;

            position.y = player.transform.position.y + 2.5f;

            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleMini = (BaseVehicle)GameManager.server.CreateEntity(prefab, position, new Quaternion());

            if (vehicleMini == null)
            {
                return;
            }
            BaseEntity miniEntity = vehicleMini as BaseEntity;

            miniEntity.OwnerID = player.userID;

            MiniCopter miniCopter = vehicleMini as MiniCopter;

            vehicleMini.Spawn();

            if (permission.UserHasPermission(player.UserIDString, MinicopterUnlimited))
            {
                // Set fuel requirements to 0
                miniCopter.fuelPerSec = 0f;
                if (!allowFuelIfUnlimited)
                {
                    // If the player is not allowed to use the fuel container, add 1 fuel so the copter will start.
                    // Also lock fuel container since there is no point in adding/removing fuel
                    var x = miniCopter.GetFuelSystem();
                    StorageContainer fuelCan = miniCopter.GetFuelSystem().GetFuelContainer();
                    ItemManager.CreateByItemID(-946369541, 1)?.MoveToContainer(fuelCan.inventory);
                    fuelCan.SetFlag(BaseEntity.Flags.Locked, true);
                }
            }
            else
            {
                miniCopter.fuelPerSec = stdFuelConsumption;
            }

            PrintMsgL(player, "SpawnedMsg");
            uint minicopteruint = vehicleMini.net.ID;

#if DEBUG
            Puts($"SPAWNED MINICOPTER {minicopteruint.ToString()} for player {player.displayName} OWNER {miniEntity.OwnerID}");
#endif
            storedData.playerminiID.Remove(player.userID);
            var myKey = currentMounts.FirstOrDefault(x => x.Value == player.userID).Key;
            currentMounts.Remove(myKey);
            storedData.playerminiID.Add(player.userID, minicopteruint);
            SaveData();

            miniEntity = null;
            miniCopter = null;
        }
Esempio n. 5
0
        private void SpawnMinicopter(BasePlayer player)
        {
            if (!player.IsBuildingBlocked() || _config.canSpawnBuildingBlocked)
            {
                RaycastHit hit;
                if (Physics.Raycast(player.eyes.HeadRay(), out hit, Mathf.Infinity,
                                    LayerMask.GetMask("Construction", "Default", "Deployed", "Resource", "Terrain", "Water", "World")))
                {
                    if (hit.distance > _config.maxSpawnDistance)
                    {
                        player.ChatMessage(lang.GetMessage("mini_sdistance", this, player.UserIDString));
                    }
                    else
                    {
                        Vector3     position   = hit.point + Vector3.up * 2f;
                        BaseVehicle miniEntity = (BaseVehicle)GameManager.server.CreateEntity(_config.assetPrefab, position, new Quaternion());
                        miniEntity.OwnerID = player.userID;
                        miniEntity.health  = _config.spawnHealth;
                        miniEntity.Spawn();

                        // Credit Original MyMinicopter Plugin
                        if (permission.UserHasPermission(player.UserIDString, _noFuel))
                        {
                            MiniCopter minicopter = miniEntity as MiniCopter;

                            if (minicopter == null)
                            {
                                return;
                            }

                            minicopter.fuelPerSec = 0f;

                            StorageContainer fuelContainer = minicopter.GetFuelSystem().GetFuelContainer();
                            ItemManager.CreateByItemID(-946369541, 1)?.MoveToContainer(fuelContainer.inventory);
                            fuelContainer.SetFlag(BaseEntity.Flags.Locked, true);
                        }

                        _data.playerMini.Add(player.UserIDString, miniEntity.net.ID);

                        if (!permission.UserHasPermission(player.UserIDString, _noCooldown))
                        {
                            // Sloppy but works
                            // TODO: Improve later
                            Dictionary <string, float> perms = new Dictionary <string, float>();
                            foreach (var perm in _config.cooldowns)
                            {
                                if (permission.UserHasPermission(player.UserIDString, perm.Key))
                                {
                                    perms.Add(perm.Key, perm.Value);
                                }
                            }

                            if (!perms.IsEmpty())
                            {
                                _data.cooldown.Add(player.UserIDString, DateTime.Now.AddSeconds(perms.Aggregate((l, r) => l.Value < r.Value ? l : r).Value));
                            }

                            // Incase players don't have any cooldown permission default to one day
                            if (!_data.cooldown.ContainsKey(player.UserIDString))
                            {
                                _data.cooldown.Add(player.UserIDString, DateTime.Now.AddDays(1));
                            }
                        }
                    }
                }
                else
                {
                    player.ChatMessage(lang.GetMessage("mini_terrain", this, player.UserIDString));
                }
            }
            else
            {
                player.ChatMessage(lang.GetMessage("mini_priv", this, player.UserIDString));
            }
        }
Esempio n. 6
0
        private void SpawnMyCH47(BasePlayer player, string command, string[] args)
        {
            bool isspawner = permission.UserHasPermission(player.UserIDString, CH47spawn);

            if (isspawner == false)
            {
                Player.Message(player, $"<color={ChatColor}><i>{lang.GetMessage("NoPermMsg", this, player.UserIDString)}</i></color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon);
                return;
            }
            if (storedData.playerch47.ContainsKey(player.userID) == true)
            {
                Player.Message(player, $"<color={ChatColor}>{lang.GetMessage("AlreadyMsg", this, player.UserIDString)}</color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon);
                return;
            }
            bool  hascooldown = permission.UserHasPermission(player.UserIDString, CH47cooldown);
            float minleft     = 0;

            if (hascooldown == true)
            {
                if (storedData.playercounter.ContainsKey(player.userID) == false)
                {
                    storedData.playercounter.Add(player.userID, 0);
                }
                else
                {
                    float count = new float();
                    storedData.playercounter.TryGetValue(player.userID, out count);
                    minleft = cooldownmin - (count / 60);
                    if (debug == true)
                    {
                        Puts($"Player DID NOT reach cooldown return.");
                    }
                    Player.Message(player, $"<color={ChatColor}>{lang.GetMessage("CooldownMsg", this, player.UserIDString)} ({minleft} min)</color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon);
                    return;
                }
            }
            else
            {
                if (storedData.playercounter.ContainsKey(player.userID))
                {
                    storedData.playercounter.Remove(player.userID);
                }
            }
            Vector3 position = player.transform.position + (player.transform.forward * 20);

            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleCH47 = (BaseVehicle)GameManager.server.CreateEntity(prefab, position, new Quaternion());

            if (vehicleCH47 == null)
            {
                return;
            }

            BaseEntity CHentity = vehicleCH47 as BaseEntity;

            CHentity.OwnerID = player.userID;
////// SET PROPERTIES ON SPAWN - FOR FUTURE

            vehicleCH47.Spawn();

            Player.Message(player, $"<color={ChatColor}>{lang.GetMessage("SpawnedMsg", this, player.UserIDString)}</color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon);

//////////////////
// BONUS ENTITIES SPAWN - FOR FUTURE
//////////////////

            uint ch47uint = vehicleCH47.net.ID;

            if (debug == true)
            {
                Puts($"SPAWNED CH47 {ch47uint.ToString()} for player {player.displayName} OWNER {CHentity.OwnerID}");
            }

            storedData.playerch47.Remove(player.userID);
            storedData.playerch47.Add(player.userID, ch47uint);
            baseplayerch47.Remove(player);
            baseplayerch47.Add(player, vehicleCH47);
        }
Esempio n. 7
0
        private void SpawnMyMinicopter(BasePlayer player, string command, string[] args)
        {
            bool isspawner = permission.UserHasPermission(player.UserIDString, MinicopterSpawn);

            if (isspawner == false)
            {
                Player.Message(player, lang.GetMessage("NoPermMsg", this, player.UserIDString), Prefix, SteamIDIcon);
                return;
            }
            if (storedData.playerminiID.ContainsKey(player.userID) == true)
            {
                Player.Message(player, lang.GetMessage("AlreadyMsg", this, player.UserIDString), Prefix, SteamIDIcon);
                return;
            }
            bool  hascooldown = permission.UserHasPermission(player.UserIDString, MinicopterCooldown);
            float minleft     = 0;

            if (hascooldown == true)
            {
                if (storedData.playercounter.ContainsKey(player.userID) == false)
                {
                    storedData.playercounter.Add(player.userID, 0);
                }
                else
                {
                    float count = new float();
                    storedData.playercounter.TryGetValue(player.userID, out count);
                    minleft = cooldownmin - (count / 60);
                    if (debug)
                    {
                        Puts($"Player DID NOT reach cooldown return.");
                    }
                    Player.Message(player, $"{lang.GetMessage("CooldownMsg", this, player.UserIDString)} ({minleft} min)", Prefix, SteamIDIcon);
                    return;
                }
            }
            else
            {
                if (storedData.playercounter.ContainsKey(player.userID))
                {
                    storedData.playercounter.Remove(player.userID);
                }
            }
            Vector3 position = player.transform.position + (player.transform.forward * 5);

            if (position == null)
            {
                return;
            }
            BaseVehicle vehicleMini = (BaseVehicle)GameManager.server.CreateEntity(prefab, position, new Quaternion());

            if (vehicleMini == null)
            {
                return;
            }
            BaseEntity Minientity = vehicleMini as BaseEntity;

            Minientity.OwnerID = player.userID;
            vehicleMini.Spawn();
            Player.Message(player, $"{lang.GetMessage("SpawnedMsg", this, player.UserIDString)}", Prefix, SteamIDIcon);
            uint minicopteruint = vehicleMini.net.ID;

            if (debug)
            {
                Puts($"SPAWNED MINICOPTER {minicopteruint.ToString()} for player {player.displayName} OWNER {Minientity.OwnerID}");
            }
            storedData.playerminiID.Remove(player.userID);
            storedData.playerminiID.Add(player.userID, minicopteruint);
            baseplayerminicop.Remove(player);
            baseplayerminicop.Add(player, vehicleMini);
        }