void SlapCommand(IPlayer player, string command, string[] args) { if (!player.HasPermission(permUse)) { player.Reply(Lang("NotAllowed", player.Id, command)); return; } if (args.Length == 0) { player.Reply(Lang("CommandUsage", player.Id, command)); return; } if (player.Id != "server_console") { if (!cooldowns.ContainsKey(player.Id)) { cooldowns.Add(player.Id, 0f); } if (cooldown != 0 && cooldowns[player.Id] + cooldown > Interface.Oxide.Now) { player.Reply(Lang("Cooldown", player.Id)); return; } } var target = players.FindPlayer(args[0]); if (target == null || !target.IsConnected) { player.Reply(Lang("PlayerNotFound", player.Id, args[0])); return; } timer.Repeat(0.6f, args.Length == 2 ? Convert.ToInt32(args[1]) : 1, () => SlapPlayer(target)); if (!target.Equals(player)) { player.Reply(Lang("PlayerSlapped", player.Id, target.Name.Sanitize())); } target.Message(slappedBy ? Lang("YouGotSlappedBy", target.Id, player.Name.Sanitize()) : Lang("YouGotSlapped", target.Id)); cooldowns[player.Id] = Interface.Oxide.Now; }
private void PopupMessage(BasePlayer player, string msg) { var element = UI.CreateElementContainer(UIPopup, UI.Color("#2a2a2a", 0.98f), "0.33 0.45", "0.67 0.6"); UI.CreatePanel(ref element, UIPopup, UI.Color("#696969", 0.4f), "0.01 0.04", "0.99 0.96"); UI.CreateLabel(ref element, UIPopup, $"{UI.Color("#2a2a2a", 0.9f)}{msg}</color>", 22, "0 0", "1 1"); if (popupMessages.ContainsKey(player.userID)) { CuiHelper.DestroyUi(player, UIPopup); popupMessages[player.userID].Destroy(); popupMessages.Remove(player.userID); } CuiHelper.AddUi(player, element); popupMessages.Add(player.userID, timer.In(3.5f, () => { CuiHelper.DestroyUi(player, UIPopup); popupMessages.Remove(player.userID); })); }
private void HealCommand(IPlayer player, string command, string[] args) { float amount; if (args.Length > 0) { float.TryParse(args[0], out amount); } if (amount > maxAmount || amount.Equals(0)) { amount = maxAmount; } IPlayer target; if (args.Length >= 2) { target = players.FindPlayer(args[1]); // TODO: Use FindPlayers and and handle multiple players } else if (args.Length == 1) { target = players.FindPlayer(args[0]); } else { target = player; } if ((Equals(target, player) && !player.HasPermission(permSelf)) || !player.HasPermission(permOthers)) { Reply(player, "NotAllowed", player.Id, command); return; } if (args.Length == 0 && target.Id == "server_console") { Reply(player, "CommandUsage", player.Id, command); return; } if (target.Id == "server_console" || !target.IsConnected) { var name = args.Length >= 2 ? args[1] : args.Length == 1 ? args[0] : ""; Reply(player, "PlayerNotFound", player.Id, name); return; } if (player.Id != "server_console") { if (!cooldowns.ContainsKey(player.Id)) { cooldowns.Add(player.Id, 0f); } if (cooldown != 0 && cooldowns[player.Id] + cooldown > Interface.Oxide.Now) { Reply(player, "Cooldown", player.Id, command); return; } } if (amount > maxAmount || amount.Equals(0)) { amount = maxAmount; } Heal(target, amount); cooldowns[player.Id] = Interface.Oxide.Now; Reply(target, "YouWereHealed", player.Id, amount); // TODO: Only show amount to max health if (!Equals(target, player)) { Reply(player, "PlayerWasHealed", player.Id, target.Name.Sanitize(), amount); } }
void God(BasePlayer player, string cmd, string[] args) { if (!IsAllowed(player, "CanUseGodmode")) { return; } if (args.Length == 0) { if (gods[player.userID] != null) { DisableGodmode(player); SendChatMessage(player, disabled); } else { EnableGodmode(player); SendChatMessage(player, enabled); } return; } var name = args[0]; if (name == "list") { if (matches[player] == null) { SendChatMessage(player, noListAvailable); return; } if (args.Length == 1) { ShowMatchingPlayers(player); return; } int index; if (!int.TryParse(args[1], out index)) { SendChatMessage(player, invalidSelection); return; } if (index > matches[player].Count) { SendChatMessage(player, invalidSelection); } else { ToggleGodmode(player, matches[player][index - 1]); } return; } var playerMatches = FindPlayersByName(name); if (playerMatches.Count < 1) { SendChatMessage(player, playerNotFound); return; } if (playerMatches.Count == 1) { ToggleGodmode(player, playerMatches[0]); return; } if (playerMatches.Count > 1) { matches.Add(player, playerMatches); ShowMatchingPlayers(player); return; } }
private void OnEntityTakeDamage(BaseEntity entity, HitInfo info) { var victim = entity.ToPlayer(); var attacker = info?.Initiator?.ToPlayer(); // Check if victim and attacker are invalid or equal if (victim == null || attacker == null || victim.Equals(attacker)) { return; } // Check if victim or attacker is an NPCPlayer (ie. murderer) if (entity is NPCPlayer || info.Initiator is NPCPlayer) { return; } // Check if victim or attacker is an NPCPlayerApex (ie. scientist) if (entity is NPCPlayerApex || info.Initiator is NPCPlayerApex) { return; } // Check if victim or attacker is a manually spawned BasePlayer if (victim.Connection == null || attacker.Connection == null) { return; } // Make sure player isn't using ranged weapons if (info.IsProjectile()) { return; } // Check if victim is protected from being mugged if (permission.UserHasPermission(victim.UserIDString, permProtection)) { return; } // Check if attacker is allowed to mug if (!permission.UserHasPermission(attacker.UserIDString, permMugging)) { return; } // Check if victim or attacker are in a loot zone, are friends, or share a clan if (InNoLootZone(victim, attacker) || IsFriend(victim, attacker) || IsClanmate(victim, attacker)) { return; } // Check for a cooldown and set one if it doesn't exist if (!cooldowns.ContainsKey(attacker.UserIDString)) { cooldowns.Add(attacker.UserIDString, 0f); } if (config.UsageCooldown != 0 && cooldowns[attacker.UserIDString] + config.UsageCooldown > Interface.Oxide.Now) { Player.Reply(attacker, Lang("Cooldown", attacker.UserIDString)); return; } // Check if config options are enabled for stealing if (config.ItemStealing) { StealItem(victim, attacker); } if (config.MoneyStealing) { StealMoney(victim, attacker); } if (config.PointStealing) { StealPoints(victim, attacker); } // Set time for next cooldown check cooldowns[attacker.UserIDString] = Interface.Oxide.Now; }
private void HealCommand(IPlayer player, string command, string[] args) { var amount = 0f; if (args.Length > 0) { float.TryParse(args[0], out amount); } if (amount > config.MaxAmount || amount.Equals(0f)) { amount = config.MaxAmount; } IPlayer target; if (args.Length >= 2) { target = FindPlayer(args[1], player); } else if (args.Length == 1) { target = players.FindPlayer(args[0]); } else { target = player; } // TODO: Show message and return if server is trying to heal self if (target == null) { return; } if ((Equals(target, player) && !player.HasPermission(permSelf)) || !player.HasPermission(permOthers)) { Message(player, "NotAllowed", command); return; } if (args.Length == 0 && target.IsServer) { Message(player, "CommandUsage", command); return; } if (target.IsServer || !target.IsConnected) { var name = args.Length >= 2 ? args[1] : args.Length == 1 ? args[0] : ""; Message(player, "PlayerNotFound", name); return; } if (!player.IsServer) { if (!cooldowns.ContainsKey(player.Id)) { cooldowns.Add(player.Id, 0f); } if (config.Cooldown != 0 && cooldowns[player.Id] + config.Cooldown > Interface.Oxide.Now) { Message(player, "Cooldown", command); return; } } if (amount > config.MaxAmount || amount.Equals(0)) { amount = config.MaxAmount; } Heal(target, amount); cooldowns[player.Id] = Interface.Oxide.Now; Message(target, "YouWereHealed", amount); if (!Equals(target, player)) { Message(player, "PlayerWasHealed", target.Name.Sanitize(), amount); } }
//SKIP void Init() { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("DateCore"); foreach (BasePlayer ply in BasePlayer.activePlayerList) { if (!Timers.ContainsKey(ply)) { Timer tm = timer.Repeat(5f, 0, () => { String msg = "Current serverdate(rust-days): " + storedData.rustdayyear + "(" + storedData.rustdaystr + ") - " + storedData.rustmonth + "(" + storedData.rustmonthstring + ") - " + storedData.rustyear; DestroyGui(ply); LoadMsgGui(msg, ply); }); Timers.Add(ply, tm); } } Puts("##DateCore##"); Puts("Initiating cores and registering timers"); Load(); timer.Repeat(1, 0, () => { try { if (storedData.day == 0) { if (Math.Floor(TOD_Sky.Instance.Cycle.Hour) == 12) { storedData.day = 1; storedData.rustday = storedData.rustday + 1; storedData.rustdayyear = storedData.rustdayyear + 1; storedData.rustdayweek = storedData.rustdayweek + 1; rustday(); decimal dec = storedData.rustday / 7; storedData.rustweek = int.Parse(Math.Floor(dec).ToString()); if (storedData.rustdayweek == 8) { storedData.rustdayweek = 1; } if (storedData.rustdayweek == 1) { storedData.rustdaystr = "Monday"; } if (storedData.rustdayweek == 2) { storedData.rustdaystr = "Tuesday"; } if (storedData.rustdayweek == 3) { storedData.rustdaystr = "Wednesday"; } if (storedData.rustdayweek == 4) { storedData.rustdaystr = "Thursday"; } if (storedData.rustdayweek == 5) { storedData.rustdaystr = "Friday"; } if (storedData.rustdayweek == 6) { storedData.rustdaystr = "Saturday"; } if (storedData.rustdayweek == 7) { storedData.rustdaystr = "Sunday"; } if (storedData.rustdayyear == 365) { storedData.rustdayyear = 0; storedData.rustyear = storedData.rustyear + 1; rustyear(); } if ((storedData.rustyear / 4).ToString().Contains(".") == false) { if (storedData.rustdayyear == 0) { storedData.rustmonthstring = Months[0]; storedData.rustmonth = 1; rustmonth(); } if (storedData.rustdayyear - 31 + 1 == 1) { storedData.rustmonthstring = Months[1]; storedData.rustmonth = 2; rustmonth(); } if (storedData.rustdayyear - 31 - 28 + 1 == 1) { storedData.rustmonthstring = Months[2]; storedData.rustmonth = 3; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 + 1 == 1) { storedData.rustmonthstring = Months[3]; storedData.rustmonth = 4; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[4]; storedData.rustmonth = 5; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[5]; storedData.rustmonth = 6; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[6]; storedData.rustmonth = 7; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[7]; storedData.rustmonth = 8; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 + 1 == 1) { storedData.rustmonthstring = Months[8]; storedData.rustmonth = 9; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[9]; storedData.rustmonth = 10; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[10]; storedData.rustmonth = 11; rustmonth(); } if (storedData.rustdayyear - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[11]; storedData.rustmonth = 12; rustmonth(); } } else { if (storedData.rustdayyear == 0) { storedData.rustmonthstring = Months[0]; storedData.rustmonth = 1; rustmonth(); } if (storedData.rustdayyear - 31 + 1 == 1) { storedData.rustmonthstring = Months[1]; storedData.rustmonth = 2; rustmonth(); } if (storedData.rustdayyear - 31 - 29 + 1 == 1) { storedData.rustmonthstring = Months[2]; storedData.rustmonth = 3; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 + 1 == 1) { storedData.rustmonthstring = Months[3]; storedData.rustmonth = 4; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[4]; storedData.rustmonth = 5; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[5]; storedData.rustmonth = 6; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[6]; storedData.rustmonth = 7; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[7]; storedData.rustmonth = 8; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 + 1 == 1) { storedData.rustmonthstring = Months[8]; storedData.rustmonth = 9; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[9]; storedData.rustmonth = 10; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 + 1 == 1) { storedData.rustmonthstring = Months[10]; storedData.rustmonth = 11; rustmonth(); } if (storedData.rustdayyear - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 - 30 + 1 == 1) { storedData.rustmonthstring = Months[11]; storedData.rustmonth = 12; rustmonth(); } } Interface.GetMod().DataFileSystem.WriteObject <StoredData>("DateCore", storedData); } } else { if (Math.Floor(TOD_Sky.Instance.Cycle.Hour) == 0) { storedData.day = 0; } } Interface.GetMod().DataFileSystem.WriteObject <StoredData>("DateCore", storedData); } catch { } }); Puts("Done bootingup DateCore!"); }