Example #1
0
        internal static void AutoCopy(UnturnedPlayer player)
        {
            if (Commands.Command_AutoCopy.Murdered.ContainsKey(player.CSteamID))
            {
                UnturnedPlayer murderer = UnturnedPlayer.FromCSteamID(Commands.Command_AutoCopy.Murdered[player.CSteamID]);

                if (murderer.HasPermission("ck.copyinventory.bypass"))
                {
                    UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("copy_bypass", murderer.CharacterName), Color.red);
                    return;
                }

                Copy(murderer, player, Plugin.CustomKitsPlugin.Instance.Configuration.Instance.IncludeClothingInKits);

                UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("copied", murderer.CharacterName), Color.green);
            }
        }
Example #2
0
        public void GiveReward_Weighted(UnturnedPlayer player)
        {
            try
            {
                List <string> Rnd_Items = new List <string>();
                foreach (var pair in Reward_dictionary)
                {
                    for (int i = 0; i < pair.Value; i++)
                    {
                        Rnd_Items.Add(pair.Key);
                    }
                }

                System.Random rnd = new System.Random();
                int           r   = rnd.Next(Rnd_Items.Count);

                if (advanced_logging)
                {
                    Rocket.Core.Logging.Logger.Log("Executing " + Rnd_Items[r].Replace("(player)", player.DisplayName).Replace("(steamid)", player.CSteamID + ""));
                }

                if (!cheats)
                {
                    Provider.hasCheats = true;
                }

                bool success = R.Commands.Execute((IRocketPlayer)UnturnedPlayer.FromCSteamID(Executor_ID), Rnd_Items[r].Replace("(player)", player.DisplayName).Replace("(steamid)", player.CSteamID + ""));

                if (!cheats)
                {
                    Provider.hasCheats = false;
                }

                if (!success)
                {
                    Rocket.Core.Logging.Logger.LogError("Failed to execute command " + Rnd_Items[r] + " while trying to give reward to " + player.DisplayName);
                }

                Check_Cooldown(player);
            }
            catch (Exception e)
            {
                Rocket.Core.Logging.Logger.LogException(e);
            }
        }
Example #3
0
        private IEnumerator PaymentCoroutine()
        {
            while (true)
            {
                foreach (House x in Configuration.Instance.homes)
                {
                    if (x.LastPaid == null || x.OwnerId == null)
                    {
                        continue;
                    }

                    UnturnedPlayer player = PlayerTool.getPlayer(new Steamworks.CSteamID(x.OwnerId.Value)) == null
                        ? null
                        : UnturnedPlayer.FromCSteamID(new Steamworks.CSteamID(x.OwnerId.Value));

                    if (!((DateTime.Now - x.LastPaid.Value).TotalMinutes > Configuration.Instance.feePaymentTimeInMinutes))
                    {
                        continue;
                    }

                    if (Uconomy.Instance.Database.GetBalance(x.OwnerId.ToString()) < x.Price)
                    {
                        if (player != null)
                        {
                            instance.TellPlayer(player, "eviction_notice", Color.red);
                        }

                        manager.SetHouseOwner(x.Id, x.Position, null);
                        continue;
                    }

                    if (player != null)
                    {
                        instance.TellPlayer(player, "upkeep_payment", Palette.SERVER,
                                            Configuration.Instance.currencySymbol, x.Price);
                    }

                    Uconomy.Instance.Database.IncreaseBalance(x.OwnerId.ToString(), -x.Price);
                    x.LastPaid = DateTime.Now;
                    Configuration.Save();
                }

                yield return(new WaitForSeconds(instance.Configuration.Instance.paymentCheckIntervalInSeconds));
            }
        }
Example #4
0
        /// <summary>
        /// Increases the account balance of the specific ID with IncreaseBy.
        /// </summary>
        /// <param name="id">Steam 64 ID of the account.</param>
        /// <param name="increaseBy">The amount that the account should be changed with (can be negative).</param>
        /// <returns>The new balance of the account.</returns>
        public decimal IncreaseBalance(string id, decimal increaseBy)
        {
            TransferReason reason = null;
            UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(ulong.Parse(id)));

            if (increaseBy >= 0)
            {
                reason = new TransferReason_Unknown_In($"{id} ({(player != null ? player.DisplayName : id)})", "", increaseBy);
            }
            else
            {
                reason = new TransferReason_Unknown_Out("", $"{id} ({(player != null ? player.DisplayName : id)})", increaseBy);
            }
            BankingSystem.Instance.api.increaseBalance(id, increaseBy, reason);
            decimal balance = BankingSystem.Instance.api.getPlayerBalance(id);

            return(balance);
        }
        private void VehiculoDaño(CSteamID instigatorSteamID, InteractableVehicle vehicle, ref ushort pendingTotalDamage, ref bool canRepair, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            if (Configuration.Instance.vidainfinita)
            {
                pendingTotalDamage = 0;
                shouldAllow        = false;
            }

            if (Configuration.Instance.mostrarlog)
            {
                UnturnedPlayer player = UnturnedPlayer.FromCSteamID(instigatorSteamID);

                if (damageOrigin == EDamageOrigin.Useable_Gun || damageOrigin == EDamageOrigin.Useable_Melee || damageOrigin == EDamageOrigin.Punch)
                {
                    Logger.LogWarning($"{player.CharacterName} Esta Intentando Romper: {vehicle.asset.name}");
                }
            }
        }
