Exemple #1
0
        private void doRecipe(Smod2.API.Item item, Scp914 objectOfType, Smod2.API.Player player, Smod2.API.KnobSetting knobSetting)
        {
            sbyte outputitem = -2;

            try
            {
                outputitem = (sbyte)(objectOfType.recipes[(byte)item.ItemType].outputs[(byte)knobSetting].outputs[getrandom.Next(0, objectOfType.recipes[(byte)item.ItemType].outputs[(byte)knobSetting].outputs.Count)]);
            }
            catch (System.Exception)
            {
                if (outputitem >= 0)
                {
                    this.plugin.Error("Recipe for " + item.ItemType + "does not exist!  Ask the game devs to add a recipe for it!");
                }
            }
            if (outputitem != -2)
            {
                item.Remove();
                this.plugin.Debug(item.ItemType + " ==> " + (ItemType)outputitem);
            }
            if (outputitem >= 0)
            {
                player.GiveItem((ItemType)outputitem);
            }
        }
Exemple #2
0
        public static void SetPermission(this Smod2.API.Player self, string color, string badge, double permission, bool cover, bool hidden, bool isStaff = false)
        {
            GameObject  player        = (GameObject)self.GetGameObject();
            ServerRoles ComponentRole = player.GetComponent <ServerRoles>();
            UserGroup   group         = new UserGroup();

            group.BadgeColor      = color;
            group.BadgeText       = badge;
            group.Permissions     = (ulong)permission;
            group.Cover           = cover;
            group.HiddenByDefault = hidden;
            ComponentRole.SetGroup(group, false, false, false);
            if (isStaff)
            {
                ComponentRole.Staff = true;
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends <see cref="Player"/> to jail, with time overload. <returns> Returns bool of operation success </returns>
        /// </summary>
        /// <param name="player">the <see cref="Player"/> to send into jail</param>
        /// <param name="jailedToTime">the time to jail the player. Null sets the time to remaining time, or if thats null, one year</param>
        public static bool SendToJail(Smod2.API.Player player, DateTime?jailedToTime)
        {
            if (player == null || player.PlayerRole.RoleID == Smod2.API.RoleType.SPECTATOR || player.OverwatchMode)
            {
                return(false);
            }
            Debug($"Attempting to jail {player.Name}");
            if (AdminToolbox.ATPlayerDict.TryGetValue(player.UserID, out PlayerSettings psetting))
            {
                if (!jailedToTime.HasValue || jailedToTime < DateTime.UtcNow)
                {
                    Debug($"Jail time for \"{player.Name}\" not specified, jailing for a year.");
                }
                psetting.JailedToTime = jailedToTime ?? ((psetting.JailedToTime > DateTime.UtcNow) ? psetting.JailedToTime : DateTime.UtcNow.AddYears(1));
                //Saves original variables
                psetting.originalPos = player.GetPosition();
                if (!psetting.isJailed)
                {
                    psetting.previousRole   = player.PlayerRole.RoleID;
                    psetting.playerPrevInv  = player.GetInventory();
                    psetting.previousHealth = player.Health;

                    foreach (AmmoType a in typeof(AmmoType).GetEnumValues())
                    {
                        if (a != AmmoType.NONE)
                        {
                            psetting.Ammo[a] = player.GetAmmo(a);
                        }
                    }
                }
                //Changes role to Tutorial, teleports to jail, removes inv.
                Debug($"Variables stored, sending \"{player.Name}\" to jail");
                player.ChangeRole(Smod2.API.RoleType.TUTORIAL, true, false);
                player.Teleport(JailPos, true);
                player.ClearInventory();
                psetting.isJailed = true;
                return(true);
            }
            else
            {
                Debug($"Could not send player to jail! Player \"{player.Name}\" not in AT-PlayerDict!");
                return(false);
            }
        }
Exemple #4
0
        IEnumerator <float> setAmmo(Smod2.API.Player Player)
        {
            plugin.Debug("=:BEFORE:= Player: " + Player.Name);
            plugin.Debug(" Ammo(Epsilon-11): " + Player.GetAmmo((AmmoType)0));
            plugin.Debug(" Ammo(MP7, Logicer): " + Player.GetAmmo((AmmoType)1));
            plugin.Debug(" Ammo(COM15, P90): " + Player.GetAmmo((AmmoType)2));
            yield return(Timing.WaitForOneFrame);

            foreach (int ind in System.Enum.GetValues(typeof(AmmoType)))
            {
                int ammo = configs[(Role)Player.TeamRole.Role + "__AMMO_" + ind];
                if (ammo >= 0)
                {
                    Player.SetAmmo((AmmoType)ind, ammo);
                }
            }
            plugin.Debug("=:AFTER:= Player: " + Player.Name);
            plugin.Debug(" Ammo(Epsilon-11): " + Player.GetAmmo((AmmoType)0));
            plugin.Debug(" Ammo(MP7, Logicer): " + Player.GetAmmo((AmmoType)1));
            plugin.Debug(" Ammo(COM15, P90): " + Player.GetAmmo((AmmoType)2));
        }
Exemple #5
0
 public static double Test(this Smod2.API.Player self, double a, double b)
 {
     return(a + b);
 }
Exemple #6
0
 public static void __index(this Smod2.API.Player self, DynValue k)
 {
     UserData.RegisterExtensionType(typeof(PlayerExtension));
 }
Exemple #7
0
        public static int GetMaxHP(this Smod2.API.Player self, int maxhp)
        {
            GameObject player = (GameObject)self.GetGameObject();

            return(player.GetComponent <PlayerStats>().maxHP);
        }
Exemple #8
0
        public static void SetOverwatch(this Smod2.API.Player self, bool overwatch)
        {
            GameObject player = (GameObject)self.GetGameObject();

            player.GetComponent <ServerRoles>().CmdSetOverwatchStatus(overwatch);
        }
Exemple #9
0
        public static void SetMute(this Smod2.API.Player self, bool mute)
        {
            GameObject player = (GameObject)self.GetGameObject();

            player.GetComponent <CharacterClassManager>().SetMuted(mute);
        }