private void msgPlayer(BasePlayer attacker, BaseEntity entity) { double time2 = PlaytimeTracker?.Call <double>("GetPlayTime", entity.OwnerID.ToString()) ?? -1d; if (time2 == -1d) { return; } int left = (int)(time - time2); if (show) { if (playerIsNew(entity.OwnerID)) { if (showTime) { SendReply(attacker, lang.GetMessage("cannot_attack_time", this, attacker.UserIDString), CheckLeft(left)); return; } SendReply(attacker, lang.GetMessage("cannot_attack_no_time", this, attacker.UserIDString)); return; } SendReply(attacker, lang.GetMessage("can_attack", this, attacker.UserIDString)); } }
object OnStructureDemolish(BuildingBlock block, BasePlayer player) { if (!MustOwnDemolish || HasPerms(player.UserIDString, "hammertime.demolishoverride") || block.OwnerID == 0 || block.OwnerID == player.userID) { return(null); } if (FriendsCanDemolish) { var hasFriend = Friends?.Call <bool>("HasFriend", block.OwnerID, player.userID) ?? false; if (hasFriend) { return(null); } } if (ClanCanDemolish) { var ownerClan = Clans?.Call <string>("GetClanOf", block.OwnerID.ToString()) ?? string.Empty; var targetClan = Clans?.Call <string>("GetClanOf", player.UserIDString) ?? string.Empty; if (!string.IsNullOrEmpty(ownerClan) && !string.IsNullOrEmpty(targetClan) && (targetClan == ownerClan)) { return(null); } } if (block.OwnerID != player.userID) { SendReply(player, GetMessage("doesNotOwnDemo", player.UserIDString)); return(true); } return(null); }
private void EjectPlayer(BasePlayer player, string zoneId) { float distance = 0; object success = ZoneManager?.Call("GetZoneLocation", zoneId); if (success is Vector3) { Vector3 position = (Vector3)success; success = ZoneManager?.Call("GetZoneSize", zoneId); if (success is Vector3 && (Vector3)success != Vector3.zero) { Vector3 size = (Vector3)success; distance = size.x > size.z ? size.x : size.z; } else { success = ZoneManager?.Call("GetZoneRadius", zoneId); } if (success is float && (float)success != 0) { distance = (float)success; } Vector3 newPosition = position + (player.transform.position - position).normalized * (distance + 10f); newPosition = CalculateGroundPos(newPosition); player.MovePosition(newPosition); player.ClientRPCPlayer(null, player, "ForcePositionTo", player.transform.position); player.SendNetworkUpdateImmediate(); } }
private void OnPlayerDisconnected(BasePlayer player, string reason) { if (!useClans) { ClosePlayerDoors(player); return; } var clan = Clans?.Call <string>("GetClanOf", player.userID) ?? string.Empty; if (string.IsNullOrEmpty(clan)) { //Not in clan/clan plugin is missing ClosePlayerDoors(player); return; } var clannies = GetOnlineClanMembers(clan); if (clannies.Contains(player.userID)) { clannies.Remove(player.userID); } if (clannies.Count == 0) { ClosePlayerDoors(player); return; } return; }
void CommandPrepare(BasePlayer player, string command, string[] args) { if (!permission.UserHasPermission(player.UserIDString, "hungergames.admin")) { return; } if (registrationOpen) { player.IPlayer.Reply("Hunger Games registration is already open."); return; } object zone = (string)ZoneManager?.Call("GetZoneName", START_ZONE); if (zone == null) { player.IPlayer.Reply("Start zone must be set before preparing Hunger Games."); return; } tributes = new List <BasePlayer>(); registrationOpen = true; // TODO: Global chat message + GUI Puts(player.IPlayer.Name + " has opened registration for Hunger Games."); player.IPlayer.Reply("Hunger Games registration opened."); }
void OnServerInitialized() { ulong imageId = 666999666999; if (ImageLibrary == true) { bool exists = (bool)ImageLibrary?.Call("HasImage", "mapmypatrolblue", imageId); if (exists == false) { // ImageLibrary?.Call ("AddImage","https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Maki-heliport-15.svg/240px-Maki-heliport-15.svg.png", "mapmypatrolblack", imageId); ImageLibrary?.Call("AddImage", "https://image.ibb.co/eCiHqK/Map_My_Patrol_icone_HUD_blue.png", "mapmypatrolblue", imageId); if (debug == true) { Puts($"ADDING ICON TO ImageLibrary"); } } if (debug == true) { Puts($"LOADING ICON from ImageLibrary"); } icondapatrol = (string)ImageLibrary?.Call("GetImage", "mapmypatrolblue", imageId); } if (ImageLibrary == false) { PrintWarning($"You are missing plugin reference : ImageLibrary"); } }
void startSpawn(string position = null) { BaseEntity entity = null; if (position != null) { timer.Once(npcCoolDown, () => { entity = GameManager.server.CreateEntity(npcPrefab, position.ToVector3()) as NPCPlayer; entity.Spawn(); npcCreated.Add(entity.net.ID, position); Kits?.Call($"GiveKit", entity, Kit); entity.SendNetworkUpdate(); }); return; } foreach (var check in murdersPoint) { entity = GameManager.server.CreateEntity(npcPrefab, check.Key.ToVector3()) as NPCPlayer; if (entity != null) { entity.Spawn(); } Kits?.Call($"GiveKit", entity, Kit); npcCreated.Add(entity.net.ID, check.Key); entity.SendNetworkUpdate(); } Puts(msg("EndSpawn")); }
private object CanResearchItem(BasePlayer player, Item targetItem) { if (configData.AlreadyUnlocked && player.blueprints.HasUnlocked(targetItem.info)) { string message = lang.GetMessage("AlreadyUnlocked", this, player.UserIDString); if (configData.Popup) { PopupNotifications?.Call("CreatePopupNotification", message); } else { player.ChatMessage(configData.ChatPrefix + message); } return(true); } if (configData.Blocked.Contains(targetItem.info.shortname)) { string message = lang.GetMessage("BlockedItem", this, player.UserIDString); if (configData.Popup) { PopupNotifications?.Call("CreatePopupNotification", message); } else { player.ChatMessage(configData.ChatPrefix + message); } return(true); } return(null); }
private List <ulong> GetClanMembers(ulong ownerId) { List <ulong> authList = new List <ulong>(); var clanName = Clans?.Call("GetClanOf", ownerId); if (clanName != null) { var clan = Clans?.Call("GetClan", (string)clanName); if (clan != null && clan is JObject) { var members = (clan as JObject).GetValue("members"); if (members != null && members is JArray) { foreach (var member in (JArray)members) { ulong ID; if (!ulong.TryParse(member.ToString(), out ID)) { continue; } authList.Add(ID); } } } } return(authList); }
void OnPlayerInit(BasePlayer player) { if (player != null && (player.IsAdmin || player.IsDeveloper)) { if (player.IsDead() || player.IsSleeping()) { timer.Once(0.5f, () => OnPlayerInit(player)); return; } var user = GetUser(player); if (user.WakeOnLand) { float y = TerrainMeta.HeightMap.GetHeight(player.transform.position); player.Teleport(new Vector3(player.transform.position.x, y + 1f, player.transform.position.z)); } if (user.AutoNoClip) { player.SendConsoleCommand("noclip"); } if (autoVanish) { Vanish?.Call("Disappear", player); } } }
private void radiationTrap(Vector3 pos) { timer.Once(0.1f, () => Effect.server.Run("assets/bundled/prefabs/fx/smoke/generator_smoke.prefab", pos)); timer.Once(trapCountdown, () => { int randomNum = UnityEngine.Random.Range(1, 1000); string randID = ("boobytraps_" + randomNum); string[] zoneArgs = new string[4];; zoneArgs[0] = "radius"; zoneArgs[1] = radiationRadius.ToString(); zoneArgs[2] = "radiation"; zoneArgs[3] = radiationAmount.ToString(); if (pos == null) { return; } ZoneManager?.Call("CreateOrUpdateZone", randID, zoneArgs, pos); currentRadTraps.Add(randID); timer.Once(radiationDestroy, () => { ZoneManager?.Call("EraseZone", randID); currentRadTraps.Remove(randID); Puts("Radiation trap zone " + randID + " removed."); }); }); }
private void OnServerInitialized() { if (Economics) { timer.Repeat(0.5f, 0, () => { if (Economics.IsLoaded) { foreach (BasePlayer player in BasePlayer.activePlayerList) { double currentBalance = (double)Economics?.Call("Balance", player.UserIDString); if (Balances.ContainsKey(player.userID)) { double savedBalance = Balances[player.userID]; if (savedBalance != currentBalance) { if (!Looters.Contains(player.userID)) { Balances[player.userID] = currentBalance; GUIRefresh(player); } } } else { Balances.Add(player.userID, currentBalance); GUIRefresh(player); } } } }); } }
void cmdGood(NetUser netUser, string command, string[] args) { var username = netUser.displayName.ToString(); var Id = netUser.userID.ToString(); bool IsAdmin = (bool)AdminControl?.Call("IsAdmin", netUser); { if (!(netUser.CanAdmin() || IsAdmin || permission.UserHasPermission(Id, permissionCanGod))) { rust.SendChatMessage(netUser, lang.GetMessage("ChatTag", this), lang.GetMessage("NoPermission", this)); return; } if (Good.Contains(Id)) { rust.SendChatMessage(netUser, lang.GetMessage("ChatTag", this, Id), lang.GetMessage("GoodOff", this, Id)); netUser.playerClient.rootControllable.rootCharacter.takeDamage.SetGodMode(false); Good.Remove(Id); return; } else { rust.SendChatMessage(netUser, lang.GetMessage("ChatTag", this, Id), lang.GetMessage("GoodOn", this, Id)); netUser.playerClient.rootControllable.rootCharacter.takeDamage.SetGodMode(true); Good.Add(Id); return; } } }
void OnPlayerRespawn(BasePlayer player) { if ((bool)Config["PrefixEnabled"] == true) { if ((bool)Config["PopupEnabled"] == true) { PopupNotifications?.Call("CreatePopupNotification", Config["RespawnMessagePopup"].ToString()); } if ((bool)Config["ChatEnabled"] == true) { SendReply(player, Config["Prefix"].ToString() + " " + Config["RespawnMessageChat"].ToString()); } } else { if ((bool)Config["PopupEnabled"] == true) { PopupNotifications?.Call("CreatePopupNotification", Config["RespawnMessagePopup"].ToString()); } if ((bool)Config["ChatEnabled"] == true) { SendReply(player, Config["RespawnMessageChat"].ToString()); } } }
private void PrintToChatEx(BasePlayer player, string result, string tcolour = "#66FF66") { if (!Convert.ToBoolean(Config["bUsePopupNotifications"])) { if (Convert.ToBoolean(Config["bShowPluginName"])) { PrintToChat(player, "<color=\"" + tcolour + "\">[" + this.Title.ToString() + "]</color> " + result); } else { PrintToChat(player, result); } } else { if (PopupNotifications) { if (Convert.ToBoolean(Config["bShowPluginName"])) { PopupNotifications?.Call("CreatePopupNotification", "<color=" + tcolour + ">" + this.Title.ToString() + "</color>\n" + result, player); } else { PopupNotifications?.Call("CreatePopupNotification", result, player); } } } }
bool GetNearbyTargetWall(Vector3 hashPos, BasePlayer _player) { double RaidInitData = (GetTimeStamp() + RaidDelay); double RaidEndData = (GetTimeStamp() + RaidTimeLimit + RaidDelay); List <BaseEntity> entities = new List <BaseEntity>(); Vis.Entities(hashPos, RaidZone1, entities, wallCol); if (entities.Count > 0) { foreach (BaseEntity _entry in entities) { ulong _ownerID = _entry.OwnerID; if (_ownerID != 0) { //bool _testVar1 = false; //is player friend bool _testVar2 = false; //is player ulong target = _entry.OwnerID; var _test = RustIOFriendListAPI?.Call("ORFriends", _player.userID, _ownerID); bool _result = Convert.ToBoolean(_test); if (_ownerID == _player.userID) { _testVar2 = true; } if ((_result == false) && (_testVar2 == false)) { return(true); } } } } return(false); }
void OnServerInitialized() { ulong imageId = 666999666999666; if (ImageLibrary == true) { bool exists = (bool)ImageLibrary?.Call("HasImage", "cannibal_plugin_buzz", imageId); if (exists == false) { ImageLibrary?.Call("AddImage", "https://image.ibb.co/kZRdsK/cannibal_icon.jpg", "cannibal_plugin_buzz", imageId); if (debug == true) { Puts($"ADDING ICON TO ImageLibrary"); } } if (debug == true) { Puts($"LOADING ICON from ImageLibrary"); } cannibalicon = (string)ImageLibrary?.Call("GetImage", "cannibal_plugin_buzz", imageId); } if (ImageLibrary == false) { PrintWarning($"You are missing plugin reference : ImageLibrary"); } foreach (BasePlayer player in BasePlayer.activePlayerList) { if (storedData.Cannibalz.ContainsKey(player.userID)) { CannibalHUD(player); } } }
private void DeleteOldZones() { int _attempts = 0; int _sucesses = 0; string[] ZoneIDs = (string[])ZoneManager?.Call("GetZoneIDs"); if (ZoneIDs != null) { for (int i = 0; i < ZoneIDs.Length; i++) { string zoneName = (string)ZoneManager?.Call("GetZoneName", ZoneIDs[i]); if (zoneName == "DynamicPVP") { _attempts++; bool _success = DeleteDynZone(ZoneIDs[i]); if (_success) { _sucesses++; } } } DebugPrint($"Deleted {_sucesses} of {_attempts} existing DynamicPVP zones", true); } }
/// <summary> /// Вызывается, когда игрок что-либо построил /// </summary> /// <param name="plan">Шпатель</param> /// <param name="go">Строение, которое игрок построил</param> void OnEntityBuilt(Planner plan, GameObject go) { if (go == null || plan == null) { return; } BuildingPrivlidge privlidge = go.ToBaseEntity() as BuildingPrivlidge; if (privlidge == null) { return; } var player = plan.GetOwnerPlayer(); if (player == null) { return; } if (ignorePlayers.Contains(player.userID)) { return; } List <ulong> friends = Friends?.Call("ApiGetFriends", player.userID) as List <ulong>; if (friends == null) { return; } CupboardAuth(privlidge, friends); SendReply(player, Messages["deployCupboardMessage"]); }
void RecordIP(string steamid, string playerip) { var IPlist = new List <string>(); var success = PlayerDatabase?.Call("GetPlayerData", steamid, "IPs"); if (success is List <string> ) { IPlist = (List <string>)success; } if (IPlist.Contains(playerip)) { return; } if (IPlist.Count >= IPmaxLogs) { for (int i = 0; i < (IPlist.Count - IPmaxLogs + 1); i++) { IPlist.RemoveAt(0); } } IPlist.Add(playerip); PlayerDatabase.Call("SetPlayerData", steamid, "IPs", IPlist); }
void OnEntityDeath(BaseCombatEntity entity, HitInfo info) { if (!useBarrels) { return; } if (entity.ShortPrefabName == "loot-barrel-1" || entity.ShortPrefabName == "loot-barrel-2" || entity.ShortPrefabName == "loot_barrel_1" || entity.ShortPrefabName == "loot_barrel_2" || entity.ShortPrefabName == "oil_barrel") { if (!info.Initiator) { return; } if (!(info.Initiator is BasePlayer)) { return; } BasePlayer player = info.InitiatorPlayer; if (player == null) { return; } string userPermission = GetPermissionName(player); if (userPermission == null) { return; } // Checking for number of barrels hit if (!playerInfo.ContainsKey(player.UserIDString)) { playerInfo.Add(player.UserIDString, 0); } if (playerInfo[player.UserIDString] == givePointsEvery - 1) { // Section that gives the player their money if (useEconomy) { Economics?.CallHook("Deposit", player.userID, Convert.ToDouble(permissionList[userPermission])); if (sendNotificationMessage) { player.ChatMessage(string.Format(msg("Economy Notice (Barrel)", player.UserIDString), permissionList[userPermission].ToString())); } } if (useServerRewards) { ServerRewards?.Call("AddPoints", new object[] { player.userID, Convert.ToInt32(permissionList[userPermission]) }); if (sendNotificationMessage) { player.ChatMessage(string.Format(msg("RP Notice (Barrel)", player.UserIDString), permissionList[userPermission].ToString())); } } playerInfo[player.UserIDString] = 0; } else { playerInfo[player.UserIDString]++; } } }
string GetFormattedMoney(BasePlayer player) { string s = string.Format("{0:C}", (double)Economics?.Call("GetPlayerMoney", player.userID)); s = s.Substring(1); s = s.Remove(s.Length - 3); return(s); }
void ResetAndAdd(BasePlayer player) { var xpagent = BasePlayer.FindXpAgent(player.userID); PvXselector?.Call("disablePvXLogger", player.userID); xpagent.Reset(); xpagent.Add(Rust.Xp.Definitions.Cheat, Rust.Xp.Config.LevelToXp(System.Convert.ToInt32(XPInfo.GetInfo(player.userID).Level))); PvXselector?.Call("pvxUpdateXPDataFile", player); PvXselector?.Call("enablePvXLogger", player.userID); }
private void AddJail(BasePlayer player, string[] args) { string name = args[1].ToLower(); Prison data = new Prison(); if (CheckSpawns(args[3]) != null) { object zoneid = ZoneManager.Call("CheckZoneID", args[2]); if (zoneid is string && (string)zoneid != "") { data.zoneID = (string)zoneid; object location = ZoneManager?.Call("GetZoneLocation", (string)zoneid); if (location != null && location is Vector3) { data.location = (Vector3)location; } else { SendMsg(player, lang.GetMessage("invalidZPos", this, player.UserIDString)); return; } object radius = ZoneManager?.Call("GetZoneRadius", (string)zoneid); if (radius != null && radius is float) { data.zoneRadius = float.Parse(radius.ToString()); } else { SendMsg(player, lang.GetMessage("invalidZRad", this, player.UserIDString)); return; } data.spawnFile = args[3]; int cellCount = (int)CheckSpawns(args[3]); for (int i = 0; i < cellCount; i++) { data.freeCells.Add(i, false); } } else { SendMsg(player, lang.GetMessage("invalidZID", this, player.UserIDString) + args[2]); return; } jailData.prisons.Add(args[1].ToLower(), data); SendMsg(player, lang.GetMessage("newJailAdd", this, player.UserIDString)); SaveData(); return; } SendMsg(player, lang.GetMessage("invalidSF", this, player.UserIDString) + args[3]); }
private void AddImage(string fileName) { var url = fileName; if (!url.StartsWith("http") && !url.StartsWith("www")) { url = $"file://{Interface.Oxide.DataDirectory}{Path.DirectorySeparatorChar}SkipNightUI{Path.DirectorySeparatorChar}Images{Path.DirectorySeparatorChar}{fileName}.png"; } ImageLibrary?.Call("AddImage", url, fileName, 0); }
void OnBetterChatMuted(IPlayer target, IPlayer initiator) { if (notifypermanent == true) { string message = SlackMessage("Muted", new KeyValuePair <string, string>("initiatorname", initiator.Name), new KeyValuePair <string, string>("player", target.Name)); Slack?.Call("FancyMessage", message, initiator, channel); } }
void InitImages() { try { uint mapCRC = uint.Parse((string)Map?.Call("MapPng")); uint raidhomeCRC = uint.Parse((string)Map?.Call("RaidHomePng")); mapImage = (Bitmap)(new ImageConverter().ConvertFrom(FileStorage.server.Get(mapCRC, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID))); raidhomeImage = (Bitmap)(new ImageConverter().ConvertFrom(FileStorage.server.Get(raidhomeCRC, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID))); } catch {} }
private bool InClan(ulong playerUID) { if (ClansReborn == null && Clans == null) { return(false); } var clanName = Clans?.Call <string>("GetClanOf", playerUID); return(clanName != null); }
void SendDiscordMessage() { string seed = ConVar.Server.seed.ToString(); string hostname = ConVar.Server.hostname; string ip = covalence.Server.Address.ToString(); string port = covalence.Server.Port.ToString(); string worldsize = ConVar.Server.worldsize.ToString(); string Message = string.Join("\n", configData.WipeMessage.ToArray()); DiscordMessages?.Call("API_SendTextMessage", configData.WebhookURL, string.Format(Message, hostname, ip, port, seed, worldsize)); }
void OnPlayerInit(BasePlayer player) { var returnCall = ZoneManager?.Call("GetPlayerZoneIDs", player) as string[]; if (returnCall != null) { foreach (var zoneId in returnCall) { OnEnterZone(zoneId, player); } } }