Example #6
0
        void OnDamageBarricadeRequested(CSteamID instigatorSteamID, Transform barricadeTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            UnturnedPlayer untPlayer = UnturnedPlayer.FromCSteamID(instigatorSteamID);

            if (untPlayer?.Player != null)
            {
                if (Utils.IsActive(untPlayer) && Config.BlockBuildableDamage)
                {
                    if (untPlayer.GodMode || untPlayer.VanishMode)
                    {
                        shouldAllow = false;
                        Utils.Announce(Translate("private_damaged_buildable_in_vanish"), untPlayer);
                        return;
                    }
                }
            }
            shouldAllow = true;
        }
Example #7
0
        private void delayKillPlayer()
        {
            if ((DateTime.Now - this.lastCalled).TotalSeconds > .5)
            {
                lastCalled = DateTime.Now;

                if (playersToKillOnConnect.Count == 1 && playersToKillOnConnect[0] != null)
                {
                    //               playersToKillOnConnect[0].GodMode = false;
                    //              playersToKillOnConnect[0].Suicide();
                    CommandEvent myEvent = new CommandEvent();
                    myEvent.clearInventory(playersToKillOnConnect[0]);
                    UnturnedPlayer playerMove = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(playersToKillOnConnect[0].CSteamID.ToString())));
                    playersToKillOnConnect[0].Teleport(new Vector3((float)-312.1, (float)72.4, (float)80.0), 0);
                    playersToKillOnConnect.Remove(playersToKillOnConnect[0]);
                }
            }
        }
        private static IEnumerator CheckJail()
        {
            while (PSRMPoliceUtilities.Instance.IsPluginLoaded)
            {
                //Who the f**k still uses coroutines?
                yield return(new WaitForSeconds((float)Convert.ToDouble(PSRMPoliceUtilities.Instance.Configuration.Instance.CheckInterval)));

                //Logger.Log("Checking jails database...");
                //Logger.Log($"{PSRMPoliceUtilities.Instance.JailTimesDatabase.Data.Count} player(s) found in jail.");

                foreach (var jailedPlayer in PSRMPoliceUtilities.Instance.JailTimesDatabase.Data.ToList().Where(jailedPlayer => jailedPlayer.ExpireDate <= DateTime.Now))
                {
                    PSRMPoliceUtilities.Instance.JailTimeService.RemoveJailedUser(jailedPlayer.PlayerId);
                    ChatManager.serverSendMessage($"{UnturnedPlayer.FromCSteamID((CSteamID) Convert.ToUInt64(jailedPlayer.PlayerId)).CharacterName} was automatically released from {jailedPlayer.JailName}.", Color.blue, null, null, EChatMode.GLOBAL, null, true);
                    UnturnedPlayer.FromCSteamID((CSteamID)Convert.ToUInt64(jailedPlayer.PlayerId)).Teleport(new Vector3(PSRMPoliceUtilities.Instance.Configuration.Instance.RelaseLocation.x, PSRMPoliceUtilities.Instance.Configuration.Instance.RelaseLocation.x, PSRMPoliceUtilities.Instance.Configuration.Instance.RelaseLocation.z), 0);
                }
            }
        }
Example #9
0
 private void OnPlayerDeath(UnturnedPlayer Player, EDeathCause Cause, ELimb Limb, CSteamID Murderer)
 {
     if (Configuration.Instance.OnlyBanOnSuicide)
     {
         if (Cause.ToString() == "SUICIDE" || UnturnedPlayer.FromCSteamID(Murderer) == Player)
         {
             DeathBan(Player);
         }
         else
         {
             Logger.LogWarning("Not banning Player, as it wasn't suicide.");
         }
     }
     else
     {
         DeathBan(Player);
     }
 }
