private void removeById(string _id) { try { PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); if (_id.Length < 1 || !ppl.Players.ContainsKey (_id)) { SdtdConsole.Instance.Output ("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); return; } if (ppl.Players [_id].LPBlocks == null || ppl.Players [_id].LPBlocks.Count == 0) { SdtdConsole.Instance.Output ("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); return; } List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); foreach (Vector3i pos in ppl.Players[_id].LPBlocks) { BlockChangeInfo bci = new BlockChangeInfo (pos, 0, true); changes.Add (bci); } GameManager.Instance.SetBlocksRPC (changes); SdtdConsole.Instance.Output ("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note "+ "that only blocks in chunks that are currently loaded (close to any player) could be removed. "+ "Please check for remaining blocks by running:"); SdtdConsole.Instance.Output(" listlandprotection " + _id); } catch (Exception e) { Log.Out ("Error in RemoveLandProtection.removeById: " + e); } }
private void removeById(string _id) { try { PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList(); if (_id.Length < 1 || !ppl.Players.ContainsKey(_id)) { SdtdConsole.Instance.Output("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); return; } if (ppl.Players [_id].LPBlocks == null || ppl.Players [_id].LPBlocks.Count == 0) { SdtdConsole.Instance.Output("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); return; } List <BlockChangeInfo> changes = new List <BlockChangeInfo> (); foreach (Vector3i pos in ppl.Players[_id].LPBlocks) { BlockChangeInfo bci = new BlockChangeInfo(pos, 0, true); changes.Add(bci); } GameManager.Instance.SetBlocksRPC(changes); SdtdConsole.Instance.Output("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note " + "that only blocks in chunks that are currently loaded (close to any player) could be removed. " + "Please check for remaining blocks by running:"); SdtdConsole.Instance.Output(" listlandprotection " + _id); } catch (Exception e) { Log.Out("Error in RemoveLandProtection.removeById: " + e); } }
public static bool SetBlock(Vector3i pos, string blockNameOrId, int rotation = 0) { List <BlockChangeInfo> changes = new List <BlockChangeInfo> (); BlockValue bv; if (blockNameOrId.ToLower().Equals("air") || blockNameOrId.ToLower().Equals("0")) { bv = new BlockValue(0); } else { ItemValue iv = ItemUtils.Instance.GetItemValue(blockNameOrId); if (iv == null) { Log.Out("Could not Get Block ItemValue"); return(false); } bv = new BlockValue((uint)iv.type); } bv.rotation = Convert.ToByte(rotation); BlockChangeInfo bci = new BlockChangeInfo(pos, bv, true, false); changes.Add(bci); GameManager.Instance.SetBlocksRPC(changes); return(true); }
private void removeByPosition(List <string> _coords) { try { int x = int.MinValue; int.TryParse(_coords [0], out x); int y = int.MinValue; int.TryParse(_coords [1], out y); int z = int.MinValue; int.TryParse(_coords [2], out z); if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { SdtdConsole.Instance.Output("At least one of the given coordinates is not a valid integer"); return; } Vector3i vectorKfpValue = new Vector3i(x, y, z); Vector3i vectorKfpMin = new Vector3i(x - 3, y - 3, z - 3); Vector3i vectorKfpMax = new Vector3i(x + 3, y + 3, z + 3); PersistentPlayerList PlayersLst = GameManager.Instance.GetPersistentPlayerList(); Boolean KFound = false; Dictionary <Vector3i, PersistentPlayerData> positionToLPBlockOwner = PlayersLst.m_lpBlockMap; foreach (KeyValuePair <Vector3i, PersistentPlayerData> current in positionToLPBlockOwner) { if ((int)current.Key.x >= (int)vectorKfpMin.x && (int)current.Key.x <= (int)vectorKfpMax.x) { SdtdConsole.Instance.Output("Coordinates X found: " + (int)current.Key.x); if ((int)current.Key.y >= (int)vectorKfpMin.y && (int)current.Key.y <= (int)vectorKfpMax.y) { SdtdConsole.Instance.Output("Coordinates Y found: " + (int)current.Key.y); if ((int)current.Key.z >= (int)vectorKfpMin.z && (int)current.Key.z <= (int)vectorKfpMax.z) { SdtdConsole.Instance.Output("Coordinates Z found: " + (int)current.Key.z); Vector3i vectorKfpEnd = new Vector3i((int)current.Key.x, (int)current.Key.y, (int)current.Key.z); BlockChangeInfo bci = new BlockChangeInfo(vectorKfpEnd, 0, true); List <BlockChangeInfo> changes = new List <BlockChangeInfo> (); changes.Add(bci); GameManager.Instance.SetBlocksRPC(changes); SdtdConsole.Instance.Output("Land protection block at (" + vectorKfpEnd.ToString() + ") removed"); KFound = true; return; } } } } if (!KFound) { SdtdConsole.Instance.Output("Aucune keystone trouvee a cet emplacement (" + vectorKfpValue.ToString() + ")."); } } catch (Exception e) { Log.Out("Error in RemoveLandProtection.removeByPosition: " + e); } }
private void LoadSinglePrefab(string fileName, Vector3i position, int rotation) { if (File.Exists(string.Concat(prefabsPath, "/", fileName, ".tts"))) { List <BlockChangeInfo> list = new List <BlockChangeInfo>(); Prefab prefab = new Prefab(); prefab.Load(prefabsPath, fileName); for (int a = 0; a < rotation; a++) { prefab.RotateY(false); } m_Console.SendResult(string.Concat( "Prefab ", fileName, " is Loading. Please wait...") ); Random rand = new Random(DateTime.Now.Millisecond); Vector3i prefabPos = default(Vector3i); Vector3i blockPos = default(Vector3i); for (prefabPos.x = 0; prefabPos.x < prefab.size.x; prefabPos.x++) { for (prefabPos.z = 0; prefabPos.z < prefab.size.z; prefabPos.z++) { for (prefabPos.y = 0; prefabPos.y < prefab.size.y; prefabPos.y++) { BlockValue block = prefab.GetBlock(prefabPos.x, prefabPos.y, prefabPos.z); // Use vector arithmetics (Prefab class does not support GetBlock with Vector3i) blockPos = position + prefabPos; BlockValue block2 = world.GetBlock(prefabPos); if (block.rawData != block2.rawData && (block.type != 0 || prefab.bCopyAirBlocks)) { uint int1 = LootContainer.lootPlaceholderMap.Replace(block, rand).rawData; BlockChangeInfo item = new BlockChangeInfo(blockPos, int1, true); list.Add(item); } } } } if (list.Count > 0) { CommonMappingFunctions.GetGameManager().SetBlocksRPC(list); m_Console.SendResult(string.Concat("Your prefab is Loaded: ", fileName, " - ", list.Count, " blocks loaded.")); } else { m_Console.SendResult(string.Concat("Prefab ", fileName, " contains no blocks...")); } } else { m_Console.SendResult(string.Concat("Prefab ", fileName, " not found...")); } }
public static void Log(string _persistentPlayerId, BlockChangeInfo _bChangeInfo) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_persistentPlayerId); if (_player != null) { using (StreamWriter sw = new StreamWriter(_blockFilepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: Player named {1} with steam id {2} placed {3} @ {4}.", DateTime.Now, _player.EntityName, _persistentPlayerId, _bChangeInfo.blockValue.Block.GetBlockName(), _bChangeInfo.pos)); sw.WriteLine(); sw.Flush(); sw.Close(); } } }
public static bool ProcessPenalty(int _total, string _persistentPlayerId, BlockChangeInfo _bChangeInfo) { try { if (!string.IsNullOrEmpty(_persistentPlayerId)) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_persistentPlayerId); if (_player != null) { AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_persistentPlayerId); if (Admin.PermissionLevel > Admin_Level) { if (DamageDetector.IsEnabled) { string _message = "[FF0000]{PlayerName} has been banned for using damage manipulation."; _message = _message.Replace("{PlayerName}", _player.EntityName); ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for using a damage manipulator. Damage recorded: {1}\"", _persistentPlayerId, _total.ToString()), null); using (StreamWriter sw = new StreamWriter(_detectionFilepath, true)) { sw.WriteLine(string.Format("Detected {0} with steam id {1} using a damage manipulator @ position {2}. Damage recorded: {3}", _player.EntityName, _persistentPlayerId, _player.position, _total)); sw.WriteLine(); sw.Flush(); sw.Close(); } } return(true); } } else { return(true); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in DamageDetector.ProcessPenalty: {0}", e.Message)); } return(false); }
private void removeByPosition(List<string> _coords) { try { int x = int.MinValue; int.TryParse (_coords [0], out x); int y = int.MinValue; int.TryParse (_coords [1], out y); int z = int.MinValue; int.TryParse (_coords [2], out z); if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); return; } Vector3i vectorKfpValue = new Vector3i(x, y, z); Vector3i vectorKfpMin = new Vector3i (x-3, y-3, z-3); Vector3i vectorKfpMax = new Vector3i (x+3, y+3, z+3); PersistentPlayerList PlayersLst = GameManager.Instance.GetPersistentPlayerList (); Boolean KFound = false; Dictionary<Vector3i, PersistentPlayerData> positionToLPBlockOwner = PlayersLst.m_lpBlockMap; foreach (KeyValuePair<Vector3i, PersistentPlayerData> current in positionToLPBlockOwner) { if ((int)current.Key.x >= (int)vectorKfpMin.x && (int)current.Key.x <= (int)vectorKfpMax.x) { SdtdConsole.Instance.Output("Coordinates X found: " + (int)current.Key.x); if ((int)current.Key.y >= (int)vectorKfpMin.y && (int)current.Key.y <= (int)vectorKfpMax.y) { SdtdConsole.Instance.Output("Coordinates Y found: " + (int)current.Key.y); if ((int)current.Key.z >= (int)vectorKfpMin.z && (int)current.Key.z <= (int)vectorKfpMax.z) { SdtdConsole.Instance.Output("Coordinates Z found: " + (int)current.Key.z); Vector3i vectorKfpEnd = new Vector3i ((int)current.Key.x, (int)current.Key.y, (int)current.Key.z); BlockChangeInfo bci = new BlockChangeInfo (vectorKfpEnd, 0, true); List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); changes.Add (bci); GameManager.Instance.SetBlocksRPC (changes); SdtdConsole.Instance.Output ("Land protection block at (" + vectorKfpEnd.ToString() + ") removed"); KFound = true; return; } } } } if (!KFound) { SdtdConsole.Instance.Output("Aucune keystone trouvee a cet emplacement (" + vectorKfpValue.ToString() + ")."); } } catch (Exception e) { Log.Out ("Error in RemoveLandProtection.removeByPosition: " + e); } }
private void RemoveBlock(List <string> _params) { string steamid = PersistentContainer.Instance.Players.GetSteamID(_params [0], true); if (steamid == null) { SdtdConsole.Instance.Output("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); return; } Player p1 = PersistentContainer.Instance.Players [steamid, false]; if (p1 == null) { SdtdConsole.Instance.Output("Target playername or entity/steamid id not found."); return; } if (!p1.IsOnline) { SdtdConsole.Instance.Output("Target player not online."); return; } int targetBlockId = 0; int newBlockId = 0; int sizex = 0; int sizez = 0; int sizey = 0; if (!int.TryParse(_params[1], out targetBlockId) || !int.TryParse(_params[2], out newBlockId) || !int.TryParse(_params[3], out sizex) || !int.TryParse(_params[4], out sizez) || !int.TryParse(_params[5], out sizey)) { SdtdConsole.Instance.Output("Not a good value..."); return; } Vector3i position = default(Vector3i); position = p1.LastPosition; List <BlockChangeInfo> list = new List <BlockChangeInfo>(); SdtdConsole.Instance.Output(string.Concat( "Effacement en cours. ", "", " Please wait...") ); int midSizex = (int)Math.Floor((sizex / 2d)); int midSizez = (int)Math.Floor((sizez / 2d)); int midSizey = (int)Math.Floor((sizey / 2d)); SdtdConsole.Instance.Output(string.Concat("targetBlockId: ", targetBlockId, " newBlockId: ", newBlockId)); World world = GameManager.Instance.World; Vector3i prefabPos = default(Vector3i); try { for (prefabPos.x = -midSizex; prefabPos.x <= midSizex; prefabPos.x++) { for (prefabPos.z = -midSizez; prefabPos.z <= midSizez; prefabPos.z++) { for (prefabPos.y = -midSizey; prefabPos.y <= midSizey; prefabPos.y++) { BlockValue block = world.GetBlock(prefabPos + position); try { SdtdConsole.Instance.Output(string.Concat("posx: ", (prefabPos.x + position.x), " blockraw:", block.rawData, ", block type: ", block.type, ", block string: ", block.ToString())); if (block.type == targetBlockId || targetBlockId == -1) { block.damage = 0; //reparatoin SdtdConsole.Instance.Output(string.Concat("int1: ", newBlockId)); uint int1 = (uint)newBlockId; SdtdConsole.Instance.Output(string.Concat("int1: ", int1)); BlockChangeInfo item = new BlockChangeInfo(prefabPos + position, int1, true); list.Add(item); } }catch (Exception ex) { Log.Out("RemoveBlocksd check block error: " + ex.Message); } } } } }catch (Exception ex) { Log.Out("RemoveBlocks check block error: " + ex.Message); } if (list.Count > 0) { GameManager.Instance.SetBlocksRPC(list); SdtdConsole.Instance.Output(string.Concat("Nettoyage terminé : ", list.Count, " blocks effacés.")); } else { SdtdConsole.Instance.Output(string.Concat("Nettoyage impossible ", newBlockId, " block introuvable.")); } }
public static bool ProcessBlockChange(GameManager __instance, string _persistentPlayerId, List <BlockChangeInfo> _blocksToChange) { try { World _world = __instance.World; if (__instance != null && _blocksToChange != null && !string.IsNullOrEmpty(_persistentPlayerId) && _blocksToChange != null) { for (int i = 0; i < _blocksToChange.Count; i++) { BlockChangeInfo _newBlockInfo = _blocksToChange[i]; //new block info BlockValue _oldBlockValue = _world.GetBlock(_newBlockInfo.pos); //old block value Block _oldBlock = _oldBlockValue.Block; if (_newBlockInfo != null && _newBlockInfo.bChangeBlockValue) //new block value { Block _newBlock = _newBlockInfo.blockValue.Block; if (_oldBlockValue.type == BlockValue.Air.type) //old block was air { if (_newBlock is BlockSleepingBag) //placed a sleeping bag { if (POIProtection.IsEnabled && POIProtection.Bed && _world.IsPositionWithinPOI(_newBlockInfo.pos.ToVector3(), 5)) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { GameManager.Instance.World.SetBlockRPC(_newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(_cInfo, _newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue(1031, out string _phrase1031); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1031 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } } else if (_newBlock is BlockLandClaim)//placed a land claim { if (POIProtection.IsEnabled && POIProtection.Claim && _world.IsPositionWithinPOI(_newBlockInfo.pos.ToVector3(), 5)) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { GameManager.Instance.World.SetBlockRPC(_newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(_cInfo, _newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue(1032, out string _phrase1032); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1032 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } } else if (_newBlock is BlockPowered)//placed a electric block { Log.Out(string.Format("[SERVERTOOLS] New block is a powered block named {0}", _newBlock.GetBlockName())); } if (BlockLogger.IsEnabled)//placed block { BlockLogger.Log(_persistentPlayerId, _newBlockInfo); } return(true); } if (Damage_Detector) { if (_newBlockInfo.blockValue.type == BlockValue.Air.type) //new block is air { if (_oldBlockValue.type == BlockValue.Air.type) //replaced block { return(true); } if (_oldBlockValue.Block is BlockLandClaim) //removed claim { if (!string.IsNullOrEmpty(_persistentPlayerId)) //id is valid { if (!PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos)) { int _total = _oldBlock.MaxDamage - _oldBlockValue.damage; if (_oldBlock.MaxDamage - _oldBlockValue.damage >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } } if (!_oldBlock.CanPickup && !PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos))//old block can not be picked up and unclaimed space { int _total = _oldBlock.MaxDamage - _oldBlockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } else if (_oldBlock.blockID == _newBlock.blockID) //block is the same { if (_newBlockInfo.bChangeDamage) //block took damage { int _total = _newBlockInfo.blockValue.damage - _oldBlockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } if (_oldBlockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0)//block replaced { return(true); } } else if (_oldBlock.DowngradeBlock.Block.blockID == _newBlock.blockID)//downgraded { if (_oldBlockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0) { return(true); } int _total = _oldBlock.MaxDamage - _oldBlockValue.damage + _newBlockInfo.blockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessBlockDamage: {0}", e.Message)); } return(true); }
public static bool ProcessBlockChange(GameManager __instance, PlatformUserIdentifierAbs _persistentPlayerId, List <BlockChangeInfo> _blocksToChange) { try { if (__instance != null && _persistentPlayerId != null && _blocksToChange != null) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromUId(_persistentPlayerId); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null) { World world = __instance.World; for (int i = 0; i < _blocksToChange.Count; i++) { BlockChangeInfo newBlockInfo = _blocksToChange[i]; //new block info BlockValue oldBlockValue = world.GetBlock(newBlockInfo.pos); //old block value Block oldBlock = oldBlockValue.Block; if (newBlockInfo != null && oldBlock != null && newBlockInfo.bChangeBlockValue) //has new block value { Block newBlock = newBlockInfo.blockValue.Block; if (newBlock != null) { if (newBlock is BlockSleepingBag)//placed a sleeping bag { if (POIProtection.IsEnabled && POIProtection.Bed && world.IsPositionWithinPOI(newBlockInfo.pos.ToVector3(), 8)) { GameManager.Instance.World.SetBlockRPC(newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(cInfo, newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue("POI1", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } else if (newBlock is BlockLandClaim)//placed a land claim { if (POIProtection.IsEnabled && POIProtection.Claim && world.IsPositionWithinPOI(newBlockInfo.pos.ToVector3(), 5)) { GameManager.Instance.World.SetBlockRPC(newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(cInfo, newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue("POI2", out string _phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } if (BlockLogger.IsEnabled && !_blocksToChange[i].blockValue.Equals(BlockValue.Air)) { BlockLogger.PlacedBlock(cInfo, newBlock, newBlockInfo.pos); } } if (oldBlockValue.Block is BlockTrapDoor) { return(true); } else if (newBlockInfo.blockValue.Equals(BlockValue.Air.type))//new block is air { if (oldBlockValue.Block is BlockLandClaim) { if (PersistentOperations.ClaimedByWho(_persistentPlayerId, newBlockInfo.pos) == EnumLandClaimOwner.None) { if (DamageDetector.IsEnabled) { int total = oldBlock.MaxDamage - oldBlockValue.damage; if (total >= DamageDetector.Block_Damage_Limit && (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > Admin_Level)) { Penalty(total, player, cInfo); return(false); } } if (BlockLogger.IsEnabled) { BlockLogger.BrokeBlock(cInfo, oldBlock, newBlockInfo.pos); } int slot = player.inventory.holdingItemIdx; ItemValue itemValue = cInfo.latestPlayerData.inventory[slot].itemValue; if (itemValue != null && InfiniteAmmo.IsEnabled && itemValue.ItemClass.IsGun() && InfiniteAmmo.Exec(cInfo, player, slot, itemValue)) { return(false); } } else if (BlockLogger.IsEnabled) { BlockLogger.RemovedBlock(cInfo, oldBlock, newBlockInfo.pos); } } else if (!oldBlock.CanPickup)//old block can not be picked up { if (PersistentOperations.ClaimedByWho(_persistentPlayerId, newBlockInfo.pos) == EnumLandClaimOwner.None) { if (DamageDetector.IsEnabled) { int total = oldBlock.MaxDamage - oldBlockValue.damage; if (total >= DamageDetector.Block_Damage_Limit && (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > Admin_Level)) { Penalty(total, player, cInfo); return(false); } } } if (BlockLogger.IsEnabled) { BlockLogger.RemovedBlock(cInfo, oldBlock, newBlockInfo.pos); } } } else if (oldBlock.blockID == newBlock.blockID) //block is the same { if (newBlockInfo.bChangeDamage) //block took damage { if (DamageDetector.IsEnabled) { int total = newBlockInfo.blockValue.damage - oldBlockValue.damage; if (total >= DamageDetector.Block_Damage_Limit && (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > Admin_Level)) { Penalty(total, player, cInfo); return(false); } } int slot = player.inventory.holdingItemIdx; ItemValue itemValue = cInfo.latestPlayerData.inventory[slot].itemValue; if (itemValue != null && InfiniteAmmo.IsEnabled && itemValue.ItemClass.IsGun() && InfiniteAmmo.Exec(cInfo, player, slot, itemValue)) { return(false); } } } else if (oldBlock.DowngradeBlock.Block.blockID == newBlock.blockID)//downgraded { if (oldBlockValue.damage == newBlockInfo.blockValue.damage || newBlockInfo.blockValue.damage == 0) { if (BlockLogger.IsEnabled) { BlockLogger.DowngradedBlock(cInfo, oldBlock, newBlock, newBlockInfo.pos); } return(true); } if (DamageDetector.IsEnabled) { int total = oldBlock.MaxDamage - oldBlockValue.damage + newBlockInfo.blockValue.damage; if (total >= DamageDetector.Block_Damage_Limit && (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > Admin_Level)) { Penalty(total, player, cInfo); return(false); } } int slot = player.inventory.holdingItemIdx; ItemValue itemValue = cInfo.latestPlayerData.inventory[slot].itemValue; if (itemValue != null && InfiniteAmmo.IsEnabled && itemValue.ItemClass.IsGun() && InfiniteAmmo.Exec(cInfo, player, slot, itemValue)) { return(false); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BlockChange.ProcessBlockChange: {0}", e.Message)); } return(true); }
private void LoadSinglePrefab(string fileName, Vector3i position, int rotation) { if (File.Exists(string.Concat(prefabsPath, "/" , fileName, ".tts"))){ List<BlockChangeInfo> list = new List<BlockChangeInfo>(); Prefab prefab = new Prefab(); prefab.Load(prefabsPath,fileName); for (int a = 0; a < rotation; a++) { prefab.RotateY(false); } m_Console.SendResult(string.Concat( "Prefab ", fileName, " is Loading. Please wait...") ); Random rand = new Random(DateTime.Now.Millisecond); Vector3i prefabPos = default(Vector3i); Vector3i blockPos = default(Vector3i); for (prefabPos.x = 0; prefabPos.x < prefab.size.x; prefabPos.x++) { for (prefabPos.z = 0; prefabPos.z < prefab.size.z; prefabPos.z++) { for (prefabPos.y = 0; prefabPos.y < prefab.size.y; prefabPos.y++) { BlockValue block = prefab.GetBlock(prefabPos.x, prefabPos.y, prefabPos.z); // Use vector arithmetics (Prefab class does not support GetBlock with Vector3i) blockPos = position + prefabPos; BlockValue block2 = world.GetBlock(prefabPos); if (block.rawData != block2.rawData && (block.type != 0 || prefab.bCopyAirBlocks)) { uint int1 = LootContainer.lootPlaceholderMap.Replace(block, rand).rawData; BlockChangeInfo item = new BlockChangeInfo(blockPos, int1, true); list.Add(item); } } } } if (list.Count > 0) { CommonMappingFunctions.GetGameManager ().SetBlocksRPC (list); m_Console.SendResult(string.Concat("Your prefab is Loaded: ", fileName, " - ", list.Count, " blocks loaded." )); }else { m_Console.SendResult(string.Concat("Prefab ", fileName, " contains no blocks...")); } } else { m_Console.SendResult(string.Concat("Prefab ", fileName , " not found...")); } }
private void RemoveBlock(List <string> _params) { string steamid = PersistentContainer.Instance.Players.GetSteamID(_params [0], true); if (steamid == null) { SdtdConsole.Instance.Output("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); return; } Player p1 = PersistentContainer.Instance.Players [steamid, false]; if (p1 == null) { SdtdConsole.Instance.Output("Target playername or entity/steamid id not found."); return; } if (!p1.IsOnline) { SdtdConsole.Instance.Output("Target player not online."); return; } Vector3i position = default(Vector3i); position = p1.LastPosition; List <BlockChangeInfo> list = new List <BlockChangeInfo>(); SdtdConsole.Instance.Output(string.Concat( "Effacement en cours. ", "", " Please wait...") ); //Vector3i prefabPos = default(Vector3i); World world = GameManager.Instance.World; try { position.z -= 1; SdtdConsole.Instance.Output(position.ToString()); BlockValue block = world.GetBlock(position); SdtdConsole.Instance.Output(block.type.ToString()); try { SdtdConsole.Instance.Output(string.Concat("posz: ", (position.z), " blockraw:", block.rawData, ", block type: ", block.type, ", block string: ", block.ToString())); if (block.type == 875) { block.damage = 0; //reparatoin uint int1 = (uint)874; SdtdConsole.Instance.Output(string.Concat("int1: ", int1)); BlockChangeInfo item = new BlockChangeInfo(position, int1, true); list.Add(item); } }catch (Exception ex) { Log.Out("RemoveBlocksd check block error: " + ex.Message); } }catch (Exception ex) { Log.Out("RemoveBlocks check block error: " + ex.Message); } if (list.Count > 0) { GameManager.Instance.SetBlocksRPC(list); SdtdConsole.Instance.Output(string.Concat("Nettoyage terminé : ", list.Count, " blocks effacés.")); } else { SdtdConsole.Instance.Output(string.Concat("Nettoyage impossible ", 874, " block introuvable.")); } }
public static bool ProcessBlockDamage(GameManager __instance, string _persistentPlayerId, List <BlockChangeInfo> _blocksToChange) { try { World _world = __instance.World; for (int i = 0; i < _blocksToChange.Count; i++) { BlockChangeInfo _newBlockInfo = _blocksToChange[i]; //new block info BlockValue _blockValue = _world.GetBlock(_newBlockInfo.pos); //old block value if (_newBlockInfo.bChangeBlockValue) //new block value { if (_newBlockInfo.blockValue.type == BlockValue.Air.type) //new block is air { if (_blockValue.type == BlockValue.Air.type) //replaced block { return(true); } if (_blockValue.Block is BlockLandClaim) //removed claim { if (!string.IsNullOrEmpty(_persistentPlayerId)) //id is valid { PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerData(_persistentPlayerId); if (_ppd != null) { List <Vector3i> _protectionBlocks = _ppd.GetLandProtectionBlocks(); if (_protectionBlocks != null && !_protectionBlocks.Contains(_newBlockInfo.pos))//protection block list valid and does not contain this location { int _total = _blockValue.Block.MaxDamage - _blockValue.damage; if (_blockValue.Block.MaxDamage - _blockValue.damage >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo)) { //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); //return false; } } } } } if (!_blockValue.Block.CanPickup)//old block can not be picked up { int _total = _blockValue.Block.MaxDamage - _blockValue.damage; if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo)) { //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); //return false; } } } else if (_blockValue.type == BlockValue.Air.type) //old block was air { if (_newBlockInfo.blockValue.Block is BlockSleepingBag) //placed a sleeping bag { PersistentOperations.BedBug(_persistentPlayerId); if (Block_Log) { BlockLog(_persistentPlayerId, _newBlockInfo); } } else if (_newBlockInfo.blockValue.Block is BlockLandClaim)//placed a land claim { PersistentOperations.ClaimBug(_persistentPlayerId); if (Block_Log) { BlockLog(_persistentPlayerId, _newBlockInfo); } } else//placed block { if (Block_Log) { BlockLog(_persistentPlayerId, _newBlockInfo); } } } else if (_blockValue.Block.blockID == _newBlockInfo.blockValue.Block.blockID) //block is the same { if (_newBlockInfo.bChangeDamage) //block took damage { int _total = _newBlockInfo.blockValue.damage - _blockValue.damage; if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo)) { //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); //return false; } } if (_blockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0)//protected block replaced { //return true; } } else if (_blockValue.Block.DowngradeBlock.Block.blockID == _newBlockInfo.blockValue.Block.blockID)//downgraded { int _total = _blockValue.Block.MaxDamage - _blockValue.damage + _newBlockInfo.blockValue.damage; if (_total >= Block_Damage_Limit && ProcessPenalty(_total, _persistentPlayerId, _newBlockInfo)) { //_world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); //return false; } } } //if (Lobby.IsEnabled && Lobby.Protected && Lobby.Lobby_Position != "0,0,0") //{ // if (Lobby.ProtectedSpace(_newBlockInfo.pos.x, _newBlockInfo.pos.z)) // { // _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); // return false; // } //} //if (Market.IsEnabled && Market.Protected && Market.Market_Position != "0,0,0") //{ // if (Market.ProtectedSpace(_newBlockInfo.pos.x, _newBlockInfo.pos.z)) // { // _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); // return false; // } //} //if (Zones.IsEnabled) //{ // if (Zones.Protected(_newBlockInfo.pos)) // { // _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); // return false; // } //} //if (ProtectedSpace.IsEnabled) //{ // if (ProtectedSpace.Exec(_newBlockInfo.pos)) // { // _world.SetBlockRPC(_newBlockInfo.clrIdx, _newBlockInfo.pos, _blockValue); // return false; // } //} } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in DamageDetector.ProcessBlockDamage: {0}", e.Message)); } return(true); }
public static bool ProcessBlockDamage(GameManager __instance, string _persistentPlayerId, List <BlockChangeInfo> _blocksToChange) { try { World _world = __instance.World; if (__instance != null && _blocksToChange != null && !string.IsNullOrEmpty(_persistentPlayerId) && _blocksToChange != null) { for (int i = 0; i < _blocksToChange.Count; i++) { BlockChangeInfo _newBlockInfo = _blocksToChange[i]; //new block info BlockValue _blockValue = _world.GetBlock(_newBlockInfo.pos); //old block value if (_newBlockInfo != null && _newBlockInfo.bChangeBlockValue) //new block value { if (_blockValue.type == BlockValue.Air.type) //old block was air { if (_newBlockInfo.blockValue.Block is BlockSleepingBag) //placed a sleeping bag { PersistentOperations.BedBug(_persistentPlayerId); } else if (_newBlockInfo.blockValue.Block is BlockLandClaim)//placed a land claim { } if (BlockLogger.IsEnabled)//placed block { BlockLogger.Log(_persistentPlayerId, _newBlockInfo); } return(true); } if (Damage_Detector) { if (_newBlockInfo.blockValue.type == BlockValue.Air.type) //new block is air { if (_blockValue.type == BlockValue.Air.type) //replaced block { return(true); } if (_blockValue.Block is BlockLandClaim) //removed claim { if (!string.IsNullOrEmpty(_persistentPlayerId)) //id is valid { if (!PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos)) { int _total = _blockValue.Block.MaxDamage - _blockValue.damage; if (_blockValue.Block.MaxDamage - _blockValue.damage >= Block_Damage_Limit) { BlockPenalty(_total, _persistentPlayerId); } } } } if (!_blockValue.Block.CanPickup && !PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos))//old block can not be picked up and unclaimed space { int _total = _blockValue.Block.MaxDamage - _blockValue.damage; if (_total >= Block_Damage_Limit) { BlockPenalty(_total, _persistentPlayerId); } } } else if (_blockValue.Block.blockID == _newBlockInfo.blockValue.Block.blockID) //block is the same { if (_newBlockInfo.bChangeDamage) //block took damage { int _total = _newBlockInfo.blockValue.damage - _blockValue.damage; if (_total >= Block_Damage_Limit) { BlockPenalty(_total, _persistentPlayerId); } } if (_blockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0)//block replaced { return(true); } } else if (_blockValue.Block.DowngradeBlock.Block.blockID == _newBlockInfo.blockValue.Block.blockID)//downgraded { if (_blockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0) { return(true); } int _total = _blockValue.Block.MaxDamage - _blockValue.damage + _newBlockInfo.blockValue.damage; if (_total >= Block_Damage_Limit) { BlockPenalty(_total, _persistentPlayerId); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessBlockDamage: {0}", e.Message)); } return(true); }
private void RemoveBlock(List<string> _params) { string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true); if (steamid == null) { SdtdConsole.Instance.Output ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); return; } Player p1 = PersistentContainer.Instance.Players [steamid, false]; if (p1 == null) { SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); return; } if (!p1.IsOnline) { SdtdConsole.Instance.Output ("Target player not online."); return; } Vector3i position = default(Vector3i); position = p1.LastPosition; List<BlockChangeInfo> list = new List<BlockChangeInfo>(); SdtdConsole.Instance.Output(string.Concat( "Effacement en cours. ", "", " Please wait...") ); //Vector3i prefabPos = default(Vector3i); World world = GameManager.Instance.World; try { position.z -= 1; SdtdConsole.Instance.Output(position.ToString()); BlockValue block = world.GetBlock(position); SdtdConsole.Instance.Output(block.type.ToString()); try { SdtdConsole.Instance.Output(string.Concat("posz: ", (position.z), " blockraw:" , block.rawData , ", block type: ", block.type, ", block string: " , block.ToString() )); if (block.type == 875) { block.damage = 0;//reparatoin uint int1 = (uint) 874; SdtdConsole.Instance.Output(string.Concat("int1: " , int1 )); BlockChangeInfo item = new BlockChangeInfo(position , int1, true); list.Add(item); } }catch (Exception ex) { Log.Out("RemoveBlocksd check block error: " + ex.Message); } }catch (Exception ex) { Log.Out("RemoveBlocks check block error: " + ex.Message); } if (list.Count > 0) { GameManager.Instance.SetBlocksRPC (list); SdtdConsole.Instance.Output(string.Concat("Nettoyage terminé : ", list.Count, " blocks effacés." )); }else { SdtdConsole.Instance.Output(string.Concat("Nettoyage impossible ", 874, " block introuvable.")); } }
private void RemoveBlock(List<string> _params) { string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true); if (steamid == null) { SdtdConsole.Instance.Output ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); return; } Player p1 = PersistentContainer.Instance.Players [steamid, false]; if (p1 == null) { SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); return; } if (!p1.IsOnline) { SdtdConsole.Instance.Output ("Target player not online."); return; } int targetBlockId = 0; int newBlockId = 0; int sizex = 0; int sizez = 0; int sizey = 0; if (!int.TryParse(_params[1],out targetBlockId) || !int.TryParse(_params[2],out newBlockId) || !int.TryParse(_params[3],out sizex) || !int.TryParse(_params[4],out sizez) || !int.TryParse(_params[5],out sizey )) { SdtdConsole.Instance.Output ("Not a good value..."); return; } Vector3i position = default(Vector3i); position = p1.LastPosition; List<BlockChangeInfo> list = new List<BlockChangeInfo>(); SdtdConsole.Instance.Output(string.Concat( "Effacement en cours. ", "", " Please wait...") ); int midSizex = (int) Math.Floor ((sizex/2d)); int midSizez = (int) Math.Floor ((sizez/2d)); int midSizey = (int) Math.Floor ((sizey/2d)); SdtdConsole.Instance.Output(string.Concat("targetBlockId: " , targetBlockId , " newBlockId: ", newBlockId )); World world = GameManager.Instance.World; Vector3i prefabPos = default(Vector3i); try { for (prefabPos.x = - midSizex; prefabPos.x <= midSizex; prefabPos.x++) { for (prefabPos.z = - midSizez; prefabPos.z <= midSizez; prefabPos.z++) { for (prefabPos.y = - midSizey; prefabPos.y <= midSizey; prefabPos.y++) { BlockValue block = world.GetBlock(prefabPos + position); try { SdtdConsole.Instance.Output(string.Concat("posx: ", (prefabPos.x + position.x), " blockraw:" , block.rawData , ", block type: ", block.type, ", block string: " , block.ToString() )); if (block.type == targetBlockId || targetBlockId == -1 ) { block.damage = 0;//reparatoin SdtdConsole.Instance.Output(string.Concat("int1: " , newBlockId )); uint int1 = (uint) newBlockId; SdtdConsole.Instance.Output(string.Concat("int1: " , int1 )); BlockChangeInfo item = new BlockChangeInfo(prefabPos + position , int1, true); list.Add(item); } }catch (Exception ex) { Log.Out("RemoveBlocksd check block error: " + ex.Message); } } } } }catch (Exception ex) { Log.Out("RemoveBlocks check block error: " + ex.Message); } if (list.Count > 0) { GameManager.Instance.SetBlocksRPC (list); SdtdConsole.Instance.Output(string.Concat("Nettoyage terminé : ", list.Count, " blocks effacés." )); }else { SdtdConsole.Instance.Output(string.Concat("Nettoyage impossible ", newBlockId, " block introuvable.")); } }