private void GodsCommand(IPlayer iPlayer, string command, string[] args) { if (!iPlayer.HasPermission(permAdmin)) { Print(iPlayer, Lang("NotAllowed", iPlayer.Id, command)); return; } if (storedData.godPlayers.Count == 0) { Print(iPlayer, Lang("NoGods", iPlayer.Id)); return; } string result = string.Empty; foreach (var god in storedData.godPlayers) { BasePlayer player = RustCore.FindPlayerByIdString(god); if (player == null) { continue; } result += $"\n[{god}] {player.displayName}"; } Print(iPlayer, result); }
public BasePlayer FindPlayerByIdString(string id) => RustCore.FindPlayerByIdString(id);
private void HandleTimer(ulong horseid, ulong userid, bool start = false) { if (htimer.ContainsKey(horseid)) { if (start) { htimer[horseid].timer = timer.Once(htimer[horseid].countdown, () => HandleTimer(horseid, userid, false)); if (configData.Options.debug) { Puts($"Started release timer for horse {horseid.ToString()} owned by {userid.ToString()}"); } } else { if (htimer.ContainsKey(horseid)) { htimer[horseid].timer.Destroy(); htimer.Remove(horseid); } try { BaseNetworkable horse = BaseNetworkable.serverEntities.Find((uint)horseid); BasePlayer player = RustCore.FindPlayerByIdString(userid.ToString()); RidableHorse mounted = player.GetMounted().GetComponentInParent <RidableHorse>(); if (mounted.net.ID == horseid && configData.Options.ReleaseOwnerOnHorse) { // Player is on this horse and we allow ownership to be removed while on the horse mounted.OwnerID = 0; horses.Remove(horseid); if (configData.Options.debug) { Puts($"Released horse {horseid.ToString()} owned by {userid.ToString()}"); } } else if (mounted.net.ID == horseid && !configData.Options.ReleaseOwnerOnHorse) { // Player is on this horse and we DO NOT allow ownership to be removed while on the horse // Reset the timer... htimer.Add(horseid, new HTimer() { start = Time.realtimeSinceStartup, countdown = configData.Options.ReleaseTime, userid = userid }); htimer[horseid].timer = timer.Once(configData.Options.ReleaseTime, () => HandleTimer(horseid, userid)); if (configData.Options.debug) { Puts($"Reset ownership timer for horse {horseid.ToString()} owned by {userid.ToString()}"); } } else { // Player is NOT mounted on this horse... BaseEntity bhorse = horse as BaseEntity; bhorse.OwnerID = 0; horses.Remove(horseid); if (configData.Options.debug) { Puts($"Released horse {horseid.ToString()} owned by {userid}"); } } SaveData(); } catch { BaseNetworkable horse = BaseNetworkable.serverEntities.Find((uint)horseid); BaseEntity bhorse = horse as BaseEntity; bhorse.OwnerID = 0; horses.Remove(horseid); SaveData(); if (configData.Options.debug) { Puts($"Released horse {horseid.ToString()} owned by {userid}"); } } } } }