Example #10
0
        private void OnDamage(Player player, ref EDeathCause cause, ref ELimb limb, ref CSteamID killer, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            if (player == null || killer == Provider.server)
            {
                return;
            }

            UnturnedPlayer p = UnturnedPlayer.FromPlayer(player);
            UnturnedPlayer k = UnturnedPlayer.FromCSteamID(killer);

            if (p?.CSteamID == null || k?.CSteamID == null)
            {
                return;
            }

            if (p.CSteamID == killer)
            {
                return;
            }

            if ((p.IsAdmin || k.IsAdmin) && Util.Config().ignoreAdmins)
            {
                return;
            }

            if (p.GetPermissions().Any(x => x.Name == "pvptoggle.ignore") || k.GetPermissions().Any(x => x.Name == "pvptoggle.ignore"))
            {
                return;
            }

            if (!p.GetComponent <PvpPlayer>().PvpEnabled || !k.GetComponent <PvpPlayer>().PvpEnabled)
            {
                if (Util.Config().enableWarningEffect&& (DateTime.Now - k.GetComponent <PvpPlayer>().LastWarned).TotalSeconds > Util.Config().warningCooldown)
                {
                    EffectManager.sendUIEffect(Util.Config().warningEffectId, 1200, killer, true);
                    CSteamID attacker = killer;
                    StartCoroutine(DelayedInvoke(Util.Config().warningScreentime,
                                                 () => EffectManager.askEffectClearByID(Util.Config().warningEffectId, attacker)));
                    k.GetComponent <PvpPlayer>().LastWarned = DateTime.Now;
                }
                damage    = 0;
                canDamage = false;
            }
        }
Example #11
0
        private void OnDamage(Player Player, ref EDeathCause Cause, ref ELimb Limb, ref CSteamID Murderer, ref Vector3 Direction, ref float Damage, ref float Times, ref bool canDamage)
        {
            UnturnedPlayer uVictim = UnturnedPlayer.FromPlayer(Player);
            UnturnedPlayer uKiller = UnturnedPlayer.FromCSteamID(Murderer);

            if (uVictim.HasPermission("killlimiter.ignore") || Player == null || uVictim == null || Murderer == Provider.server || uVictim.CSteamID == Murderer || uKiller == null)
            {
                return;
            }

            if (!uKiller.GetComponent <PlayerUtil>().canKill)
            {
                UnturnedChat.Say(uKiller, "You have reached your kill limit!", Color.red);
                Damage    = 0;
                canDamage = false;
                return;
            }
            return;
        }
Example #12
0
        private void OnPlayerDeath(UnturnedPlayer uVictim, EDeathCause Cause, ELimb Limb, CSteamID Murderer)
        {
            if (UnturnedPlayer.FromCSteamID(Murderer).HasPermission("killlimiter.ignore"))
            {
                return;
            }

            UnturnedPlayer uKiller = UnturnedPlayer.FromCSteamID(Murderer);

            uKiller.GetComponent <PlayerUtil>().Kills++;

            if (uKiller.GetComponent <PlayerUtil>().Kills == Instance.Configuration.Instance.KillLimit)
            {
                uKiller.GetComponent <PlayerUtil>().CanKillTime = GetLongTime();
                uKiller.GetComponent <PlayerUtil>().canKill     = false;
                UnturnedChat.Say(uKiller, $"You can no longer damage other players for {Instance.Configuration.Instance.LimitCooldown} seconds!", Color.red);
            }
            return;
        }
 private void Awake()
 {
     Instance = this;
     Provider.onServerDisconnected += (CSteamID r) =>
     {
         if (r != CSteamID.Nil)
         {
             OnPlayerDisconnected.TryInvoke(UnturnedPlayer.FromCSteamID(r));
         }
     };
     Provider.onServerShutdown  += () => { onShutdown.TryInvoke(); };
     Provider.onServerConnected += (CSteamID r) =>
     {
         if (r != CSteamID.Nil)
         {
             UnturnedPlayer p = UnturnedPlayer.FromCSteamID(r);
             p.Player.gameObject.TryAddComponent <UnturnedPlayerFeatures>();
             p.Player.gameObject.TryAddComponent <UnturnedPlayerMovement>();
             p.Player.gameObject.TryAddComponent <UnturnedPlayerEvents>();
             OnBeforePlayerConnected.TryInvoke(p);
         }
     };
     DamageTool.damagePlayerRequested += (ref DamagePlayerParameters parameters, ref bool shouldAllow) =>
     {
         if (OnPlayerDamaged != null)
         {
             if (parameters.player != null && parameters.killer != CSteamID.Nil && parameters.killer != null)
             {
                 UnturnedPlayer getterDamage = UnturnedPlayer.FromPlayer(parameters.player);
                 UnturnedPlayer senderDamage = UnturnedPlayer.FromCSteamID(parameters.killer);
                 OnPlayerDamaged.TryInvoke(
                     getterDamage,
                     parameters.cause,
                     parameters.limb,
                     senderDamage,
                     parameters.direction,
                     parameters.damage,
                     parameters.times,
                     shouldAllow);
             }
         }
     };
 }
        private void BarricadeDamaged(CSteamID instigatorSteamID, Transform barricadeTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            if (!shouldAllow ||
                !BarricadeManager.tryGetInfo(barricadeTransform, out byte x, out byte y, out ushort plant, out ushort index, out var region, out var drop) ||
                plant != ushort.MaxValue)
            {
                return;
            }

            var newHp = region.barricades.FirstOrDefault(c => c.instanceID == drop.instanceID).barricade.health - pendingTotalDamage;

            if (newHp > 0)
            {
                return;
            }
            var barricade = region.barricades.FirstOrDefault(c => c.instanceID == drop.instanceID);

            if (UnturnedPlayer.FromCSteamID((CSteamID)barricade.owner)?.Player != null)
            {
                return;
            }

            var player = PlayerTool.getPlayer(instigatorSteamID);

            var playerInfo = InfoSerializer.Players.FirstOrDefault(c => c.Characters.Any(k => k.InstanceId == drop.instanceID));

            var character = playerInfo?.Characters?.FirstOrDefault(c => c.InstanceId == drop.instanceID);

            if (character == null)
            {
                return;
            }


            foreach (var item in character.Items)
            {
                ItemManager.dropItem(new Item(item.ItemId, item.Amount, item.Quality, item.State), character.BarricadeLocation.ToVector3() + new Vector3(0, 0.5f), true, true, true);
            }

            playerInfo.Characters.Remove(character);

            InfoSerializer.Save();
        }
Example #15
0
 public void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
 {
     if (cause.ToString() == "ZOMBIE")
     {
         UnturnedChat.Say(player.CharacterName + " got killed by a zombie! ", Color.red);
     }
     else if (cause.ToString() == "GUN")
     {
         UnturnedChat.Say(UnturnedPlayer.FromCSteamID(murderer).CharacterName + " shot " + player.CharacterName + "!", Color.red);
     }
     else if (cause.ToString() == "MELEE")
     {
         UnturnedChat.Say(UnturnedPlayer.FromCSteamID(murderer).CharacterName + " meleed " + player.CharacterName + " to death!", Color.red);
     }
     else if (cause.ToString() == "PUNCH")
     {
         UnturnedChat.Say(UnturnedPlayer.FromCSteamID(murderer).CharacterName + " punched " + player.CharacterName + " to death!", Color.red);
     }
     else if (cause.ToString() == "ROADKILL")
     {
         UnturnedChat.Say(UnturnedPlayer.FromCSteamID(murderer).CharacterName + " ran over " + player.CharacterName + "!", Color.red);
     }
     else if (cause.ToString() == "VEHICLE")
     {
         UnturnedChat.Say(player.CharacterName + " died in a vehicle explosion!", Color.red);
     }
     else if (cause.ToString() == "FOOD")
     {
         UnturnedChat.Say(player.CharacterName + " starved to death!", Color.red);
     }
     else if (cause.ToString() == "WATER")
     {
         UnturnedChat.Say(player.CharacterName + " has dehydrated to death!", Color.red);
     }
     else if (cause.ToString() == "INFECTION")
     {
         UnturnedChat.Say(player.CharacterName + " got infected!", Color.red);
     }
     else if (cause.ToString() == "BLEEDING")
     {
         UnturnedChat.Say(player.CharacterName + " bled out!", Color.red);
     }
 }
Example #16
0
        void OnPlayerDamaged(Player player, ref EDeathCause cause, ref ELimb limb, ref CSteamID killer, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            UnturnedPlayer untKiller = UnturnedPlayer.FromCSteamID(killer);
            UnturnedPlayer untVictim = UnturnedPlayer.FromPlayer(player);

            // Remove any of those pesky errors
            if (untKiller?.Player != null)
            {
                if (Utils.IsActive(untKiller))
                {
                    if (untKiller.GodMode)
                    {
                        if (Config.PlayerDamagePublicWarn)
                        {
                            Utils.Announce(Translate("public_damaged_in_god", untKiller.DisplayName));
                        }
                        if (Config.PlayerDamagePrivateWarn)
                        {
                            Utils.Announce(Translate("private_damaged_in_god", untVictim.DisplayName, untKiller), untKiller);
                        }
                        if (Config.BlockPlayerDamage)
                        {
                            canDamage = false;
                        }
                    }
                    if (untKiller.VanishMode)
                    {
                        if (Config.PlayerDamagePublicWarn)
                        {
                            Utils.Announce(Translate("public_damaged_in_vanish", untKiller.DisplayName, untVictim.DisplayName));
                        }
                        if (Config.PlayerDamagePrivateWarn)
                        {
                            Utils.Announce(Translate("private_damaged_in_vanish", untVictim.DisplayName), untKiller);
                        }
                        if (Config.BlockPlayerDamage)
                        {
                            canDamage = false;
                        }
                    }
                }
            }
        }
Example #17
0
        private void onPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
        {
            UnturnedPlayer killer = UnturnedPlayer.FromCSteamID(murderer);

            if (cause == EDeathCause.GUN && limb == ELimb.SKULL)
            {
                ChatManager.serverSendMessage(Translate("death_message_gun_in_skull", killer.CharacterName, player.CharacterName), Color.white, null, null, EChatMode.GLOBAL, null, true);
                experienceForKill(killer, limb);
            }
            else if (cause == EDeathCause.GUN || cause == EDeathCause.MELEE || cause == EDeathCause.MISSILE || cause == EDeathCause.PUNCH || cause == EDeathCause.ROADKILL || cause == EDeathCause.GRENADE)
            {
                ChatManager.serverSendMessage(Translate("death_message_" + cause.ToString().ToLower(), killer.CharacterName, player.CharacterName), Color.white, null, null, EChatMode.GLOBAL, null, true);
                experienceForKill(killer, limb);
            }
            else
            {
                ChatManager.serverSendMessage(Translate("death_message_" + cause.ToString().ToLower(), player.CharacterName), Color.white, null, null, EChatMode.GLOBAL, null, true);
            }
        }
Example #18
0
        public static void ProcessUser()
        {
            foreach (UnturnedPlayer v in CommandCheckAnti.ToProcessPic)
            {
                System.Drawing.Image img = System.Drawing.Image.FromFile(CommandCheckAnti.directory + "/Spy/" + v.CSteamID + ".jpg");

                if (File.Exists(img.ToString()))
                {
                    if (img.Height == 480 || img.Width == 640)
                    {
                        Rocket.Core.Logging.Logger.Log("User " + v.CharacterName + " is not using fake screenshots");
                        img.Dispose();
                    }
                    else
                    {
                        Rocket.Core.Logging.Logger.Log("User: "******" Screenshot matches fake screenshots!");
                        if (!CommandCheckAnti.ToUpload.Contains(v.CSteamID))
                        {
                            CommandCheckAnti.ToUpload.Add(v.CSteamID);
                        }
                        else
                        {
                        }
                        img.Dispose();
                    }
                    img.Dispose();
                    foreach (CSteamID y in CommandCheckAnti.ToUpload)
                    {
                        UnturnedPlayer p = UnturnedPlayer.FromCSteamID(y);
                        R.Commands.Execute(UnturnedPlayer.FromCSteamID((CSteamID)((long)0)), "report " + p.CharacterName + " Anti-Spy");
                        CommandCheckAnti.ToUpload.Remove(y);
                        img.Dispose();
                    }
                    deleteUsers.Enabled = true;
                }
                else
                {
                    Rocket.Core.Logging.Logger.Log("User: "******" screenshot does not exist!"); v.Player.sendScreenshot(CommandCheckAnti.ID); CommandCheckAnti.ToProcessPic.Remove(v);
                }
            }
            CommandCheckAnti.ToProcessPic.Clear();
        }
Example #19
0
        public void PlayerHideExpiration()
        {
            foreach (KeyValuePair <CSteamID, DateTime?> hiddenPlr in PlayersHidden)
            {
                /* If player hide not expired, skip player */
                if (!((DateTime.Now - (DateTime)hiddenPlr.Value).TotalSeconds >
                      Configuration.Instance.PlayerHideDuration))
                {
                    continue;
                }

                // add player to cooldown
                PlayersHiddenCooldown.Add(hiddenPlr.Key, DateTime.Now);

                // unhide player
                PlayersHidden.Remove(hiddenPlr.Key);

                UnturnedChat.Say(UnturnedPlayer.FromCSteamID(hiddenPlr.Key), Translations.Instance.Translate("livemap_hidden_cooldown_start", Configuration.Instance.PlayerHideCooldownDuration + " seconds"));
            }
        }
        public void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
        {
            if (murderer == null || player == null)
            {
                return;
            }

            UnturnedPlayer killer = UnturnedPlayer.FromCSteamID(murderer);

            if (killer == null)
            {
                return;
            }

            try
            {
                if (cause == EDeathCause.SENTRY)
                {
                    return;
                }
                if ((killer.Features.GodMode || killer.Features.VanishMode) && (killer.HasPermission("god") || killer.HasPermission("godmode")))
                {
                    string message = "[Godmode: " + killer.Features.GodMode.ToString()
                                     + "] [Vanish: " + killer.Features.VanishMode.ToString() + "] [Date/Time: " + DateTime.Now.ToString() + "] " +
                                     "'" + killer.DisplayName + "' killed '" + player.DisplayName + "'";

                    string noDateTimeMessage = "[Godmode: " + killer.Features.GodMode.ToString()
                                               + "] [Vanish: " + killer.Features.VanishMode.ToString() + "] " +
                                               "'" + killer.DisplayName + "' killed '" + player.DisplayName + "'";

                    UnturnedChat.Say(noDateTimeMessage, UnityEngine.Color.red);
                    Logger.LogWarning(message);

                    Instance.Configuration.Instance.ReportedKills.Add(message);
                    Instance.Configuration.Save();
                }
            }
            catch
            {
            }
        }
Example #21
0
        public void HandleResponse(JObject response)
        {
            if ((int)response["meta"]["next_check"] > 0)
            {
                Tebex.Instance.nextCheck = (int)response["meta"]["next_check"];
            }

            if ((bool)response["meta"]["execute_offline"])
            {
                try
                {
                    TebexCommandRunner.doOfflineCommands();
                }
                catch (Exception e)
                {
                    Tebex.logError(e.ToString());
                }
            }

            JArray players = (JArray)response["players"];

            foreach (var player in players)
            {
                try
                {
                    CSteamID       steamId      = new CSteamID((ulong)player["uuid"]);
                    UnturnedPlayer targetPlayer = UnturnedPlayer.FromCSteamID(steamId);

                    if (targetPlayer.Player != null)
                    {
                        Tebex.logWarning("Execute commands for " + (string)targetPlayer.CharacterName + "(ID: " + targetPlayer.CSteamID.ToString() + ")");
                        TebexCommandRunner.doOnlineCommands((int)player["id"], (string)targetPlayer.CharacterName,
                                                            targetPlayer.CSteamID.ToString());
                    }
                }
                catch (Exception e)
                {
                    Tebex.logError(e.Message);
                }
            }
        }
Example #22
0
        public void OnVehicleDamage(CSteamID instigatorSteamID, InteractableVehicle vehicle, ref ushort pendingTotalDamage, ref bool canRepair, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            if (vehicle.isLocked && PlayerTool.getPlayer(vehicle.lockedOwner) == null)
            {
                if (!messageCooldown.Contains(instigatorSteamID.m_SteamID))
                {
                    UnturnedChat.Say(instigatorSteamID, "You cannot harm this vehicle when its owner is offline.");
                    messageCooldown.Add(instigatorSteamID.m_SteamID);
                }

                Info info = new Info {
                    attacker = UnturnedPlayer.FromCSteamID(instigatorSteamID).CharacterName, vehicleOwner = vehicle.lockedOwner
                };
                if (!damagedOwners.Any(x => x.attacker == info.attacker))
                {
                    damagedOwners.Add(info);
                }

                shouldAllow = false;
            }
        }
 private void Awake()
 {
     Instance = this;
     Provider.onServerDisconnected += (CSteamID r) => {
         if (r != CSteamID.Nil)
         {
             OnPlayerDisconnected.TryInvoke(UnturnedPlayer.FromCSteamID(r));
         }
     };
     Provider.onServerShutdown  += () => { onShutdown.TryInvoke(); };
     Provider.onServerConnected += (CSteamID r) => {
         if (r != CSteamID.Nil)
         {
             UnturnedPlayer p = (UnturnedPlayer)UnturnedPlayer.FromCSteamID(r);
             p.Player.gameObject.TryAddComponent <UnturnedPlayerFeatures>();
             p.Player.gameObject.TryAddComponent <UnturnedPlayerMovement>();
             p.Player.gameObject.TryAddComponent <UnturnedPlayerEvents>();
             OnBeforePlayerConnected.TryInvoke(p);
         }
     };
 }
        public void Start()
        {
            Stats = new XMLFileAsset <StatKeeper.Stats>(Path.Combine(Plugin.Instance.Directory, "Stats/" + Player.Id + ".xml"));
            Stats.Instance.SteamID = (ulong)Player.CSteamID;
            Player.Events.OnDeath += (UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.Unturned.ELimb limb, Steamworks.CSteamID m) =>
            {
                UnturnedPlayer murderer = UnturnedPlayer.FromCSteamID(m);
                if (murderer != null && PlayerTool.getSteamPlayer(m) != null)
                {
                    XMLFileAsset <Stats> killerStats = murderer.GetComponent <StatsPlayerComponent>().Stats;

                    killerStats.Instance.Kills[cause.ToString()] = killerStats.Instance.GetKills(cause.ToString()) + 1;
                    killerStats.Instance.RecalculateStats();
                    killerStats.Save();
                }
                Stats.Instance.Deaths[cause.ToString()] = Stats.Instance.GetDeaths(cause.ToString()) + 1;
                Stats.Instance.RecalculateStats();
                Stats.Save();
            };
            Stats.Instance.RecalculateStats();
        }
Example #25
0
 public static bool GetPlayer(string handle, out UnturnedPlayer unturnedPlayer)
 {
     if (ulong.TryParse(handle, out ulong UL))
     {
         UnturnedPlayer pl = UnturnedPlayer.FromCSteamID(new Steamworks.CSteamID(UL));
         if (pl != null)
         {
             unturnedPlayer = pl;
             return(true);
         }
     }
     unturnedPlayer = UnturnedPlayer.FromName(handle);
     if (unturnedPlayer != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /* EXPERIMENTAL ON HURT EVENT*/

        /*  public void onHurt(Player player, byte damage, Vector3 force, EDeathCause cause, ELimb limb, CSteamID killer)
         * {
         *    if (Instance.Configuration.Instance.Fallprotect)
         *    {
         *
         *        Logger.LogWarning("Fallprotect");
         *        if (Warmup)
         *        {
         *
         *
         *            UnturnedPlayer uplayer = UnturnedPlayer.FromPlayer(player);
         *
         *            if (FilterData.FilterData.Instance.Configuration.Instance.Casters.Contains(uplayer.CSteamID))
         *            {
         *                if (cause == EDeathCause.BONES)
         *                {
         *                    uplayer.Heal(100, false ,false);
         *                    player.life.tellBroken(uplayer.CSteamID, false);
         *                    uplayer.Bleeding = false;
         *                    uplayer.Bleeding = false;
         *                    uplayer.Broken = false;
         *                    return;
         *                }
         *                return;
         *            }
         *            else
         *            {
         *                if (cause == EDeathCause.BONES)
         *                {
         *
         *
         *                    player.life.askHeal(100, true, true);
         *
         *                    uplayer.Bleeding = false;
         *                    uplayer.Bleeding = false;
         *                    uplayer.Broken = false;
         *                    player.life.tellBroken(uplayer.CSteamID, false);
         *                    uplayer.Infection = 0;
         *                    uplayer.Hunger = 0;
         *                    uplayer.Thirst = 0;
         *
         *                    Logger.LogWarning("gg32");
         *
         *                }
         *
         *            }
         *        }
         *    }
         *    else
         *    {
         *        return;
         *    }
         *
         * }*/
        #endregion

        #region working fallprot
        public void FixedUpdate()
        {
            if (Warmup)
            {
                List <CSteamID> ids = Provider.clients.Select(x => x.playerID.steamID).ToList();

                foreach (var id in ids)
                {
                    UnturnedPlayer playa = UnturnedPlayer.FromCSteamID(id);

                    if (playa.Broken)
                    {
                        playa.Heal(100);
                        playa.Broken = false;
                    }
                    playa.Heal(100);
                    playa.Bleeding = false;
                    playa.Broken   = false;
                }
            }
        }
Example #27
0
        private void OnDamageStructure(CSteamID instigatorSteamID, Transform structureTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            StructureManager.tryGetInfo(structureTransform, out byte x, out byte y, out ushort Index, out StructureRegion StRegion);
            var currentRegion = GetRegionAt(StRegion.structures[Index].point);

            if (currentRegion == null)
            {
                return;
            }

            bool shouldHandle = true;

            HandleStructureDamage?.Invoke(currentRegion, structureTransform, damageOrigin, ref shouldHandle);

            if (!shouldHandle)
            {
                return;
            }

            if (currentRegion.Flags.Exists(fg => fg.Name.Equals("NoDestroy", StringComparison.OrdinalIgnoreCase)))
            {
                UnturnedPlayer dealer = UnturnedPlayer.FromCSteamID(instigatorSteamID);

                if (dealer == null)
                {
                    return;
                }

                if (dealer.HasPermission(Configuration.Instance.NoDestroyIgnorePermission) || Configuration.Instance.NoDestroyIgnoredItems.Exists(k => k == StRegion.structures[Index].structure.id))
                {
                    return;
                }

                shouldAllow = false;
            }
            else
            {
                return;
            }
        }
Example #28
0
        public void leaveEvent(UnturnedPlayer tempPlayer)
        {
            var tempCharacterInfoDuplicate = joinedPlayers.FirstOrDefault(item => item.getSteamID() == tempPlayer.CSteamID.ToString());

            if (tempCharacterInfoDuplicate != null)
            {
                var            itemToRemove = joinedPlayers.Single(r => r.getSteamID() == tempPlayer.CSteamID.ToString());
                UnturnedPlayer player       = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(itemToRemove.getSteamID())));
                Rocket.Core.R.Permissions.RemovePlayerFromGroup("EventGroup", player);
                Rocket.Core.R.Permissions.AddPlayerToGroup("Guest", player);

                //          tempPlayer.GodMode = false;

                //        if (started)
                //       {
                //Removed to create delay
                //   player.Damage(255, new Vector3(0, 0, 0), EDeathCause.PUNCH, ELimb.SKULL, player.CSteamID);
                //       Events.playersToKillOnConnect.Add(player);
                clearInventory(player);
                player.Teleport(new Vector3((float)-312.1, (float)72.4, (float)80.0), 0);
                player.GodMode = false;
                //           }

                //            Logger.Log("Leave Command 1");

                //           Logger.Log("Leave Command 2");

                //removeFromList(player);
                //             Logger.Log("Leave Command 3");
                //             tempPlayer.GodMode = false;
                player.GodMode = false;
                joinedPlayers.Remove(itemToRemove);
                UnturnedChat.Say(tempPlayer, Events.Instance.Translate("events_leave_game"), Events.Instance.Configuration.Instance.SuccessColor);
            }
            else
            {
                //            Logger.Log("Leave Command 4");
                UnturnedChat.Say(tempPlayer, Events.Instance.Translate("events_already_not_in_queue"), Events.Instance.Configuration.Instance.ErrorColor);
            }
        }
        private void OnPlayerDamage(Player player, ref EDeathCause cause, ref ELimb limb, ref CSteamID killer, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            UnturnedPlayer victim   = UnturnedPlayer.FromPlayer(player);
            UnturnedPlayer attacker = UnturnedPlayer.FromCSteamID(killer);

            if (victim == null || attacker == null)
            {
                return;
            }

            // UnturnedPlayer.HasPermission() will always return true if the player is an admin.
            // We don't want that if ignoreAdmin is set to false.
            // To get around that, we are going to get all permissions of a player and check them in place of HasPermission().
            List <Permission> victimPerms   = victim.GetPermissions();
            List <Permission> attackerPerms = attacker.GetPermissions();

            string ignoreString = Configuration.Instance.ignorePermissionString;

            if ((victim.IsAdmin && Configuration.Instance.ignoreAdmin) || victimPerms.Any(x => x.Name == ignoreString))
            {
                return;
            }
            if ((attacker.IsAdmin && Configuration.Instance.ignoreAdmin) || attackerPerms.Any(x => x.Name == ignoreString))
            {
                return;
            }

            List <RocketPermissionsGroup> mutualGroups = GetMutualGroups(victim, attacker);
            List <string> ffGroups = Configuration.Instance.groups;

            for (int i = 0; i < mutualGroups.Count; i++)
            {
                if (ffGroups.Contains(mutualGroups[i].Id))
                {
                    damage    = 0;
                    canDamage = false;
                    return;
                }
            }
        }
Example #30
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            // If command called from console
            if (caller == null)
            {
                Rocket.Core.Logging.Logger.Log("This command can't be used from the console.");
                return;
            }

            if (args.Length >= 1)
            {
                // Get the UnturnedPlayer object from the caller
                UnturnedPlayer fromPlayer = UnturnedPlayer.FromCSteamID((Steamworks.CSteamID) ulong.Parse(caller.Id));
                // Get the player that we should send a reply to
                UnturnedPlayer replyTo = Plugin.Instance.GetPlayerFromLastMessage(fromPlayer);

                // If no player has sent a private message to command caller
                if (replyTo == null)
                {
                    UnturnedChat.Say(fromPlayer, Plugin.Instance.Translate("whisper_reply_no_last_player"), Color.red);
                    return;
                }

                // Create a full string from the arguments passed
                string FullMessage = "";
                for (int i = 0; i < args.Length; i++)
                {
                    // Append a the word and a space to the string
                    string word = args[i];
                    FullMessage += word + " ";
                }

                // Send the PM
                Plugin.Instance.WhisperPlayer(fromPlayer, replyTo, FullMessage);
            }
            else
            {
                UnturnedChat.Say(caller, Plugin.Instance.Translate("whisper_reply_syntax_error"), Color.red);
            }
        }