public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (l == 0) { return false; } if (l == 1) { return false; } byte byte0 = 0; if (l == 4) { byte0 = 1; } if (l == 3) { byte0 = 2; } if (l == 5) { byte0 = 3; } var entitypainting = new EntityPainting(world, i, j, k, byte0); if (entitypainting.onValidSurface()) { if (!world.singleplayerWorld) { world.entityJoinedWorld(entitypainting); } itemstack.stackSize--; } return true; }
public bool canInteractWith(EntityPlayer entityplayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64D; }
public override void onCollideWithPlayer(EntityPlayer entityplayer) { if (slimeSize > 1 && canEntityBeSeen(entityplayer) && getDistanceToEntity(entityplayer) < 0.59999999999999998D*slimeSize && entityplayer.attackEntityFrom(this, slimeSize)) { worldObj.playSoundAtEntity(this, "mob.slimeattack", 1.0F, (rand.nextFloat() - rand.nextFloat())*0.2F + 1.0F); } }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { itemstack.stackSize--; world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F/(itemRand.nextFloat()*0.4F + 0.8F)); if (!world.singleplayerWorld) { world.entityJoinedWorld(new EntitySnowball(world, entityplayer)); } return itemstack; }
public override bool canInteractWith(EntityPlayer entityplayer) { if (field_20150_c.getBlockId(field_20149_h, field_20148_i, field_20147_j) != Block.workbench.blockID) { return false; } return entityplayer.getDistanceSq(field_20149_h + 0.5D, field_20148_i + 0.5D, field_20147_j + 0.5D) <= 64D; }
public override void onCraftGuiClosed(EntityPlayer entityplayer) { base.onCraftGuiClosed(entityplayer); for (int i = 0; i < 9; i++) { ItemStack itemstack = craftMatrix.getStackInSlot(i); if (itemstack != null) { entityplayer.dropPlayerItem(itemstack); } } }
public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) { if (world.singleplayerWorld) { return true; } else { entityplayer.displayWorkbenchGUI(i, j, k); return true; } }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (world.getBlockId(i, j, k) == Block.snow.blockID) { l = 0; } else { if (l == 0) { j--; } if (l == 1) { j++; } if (l == 2) { k--; } if (l == 3) { k++; } if (l == 4) { i--; } if (l == 5) { i++; } } if (itemstack.stackSize == 0) { return false; } if (world.canBlockBePlacedAt(blockID, i, j, k, false)) { Block block = Block.blocksList[blockID]; if (world.setBlockAndMetadataWithNotify(i, j, k, blockID, getMetadata(itemstack.getItemDamage()))) { Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l); Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer); world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, block.stepSound.func_737_c(), (block.stepSound.func_738_a() + 1.0F)/2.0F, block.stepSound.func_739_b()*0.8F); itemstack.stackSize--; } } return true; }
public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) { int l = world.getBlockMetadata(i, j, k); if (l > 0) { ejectRecord(world, i, j, k, l); return true; } else { return false; } }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (world.getBlockId(i, j, k) == Block.jukebox.blockID && world.getBlockMetadata(i, j, k) == 0) { world.setBlockMetadataWithNotify(i, j, k, (shiftedIndex - record13.shiftedIndex) + 1); world.playRecord(recordName, i, j, k); itemstack.stackSize--; return true; } else { return false; } }
public bool activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l) { int i1 = world.getBlockId(i, j, k); if (i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer)) { return true; } if (itemstack == null) { return false; } else { return itemstack.useItem(entityplayer, world, i, j, k, l); } }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { if (entityplayer.fishEntity != null) { int i = entityplayer.fishEntity.func_6143_c(); itemstack.damageItem(i); entityplayer.swingItem(); } else { world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F/(itemRand.nextFloat()*0.4F + 0.8F)); if (!world.singleplayerWorld) { world.entityJoinedWorld(new EntityFish(world, entityplayer)); } entityplayer.swingItem(); } return itemstack; }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (l != 1) { return false; } j++; var blockbed = (BlockBed) Block.bed; int i1 = MathHelper.floor_double(((entityplayer.rotationYaw*4F)/360F) + 0.5D) & 3; sbyte byte0 = 0; sbyte byte1 = 0; if (i1 == 0) { byte1 = 1; } if (i1 == 1) { byte0 = -1; } if (i1 == 2) { byte1 = -1; } if (i1 == 3) { byte0 = 1; } if (world.isAirBlock(i, j, k) && world.isAirBlock(i + byte0, j, k + byte1) && world.isBlockOpaqueCube(i, j - 1, k) && world.isBlockOpaqueCube(i + byte0, j - 1, k + byte1)) { world.setBlockAndMetadataWithNotify(i, j, k, blockbed.blockID, i1); world.setBlockAndMetadataWithNotify(i + byte0, j, k + byte1, blockbed.blockID, i1 + 8); itemstack.stackSize--; return true; } else { return false; } }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (itemstack.getItemDamage() == 15) { int i1 = world.getBlockId(i, j, k); if (i1 == Block.sapling.blockID) { ((BlockSapling) Block.sapling).func_21027_b(world, i, j, k, world.rand); itemstack.stackSize--; return true; } if (i1 == Block.crops.blockID) { ((BlockCrops) Block.crops).func_21028_c(world, i, j, k); itemstack.stackSize--; return true; } } return false; }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { int i1 = world.getBlockId(i, j, k); Material material = world.getBlockMaterial(i, j + 1, k); if (!material.isSolid() && i1 == Block.grass.blockID || i1 == Block.dirt.blockID) { Block block = Block.tilledField; world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, block.stepSound.func_737_c(), (block.stepSound.func_738_a() + 1.0F)/2.0F, block.stepSound.func_739_b()*0.8F); if (world.singleplayerWorld) { return true; } world.setBlockWithNotify(i, j, k, block.blockID); itemstack.damageItem(1); if (world.rand.nextInt(8) == 0 && i1 == Block.grass.blockID) { int j1 = 1; for (int k1 = 0; k1 < j1; k1++) { float f = 0.7F; float f1 = world.rand.nextFloat()*f + (1.0F - f)*0.5F; float f2 = 1.2F; float f3 = world.rand.nextFloat()*f + (1.0F - f)*0.5F; var entityitem = new EntityItem(world, i + f1, j + f2, k + f3, new ItemStack(seeds)); entityitem.delayBeforeCanPickup = 10; world.entityJoinedWorld(entityitem); } } return true; } else { return false; } }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { float f = 1.0F; float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch)*f; float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw)*f; double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX)*f; double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)*f + 1.6200000000000001D) - entityplayer.yOffset; double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ)*f; Vec3D vec3d = Vec3D.createVector(d, d1, d2); float f3 = MathHelper.cos(-f2*0.01745329F - 3.141593F); float f4 = MathHelper.sin(-f2*0.01745329F - 3.141593F); float f5 = -MathHelper.cos(-f1*0.01745329F); float f6 = MathHelper.sin(-f1*0.01745329F); float f7 = f4*f5; float f8 = f6; float f9 = f3*f5; double d3 = 5D; Vec3D vec3d1 = vec3d.addVector(f7*d3, f8*d3, f9*d3); MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, true); if (movingobjectposition == null) { return itemstack; } if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.singleplayerWorld) { world.entityJoinedWorld(new EntityBoat(world, i + 0.5F, j + 1.5F, k + 0.5F)); } itemstack.stackSize--; } return itemstack; }
public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { if (l == 0) { j--; } if (l == 1) { j++; } if (l == 2) { k--; } if (l == 3) { k++; } if (l == 4) { i--; } if (l == 5) { i++; } int i1 = world.getBlockId(i, j, k); if (i1 == 0) { world.playSoundEffect(i + 0.5D, j + 0.5D, k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat()*0.4F + 0.8F); world.setBlockWithNotify(i, j, k, Block.fire.blockID); } itemstack.damageItem(1); return true; }
public override bool blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) { if (world.singleplayerWorld) { return true; } int l = world.getBlockMetadata(i, j, k); int i1 = l & 7; int j1 = 8 - (l & 8); world.setBlockMetadataWithNotify(i, j, k, i1 + j1); world.markBlocksDirty(i, j, k, i, j, k); world.playSoundEffect(i + 0.5D, j + 0.5D, k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F); world.notifyBlocksOfNeighborChange(i, j, k, blockID); if (i1 == 1) { world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID); } else if (i1 == 2) { world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID); } else if (i1 == 3) { world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID); } else if (i1 == 4) { world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID); } else { world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID); } return true; }
public static String getEntityCitySpeech(EntityPlayer p) { return(p.getEntityCitySpeech(p.getEntityCity())); }
public override void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer) { blockActivated(world, i, j, k, entityplayer); }
/// <summary> /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer /// </summary> public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.Capabilities.IsCreativeMode) { par1ItemStack.StackSize--; } par2World.PlaySoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (ItemRand.NextFloat() * 0.4F + 0.8F)); if (!par2World.IsRemote) { par2World.SpawnEntityInWorld(new EntityExpBottle(par2World, par3EntityPlayer)); } return(par1ItemStack); }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { var _cInfo = _senderInfo.RemoteClientInfo; if (_cInfo != null) { if (_params[0].ToLower().Equals("off")) { if (Zones.IsEnabled) { Zones.IsEnabled = false; Config.WriteXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zones has been set to off")); return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zones is already off")); return; } } else if (_params[0].ToLower().Equals("on")) { if (!Zones.IsEnabled) { Zones.IsEnabled = true; Config.WriteXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zones has been set to on")); return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zones is already on")); return; } } else if (_params[0].ToLower().Equals("new")) { if (newZone.ContainsKey(_cInfo.entityId)) { newZone[_cInfo.entityId] = 1; } else { newZone.Add(_cInfo.entityId, 1); } if (Zones.zoneSetup1.ContainsKey(_cInfo.entityId)) { Zones.zoneSetup1.Remove(_cInfo.entityId); } if (Zones.zoneSetup2.ContainsKey(_cInfo.entityId)) { Zones.zoneSetup2.Remove(_cInfo.entityId); } string[] _strings = new string[7]; bool[] _bools = new bool[3]; _params.RemoveAt(0); string _name = string.Join(" ", _params); _strings[2] = _name; Zones.zoneSetup1.Add(_cInfo.entityId, _strings); Zones.zoneSetup2.Add(_cInfo.entityId, _bools); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Started a new zone setup. Zone name set to {0}.", _name)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Stand at the first corner of the zone and type zns save.")); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] If you would like a circle, stand in the middle of the circle and type zns circle.")); } else if (_params[0].ToLower().Equals("list")) { if (Zones.Box1.Count > 0) { for (int i = 0; i < Zones.Box1.Count; i++) { string[] _box = Zones.Box1[i]; bool[] _box2 = Zones.Box2[i]; if (_box != null) { SdtdConsole.Instance.Output(string.Format("Zone number {0}:", i)); SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _box[0])); SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _box[1])); SdtdConsole.Instance.Output(string.Format("Circle = {0}", _box2[0])); SdtdConsole.Instance.Output(string.Format("Name = {0}", _box[2])); SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _box[3])); SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _box[4])); SdtdConsole.Instance.Output(string.Format("Response = {0}", _box[5])); SdtdConsole.Instance.Output(string.Format("Reminder Notice = {0}", _box[6])); SdtdConsole.Instance.Output(string.Format("PvE = {0}", _box2[1])); SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _box2[2])); SdtdConsole.Instance.Output(string.Format("")); } } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] There are no zones setup.")); } } else if (_params[0].ToLower().Equals("delete")) { if (Zones.Box1.Count > 0) { if (int.TryParse(_params[1], out int _number)) { if (Zones.Box1.Count >= _number) { string[] _box1 = Zones.Box1[_number]; bool[] _box2 = Zones.Box2[_number]; Zones.Box1.RemoveAt(_number); Zones.Box2.RemoveAt(_number); Zones.UpdateXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Removed zone entry number {0} from the list", _number)); return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Could not delete number {0} from the list. Entry not found", _number)); return; } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid format or non numeric entry. Type zns delete <number> from the list of zones.")); return; } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] There are no zones setup.")); return; } } else if (_params[0].ToLower().Equals("circle")) { if (newZone.ContainsKey(_cInfo.entityId)) { newZone.TryGetValue(_cInfo.entityId, out int _stage); if (_stage == 1) { Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); _bools[0] = true; Zones.zoneSetup2[_cInfo.entityId] = _bools; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[0] = _sposition; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 2; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Saved the zone as a circle. Circle center point = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Type zns circle <number> to set the amount of blocks from center the zone will reach.")); } else if (_stage == 2) { Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); if (_bools[0]) { if (int.TryParse(_params[1], out int _radius)) { Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[1] = _radius.ToString(); Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 3; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Saved the circular zone radius to {0} blocks.", _radius)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"entry message\". This is the message players receive upon entering the zone.")); } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid radius for circlular zone, try again.")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] This zone is not setup as a circle, go back by typing zones back.")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Start a new zone setup or go back to the circle setup if you need to change it by typing zns back.")); } } } else if (_params[0].ToLower().Equals("save")) { if (newZone.ContainsKey(_cInfo.entityId)) { newZone.TryGetValue(_cInfo.entityId, out int _stage); if (_stage == 1) { Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); _bools[0] = false; Zones.zoneSetup2[_cInfo.entityId] = _bools; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[0] = _sposition; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 2; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 1 = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 1 saved. Stand in the opposite corner of the zone and type zns save.")); } if (_stage == 2) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[1] = _sposition; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 3; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 2 = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 2 saved. Type zns save \"entry message\". This is the message players receive upon entering the zone.")); } else if (_stage == 3) { _params.RemoveAt(0); string _entry = string.Join(" ", _params); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[3] = _entry; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 4; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone entry message = \"{0}\"", _entry)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Entry message saved. Type zns save \"exit message\". This is the message players receive upon exiting the zone.")); } else if (_stage == 4) { _params.RemoveAt(0); string _exit = string.Join(" ", _params); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[4] = _exit; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 5; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone exit message = \"{0}\"", _exit)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Exit message saved. Type zns save \"response\". This is the console command that will occur when a player enters this zone.")); } else if (_stage == 5) { _params.RemoveAt(0); string _response = string.Join(" ", _params); if (_response == "") { _response = "**"; } Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[5] = _response; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 6; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone response = \"{0}\"", _response)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Response saved. Type zns save \"reminder message\". This will set the message players receive if they stay in this zone long enough.")); } else if (_stage == 6) { _params.RemoveAt(0); string _reminder = string.Join(" ", _params); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); _strings[6] = _reminder; Zones.zoneSetup1[_cInfo.entityId] = _strings; newZone[_cInfo.entityId] = 7; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone reminder message = \"{0}\"", _reminder)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Reminder message saved. Type zns save 'true or false'. This will set PvE to true or false.")); } else if (_stage == 7) { if (bool.TryParse(_params[1], out bool _result)) { Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); if (_result) { _bools[1] = true; Zones.zoneSetup2[_cInfo.entityId] = _bools; newZone[_cInfo.entityId] = 8; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone PvE = {0}", _result)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] PvE saved. Type zns save 'true or false'. This will set No_Zombie to true or false.")); } else { _bools[1] = false; Zones.zoneSetup2[_cInfo.entityId] = _bools; newZone[_cInfo.entityId] = 8; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone PvE = {0}", _result)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] PvE saved. Type zns save 'true or false'. This will set No_Zombie to true or false.")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Incorrect format. Type zns save 'true or false'.")); } } else if (_stage == 8) { if (bool.TryParse(_params[1], out bool _result)) { Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); if (_result) { _bools[2] = true; Zones.zoneSetup2[_cInfo.entityId] = _bools; newZone[_cInfo.entityId] = 9; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] No zombie = {0}", _result)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] No zombie saved")); SdtdConsole.Instance.Output(""); SdtdConsole.Instance.Output(string.Format("Zone Review:")); SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0])); SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1])); SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0])); SdtdConsole.Instance.Output(string.Format("Name = {0}", _strings[2])); SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[3])); SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[4])); SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[5])); SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[6])); SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1])); SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _bools[2])); SdtdConsole.Instance.Output(string.Format("Type zns save. This will complete the setup.")); } else { _bools[2] = false; Zones.zoneSetup2[_cInfo.entityId] = _bools; newZone[_cInfo.entityId] = 9; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] No zombie = {0}", _result)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] No zombie saved")); SdtdConsole.Instance.Output(""); SdtdConsole.Instance.Output(string.Format("Zone Review:")); SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0])); SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1])); SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0])); SdtdConsole.Instance.Output(string.Format("Name = {0}", _strings[2])); SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[3])); SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[4])); SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[5])); SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[6])); SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1])); SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _bools[2])); SdtdConsole.Instance.Output(string.Format("Type zns save. This will complete the setup.")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Incorrect format. Type zns zns 'true or false'.")); } } else if (_stage == 9) { Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); string[] _box1 = { _strings[0], _strings[1], _strings[2], _strings[3], _strings[4], _strings[5], _strings[6] }; bool[] _box2 = { _bools[0], _bools[1], _bools[2] }; if (!Zones.Box1.Contains(_box1)) { Zones.Box1.Add(_box1); Zones.Box2.Add(_box2); Zones.UpdateXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] New zone setup has been completed.")); } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] This zone is already setup. Setup a new zone by typing zns new.")); } newZone.Remove(_cInfo.entityId); Zones.zoneSetup1.Remove(_cInfo.entityId); Zones.zoneSetup1.Remove(_cInfo.entityId); } } else if (_params[0].ToLower().Equals("back")) { if (newZone.ContainsKey(_cInfo.entityId)) { newZone.TryGetValue(_cInfo.entityId, out int _stage); if (_stage == 1) { Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone name = {0}", _strings[2])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Stand at the first corner of the zone and type zns save.")); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] If you would like a circle, stand in the middle of the circle and type zns circle.")); } else if (_stage == 2) { newZone[_cInfo.entityId] = 1; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); string[] _corner1 = _strings[0].Split(','); int.TryParse(_corner1[0], out int x); int.TryParse(_corner1[1], out int y); int.TryParse(_corner1[2], out int z); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); if (_bools[0]) { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Saved the zone as a circle. Circle center point = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Stand at the furthest point from the center and type zns circle.")); } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 1 = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 1 saved. Stand in the opposite corner of the zone and type zns save.")); } } else if (_stage == 3) { newZone[_cInfo.entityId] = 2; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); if (_bools[0]) { string _distance = _strings[1]; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Saved the circle radius to {0}.", _distance)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Type zns save 'entry message'. This is the message players receive upon entering the zone.")); } else { string[] _corner2 = _strings[1].Split(','); int.TryParse(_corner2[0], out int x); int.TryParse(_corner2[1], out int y); int.TryParse(_corner2[2], out int z); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 2 = {0} {1} {2}", x, y, z)); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Corner 2 saved. Type zns save 'entry message'. This is the message players receive upon entering the zone.")); } } else if (_stage == 4) { newZone[_cInfo.entityId] = 3; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone entry message = \"{0}\"", _strings[2])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone entry message saved. Type zns save 'exit message'. This is the message players receive upon exiting the zone.")); } else if (_stage == 5) { newZone[_cInfo.entityId] = 4; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone exit message = \"{0}\"", _strings[3])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone exit message saved. Type zns save 'response'. This is the console command that will occur when a player enters this zone.")); } else if (_stage == 6) { newZone[_cInfo.entityId] = 5; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone response = \"{0}\"", _strings[4])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone response saved. Type zns save 'reminder message'. This will set the message players receive if they stay in this zone long enough.")); } else if (_stage == 7) { newZone[_cInfo.entityId] = 6; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone reminder message = \"{0}\"", _strings[5])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone reminder message saved. Type zns save 'true or false'. This will set the zone as a PvE zone or not.")); } else if (_stage == 8) { newZone[_cInfo.entityId] = 7; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone PvE = {0}", _bools[1])); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone PvE saved. Type zns save 'true or false'. This will set the zone as a PvE zone or not.")); } else if (_stage == 9) { newZone[_cInfo.entityId] = 8; SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Zone setup has gone back one step.")); Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out string[] _strings); Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out bool[] _bools); SdtdConsole.Instance.Output(string.Format("Zone Review:")); SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0])); SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1])); SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0])); SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[2])); SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[3])); SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[4])); SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[5])); SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1])); SdtdConsole.Instance.Output(string.Format("Type zns save. This will complete the setup.")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] You have not started the setup for a new zone. Type zns new to begin setting up a new zone.")); } } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0])); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ZonesConsole.Execute: {0}", e.Message)); } }
public static void Tele(ClientInfo _cInfo) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (Box.Count > 0) { int _playerX = (int)_player.position.x; int _playerY = (int)_player.position.y; int _playerZ = (int)_player.position.z; int xMin, yMin, zMin, xMax, yMax, zMax, xDest, yDest, zDest; string[] _xyzCorner1 = { }, _xyzCorner2 = { }, _xyzDestCords = { }; foreach (KeyValuePair <string, string[]> kvpCorners in Box) { _xyzCorner1 = kvpCorners.Value[0].Split(','); int.TryParse(_xyzCorner1[0], out xMin); int.TryParse(_xyzCorner1[1], out yMin); int.TryParse(_xyzCorner1[2], out zMin); _xyzCorner2 = kvpCorners.Value[1].Split(','); int.TryParse(_xyzCorner2[0], out xMax); int.TryParse(_xyzCorner2[1], out yMax); int.TryParse(_xyzCorner2[2], out zMax); _xyzDestCords = kvpCorners.Value[2].Split(','); int.TryParse(_xyzDestCords[0], out xDest); int.TryParse(_xyzDestCords[1], out yDest); int.TryParse(_xyzDestCords[2], out zDest); if (xMin >= 0 & xMax >= 0) { if (xMin < xMax) { if (_playerX >= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX <= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } else { if (_playerX <= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX >= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } } else if (xMin <= 0 & xMax <= 0) { if (xMin < xMax) { if (_playerX >= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX <= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } else { if (_playerX <= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX >= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } } else if (xMin <= 0 & xMax >= 0) { if (_playerX >= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX <= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } else if (xMin >= 0 & xMax <= 0) { if (_playerX <= xMin) { _xMinCheck = 1; } else { _xMinCheck = 0; } if (_playerX >= xMax) { _xMaxCheck = 1; } else { _xMaxCheck = 0; } } if (yMin >= 0 & yMax >= 0) { if (yMin < yMax) { if (_playerY >= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY <= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } else { if (_playerY <= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY >= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } } else if (yMin <= 0 & yMax <= 0) { if (yMin < yMax) { if (_playerY >= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY <= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } else { if (_playerY <= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY >= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } } else if (yMin <= 0 & yMax >= 0) { if (_playerY >= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY <= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } else if (yMin >= 0 & yMax <= 0) { if (_playerY <= yMin) { _yMinCheck = 1; } else { _yMinCheck = 0; } if (_playerY >= yMax) { _yMaxCheck = 1; } else { _yMaxCheck = 0; } } if (zMin >= 0 & zMax >= 0) { if (zMin < zMax) { if (_playerZ >= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerZ <= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } else { if (_playerZ <= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerZ >= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } } else if (zMin <= 0 & zMax <= 0) { if (zMin < zMax) { if (_playerZ >= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerZ <= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } else { if (_playerZ <= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerZ >= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } } else if (zMin <= 0 & zMax >= 0) { if (_playerZ >= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerZ <= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } else if (zMin >= 0 & zMax <= 0) { if (_playerY <= zMin) { _zMinCheck = 1; } else { _zMinCheck = 0; } if (_playerY >= zMax) { _zMaxCheck = 1; } else { _zMaxCheck = 0; } } if (_xMinCheck == 1 & _yMinCheck == 1 & _zMinCheck == 1 & _xMaxCheck == 1 & _yMaxCheck == 1 & _zMaxCheck == 1) { if (PvP_Check) { if (Teleportation.PCheck(_cInfo, _player)) { return; } } if (Zombie_Check) { if (Teleportation.ZCheck(_cInfo, _player)) { return; } } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(xDest, yDest, zDest), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.playerId].LastTravel = DateTime.Now; PersistentContainer.Instance.Save(); string _phrase603; if (!Phrases.Dict.TryGetValue(603, out _phrase603)) { _phrase603 = "You have traveled to {Destination}."; } _phrase603 = _phrase603.Replace("{Destination}", kvpCorners.Key); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase603 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } string _phrase604; if (!Phrases.Dict.TryGetValue(604, out _phrase604)) { _phrase604 = "You are not in a travel location."; } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase604 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } }
public virtual bool canInteractWith(EntityPlayer entityplayer) { return upperChest.canInteractWith(entityplayer) && lowerChest.canInteractWith(entityplayer); }
/// <summary> /// Called when the item is used by an entity /// </summary> /// <param name="player">The entity using it</param> /// <returns>Returns if the item is used</returns> public virtual bool OnUse(EntityPlayer player) { return false; }
public override bool canInteractWith(EntityPlayer entityplayer) { return true; }
private static void Kill(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (PvP_Check) { List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo2 = ClientInfoList[i]; if (_cInfo2 != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { Vector3 _pos2 = _player2.GetPosition(); if (((int)_player.position.x - (int)_pos2.x) * ((int)_player.position.x - (int)_pos2.x) + ((int)_player.position.z - (int)_pos2.z) * ((int)_player.position.z - (int)_pos2.z) <= 25 * 25) { if (!_player.IsFriendsWith(_player2)) { string _phrase819; if (!Phrases.Dict.TryGetValue(819, out _phrase819)) { _phrase819 = " you are too close to a player that is not a friend. Command unavailable."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase819 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } } } } if (Zombie_Check) { List <Entity> Entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < Entities.Count; i++) { Entity _entity = Entities[i]; if (_entity != null) { EntityType _type = _entity.entityType; if (_type == EntityType.Zombie) { Vector3 _pos2 = _entity.GetPosition(); if (((int)_player.position.x - (int)_pos2.x) * ((int)_player.position.x - (int)_pos2.x) + ((int)_player.position.z - (int)_pos2.z) * ((int)_player.position.z - (int)_pos2.z) <= 10 * 10) { string _phrase820; if (!Phrases.Dict.TryGetValue(820, out _phrase820)) { _phrase820 = " you are too close to a zombie. Command unavailable."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase820 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } } } SdtdConsole.Instance.ExecuteSync(string.Format("kill {0}", _cInfo.playerId), (ClientInfo)null); PersistentContainer.Instance.Players[_cInfo.playerId].LastKillMe = DateTime.Now; PersistentContainer.Instance.Save(); }
public ManagedZombie(EntityEnemy _zombie, EntityPlayer _player) { zombie = _zombie; player = _player; }
private void SlowTick(float dt) { if (entity is EntityPlayer) { EntityPlayer plr = (EntityPlayer)entity; if (entity.World.PlayerByUid(plr.PlayerUID).WorldData.CurrentGameMode == EnumGameMode.Creative) { return; } } bool harshWinters = entity.World.Config.GetString("harshWinters").ToBool(true); ClimateCondition conds = entity.World.BlockAccessor.GetClimateAt(entity.Pos.AsBlockPos, EnumGetClimateMode.NowValues); if (conds == null || conds.Temperature >= 2 || !harshWinters) { entity.Stats.Remove("hungerrate", "resistcold"); } else { // 0..1 float diff = GameMath.Clamp(2 - conds.Temperature, 0, 10); Room room = entity.World.Api.ModLoader.GetModSystem <RoomRegistry>().GetRoomForPosition(entity.Pos.AsBlockPos); entity.Stats.Set("hungerrate", "resistcold", room.ExitCount == 0 ? 0 : diff / 40f, true); } if (Saturation <= 0) { // Let's say a fat reserve of 1000 is depleted in 3 ingame days using the default game speed of 1/60th // => 72 ingame hours / 60 = 1.2 irl hours = 4320 irl seconds // => 1 irl seconds substracts 1/4.32 fat reserves //float sprintLoss = sprintCounter / (15f * 6); //FatReserves = Math.Max(0, FatReserves - dt / 4.32f - sprintLoss / 4.32f); //if (FatReserves <= 0) { entity.ReceiveDamage(new DamageSource() { Source = EnumDamageSource.Internal, Type = EnumDamageType.Hunger }, 0.125f); } sprintCounter = 0; } /*if (Saturation >= 0.85 * MaxSaturation) * { * // Fat recovery is 6 times slower * FatReserves = Math.Min(MaxFatReserves, FatReserves + dt / (6 * 4.32f)); * } * * float max = MaxFatReserves; * float cur = FatReserves / max; * * if (cur <= 0.8 || lastFatReserves <= 0.8) * { * float diff = cur - lastFatReserves; * if (Math.Abs(diff) >= 0.1) * { * HealthLocked += diff > 0 ? -1 : 1; * * if (diff > 0 || Health > 0) * { * entity.ReceiveDamage(new DamageSource() { source = EnumDamageSource.Internal, type = (diff > 0) ? EnumDamageType.Heal : EnumDamageType.Hunger }, 1); * } * * lastFatReserves = cur; * } * } else * { * lastFatReserves = cur; * } */ }
/// <summary> /// Do not make give this method the name canInteractWith because it clashes with Container /// </summary> public virtual bool IsUseableByPlayer(EntityPlayer par1EntityPlayer) { return(true); }
public static Vector3 GetServerPos(this EntityPlayer player) { return(new Vector3(player.serverPos.x / 32f, player.serverPos.y / 32f, player.serverPos.z / 32f)); }
private static void SaveHome(ClientInfo _cInfo, string _homeName, int _homeTotal) { try { if (string.IsNullOrWhiteSpace(_homeName)) { Phrases.Dict.TryGetValue("Homes11", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes != null && PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes.Count > 0) { if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes.Count < _homeTotal) { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { Vector3 position = player.GetPosition(); int x = (int)position.x; int y = (int)position.y; int z = (int)position.z; string wposition = x + "," + y + "," + z; if (!PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes.ContainsKey(_homeName)) { PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes.Add(_homeName, wposition); PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Homes9", out string phrase); phrase = phrase.Replace("{Name}", _homeName); phrase = phrase.Replace("{Position}", wposition); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue("Homes10", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("Homes11", out string phrase); phrase = phrase.Replace("{Value}", _homeTotal.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else if (_homeTotal > 0) { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { Dictionary <string, string> homes = new Dictionary <string, string>(); Vector3 position = player.GetPosition(); int x = (int)position.x; int y = (int)position.y; int z = (int)position.z; string wposition = x + "," + y + "," + z; homes.Add(_homeName, wposition); PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Homes = homes; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Homes12", out string phrase); phrase = phrase.Replace("{Name}", _homeName); phrase = phrase.Replace("{Position}", wposition); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Homes11", out string phrase); phrase = phrase.Replace("{Value}", _homeTotal.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Homes.SaveHome: {0}", e.Message)); } }
public virtual bool CanBeActivated(EntityPlayer player) { return(true); }
public abstract void Activate(EntityPlayer player);
/// <summary> /// Initializes the player /// </summary> public void InitializePlayer() { EntityCloud.Initialize(); layers = WorldGen.Generate(); player = new EntityPlayer(); player.Spawn(); cameraPosition = player.Position - main.Resolution / 2f; }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count == 3 || _params.Count == 4 || _params.Count > 5) { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, 2 or 5, found {0}", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { if (Track.IsEnabled) { Track.IsEnabled = false; Config.WriteXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Tracking has been set to off")); return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Tracking is already off")); return; } } else if (_params[0].ToLower().Equals("on")) { if (!Track.IsEnabled) { Track.IsEnabled = true; Config.WriteXml(); SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Tracking has been set to on")); return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Tracking is already on")); return; } } else if (_params.Count == 2) { if (PersistentContainer.Instance.Track != null && PersistentContainer.Instance.Track.Count > 0) { bool _found = false; int _hours, _range; if (int.TryParse(_params[0], out _hours)) { if (_hours > 48) { _hours = 48; } if (int.TryParse(_params[1], out _range)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_senderInfo.RemoteClientInfo.entityId]; if (_player != null) { List <string[]> _tracking = PersistentContainer.Instance.Track; for (int i = 0; i < _tracking.Count; i++) { string[] _trackData = _tracking[i]; DateTime.TryParse(_trackData[0], out DateTime _date); if (_date.AddHours(_hours) >= DateTime.Now) { string[] _cords = _trackData[1].Split(','); int.TryParse(_cords[0], out int _x); int.TryParse(_cords[1], out int _y); int.TryParse(_cords[2], out int _z); Vector3 _trackedVecPos = new Vector3(_x, _y, _z); if (RangeCheck(_player.position, _trackedVecPos, _range)) { SdtdConsole.Instance.Output(string.Format("Player: {0}, SteamId: {1}, Time: {2}, Position: {3}, Item Held: {4}", _trackData[3], _trackData[2], _trackData[0], _trackData[1], _trackData[4])); } } } } if (!_found) { SdtdConsole.Instance.Output("[SERVERTOOLS] Tracking log lists nobody at this time and range from your current position"); } return; } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[1])); return; } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0])); return; } } else { SdtdConsole.Instance.Output("[SERVERTOOLS] Tracking log has no data"); return; } } else if (_params.Count == 5) { if (PersistentContainer.Instance.Track != null && PersistentContainer.Instance.Track.Count > 0) { bool _found = false; if (int.TryParse(_params[0], out int _hours)) { if (int.TryParse(_params[1], out int _range)) { if (int.TryParse(_params[2], out int _worldX)) { if (int.TryParse(_params[3], out int _worldY)) { if (int.TryParse(_params[4], out int _worldZ)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_senderInfo.RemoteClientInfo.entityId]; if (_player != null) { List <string[]> _tracking = PersistentContainer.Instance.Track; for (int i = 0; i < _tracking.Count; i++) { string[] _trackData = _tracking[i]; DateTime.TryParse(_trackData[0], out DateTime _date); if (_date.AddHours(_hours) >= DateTime.Now) { Vector3 _trackedVecPos = new Vector3(_worldX, _worldY, _worldZ); if (RangeCheck(_player.position, _trackedVecPos, _range)) { SdtdConsole.Instance.Output(string.Format("Player: {0}, SteamId: {1}, Time: {2}, Position: {3}, Item Held: {4}", _trackData[3], _trackData[2], _trackData[0], _trackData[1], _trackData[4])); } } } } if (!_found) { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Tracking results found nobody at this time and range inside the specified position")); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[4])); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[3])); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[2])); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[1])); } } else { SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0])); } return; } else { SdtdConsole.Instance.Output("[SERVERTOOLS] Tracking log has no data"); return; } } else { SdtdConsole.Instance.Output("[SERVERTOOLS] Invalid arguments"); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in TrackingConsole.Execute: {0}", e.Message)); } }
/// <summary> /// Initializes a new instance of the <see cref="SurvivalKit.Permissions.PlayerCommandSender"/> class able to be used as a <see cref="SurvivalKit.Permissions.CommandSender"/>. /// </summary> /// <param name="sender">The player this CommandSender instance should represent.</param> /// <param name="networkPlayer">The NetworkPlayer used to send messages back.</param> public PlayerCommandSender(EntityPlayer sender, UnityEngine.NetworkPlayer networkPlayer) { this.sender = sender; this.networkPlayer = networkPlayer; fullName = ("player;steam=" + SKMain.getClientInfo(networkPlayer).playerId + ";"); }
public override void GameTick(Entity entity, float dt) { EntityPlayer entityplayer = entity as EntityPlayer; EntityControls controls = entityplayer.Controls; string playerUID = entity.WatchedAttributes.GetString("playerUID"); IPlayer player = entity.World.PlayerByUid(playerUID); if (entity.World is IServerWorldAccessor && ((IServerPlayer)player).ConnectionState != EnumClientState.Playing) { return; } if (player != null) { IClientWorldAccessor clientWorld = entity.World as IClientWorldAccessor; // We pretend the entity is flying to disable gravity so that EntityBehaviorInterpolatePosition system // can work better controls.IsFlying = player.WorldData.FreeMove || (clientWorld != null && clientWorld.Player.ClientId != player.ClientId); controls.NoClip = player.WorldData.NoClip; controls.MovespeedMultiplier = player.WorldData.MoveSpeedMultiplier; } EntityPos pos = entity.World is IServerWorldAccessor ? entity.ServerPos : entity.Pos; if (controls.TriesToMove && player is IClientPlayer) { IClientPlayer cplr = player as IClientPlayer; float prevYaw = pos.Yaw; if (entity.Swimming) { float prevPitch = pos.Pitch; pos.Yaw = cplr.CameraYaw; pos.Pitch = cplr.CameraPitch; controls.CalcMovementVectors(pos, dt); pos.Yaw = prevYaw; pos.Pitch = prevPitch; } else { pos.Yaw = cplr.CameraYaw; controls.CalcMovementVectors(pos, dt); pos.Yaw = prevYaw; } float desiredYaw = (float)Math.Atan2(controls.WalkVector.X, controls.WalkVector.Z) - GameMath.PIHALF; float yawDist = GameMath.AngleRadDistance(entityplayer.WalkYaw, desiredYaw); entityplayer.WalkYaw += GameMath.Clamp(yawDist, -10 * dt, 10 * dt); entityplayer.WalkYaw = GameMath.Mod(entityplayer.WalkYaw, GameMath.TWOPI); if (entity.Swimming) { float desiredPitch = -(float)Math.Sin(pos.Pitch); // (float)controls.FlyVector.Y * GameMath.PI; float pitchDist = GameMath.AngleRadDistance(entityplayer.WalkPitch, desiredPitch); entityplayer.WalkPitch += GameMath.Clamp(pitchDist, -2 * dt, 2 * dt); entityplayer.WalkPitch = GameMath.Mod(entityplayer.WalkPitch, GameMath.TWOPI); //Console.WriteLine(entityplayer.WalkPitch); } else { entityplayer.WalkPitch = 0; } } else { controls.CalcMovementVectors(pos, dt); } TickEntityPhysics(pos, controls, dt); }
/// <summary> /// Callback for item usage. If the item does something special on right clicking, he will have one of those. Return /// True if something happen and false if it don't. This is for ITEMS, not BLOCKS ! /// </summary> public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (par7 == 0) { return(false); } if (!par3World.GetBlockMaterial(par4, par5, par6).IsSolid()) { return(false); } if (par7 == 1) { par5++; } if (par7 == 2) { par6--; } if (par7 == 3) { par6++; } if (par7 == 4) { par4--; } if (par7 == 5) { par4++; } if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6)) { return(false); } if (!Block.SignPost.CanPlaceBlockAt(par3World, par4, par5, par6)) { return(false); } if (par7 == 1) { int i = MathHelper2.Floor_double((double)(((par2EntityPlayer.RotationYaw + 180F) * 16F) / 360F) + 0.5D) & 0xf; par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, Block.SignPost.BlockID, i); } else { par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, Block.SignWall.BlockID, par7); } par1ItemStack.StackSize--; TileEntitySign tileentitysign = (TileEntitySign)par3World.GetBlockTileEntity(par4, par5, par6); if (tileentitysign != null) { par2EntityPlayer.DisplayGUIEditSign(tileentitysign); } return(true); }
public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount) { try { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { ItemValue _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1); if (_itemValue != null) { int _coinId = _itemValue.GetItemOrBlockId(); if (int.TryParse(_amount, out int _value)) { if (_value > 0) { int _currencyToRemove = _value; int _currencyRemoved = 0; LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>(); DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>(); ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters; for (int i = 0; i < _chunklist.Count; i++) { ChunkCluster _chunk = _chunklist[i]; _chunkArray = _chunk.GetChunkArray(); foreach (Chunk _c in _chunkArray) { _tiles = _c.GetTileEntities(); foreach (TileEntity _tile in _tiles.dict.Values) { TileEntityType type = _tile.GetTileEntityType(); if (type.ToString().Equals("SecureLoot")) { TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile; if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing()) { Vector3i vec3i = SecureLoot.ToWorldPos(); if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3) { if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3) { ItemStack[] _items = SecureLoot.items; if (_items != null && _items.Length > 0) { for (int j = 0; j < _items.Length; j++) { if (_currencyToRemove > 0) { if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _coinId) { if (_items[j].count <= _currencyToRemove) { int _newCount = _currencyToRemove - _items[j].count; int _newCount2 = _currencyRemoved + _items[j].count; _currencyToRemove = _newCount; _currencyRemoved = _newCount2; _items[j] = ItemStack.Empty.Clone(); } else { int _newCount = _currencyRemoved + _currencyToRemove; int _newStackCount = _items[j].count - _currencyToRemove; _currencyToRemove = 0; _currencyRemoved = _newCount; _items[j] = new ItemStack(_itemValue, _newStackCount); } _tile.SetModified(); } } } } } } } } } } } if (_currencyRemoved > 0) { if (Deposit_Fee_Percent > 0) { float _fee = _currencyRemoved * ((float)Deposit_Fee_Percent / 100); int _adjustedDeposit = _currencyRemoved - (int)_fee; AddCoinsToBank(_cInfo.playerId, _adjustedDeposit); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _adjustedDeposit)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(643, out string _phrase643); _phrase643 = _phrase643.Replace("{Value}", _adjustedDeposit.ToString()); _phrase643 = _phrase643.Replace("{CoinName}", Ingame_Coin); _phrase643 = _phrase643.Replace("{Percent}", Deposit_Fee_Percent.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase643 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { AddCoinsToBank(_cInfo.playerId, _currencyRemoved); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _currencyRemoved)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(644, out string _phrase644); _phrase644 = _phrase644.Replace("{Value}", _currencyRemoved.ToString()); _phrase644 = _phrase644.Replace("{CoinName}", Ingame_Coin); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase644 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(645, out string _phrase645); _phrase645 = _phrase645.Replace("{CoinName}", Ingame_Coin); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase645 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(646, out string _phrase646); _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase646 = _phrase646.Replace("{Command95}", Command95); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase646 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(646, out string _phrase646); _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase646 = _phrase646.Replace("{Command95}", Command95); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase646 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(647, out string _phrase647); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase647 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin)); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Bank.ChestToBankDeposit: {0}", e.Message)); } }
public bool func_6154_a(EntityPlayer entityplayer, World world, ItemStack itemstack) { int i = itemstack.stackSize; ItemStack itemstack1 = itemstack.useItemRightClick(world, entityplayer); if (itemstack1 != itemstack || itemstack1 != null && itemstack1.stackSize != i) { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = itemstack1; if (itemstack1.stackSize == 0) { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null; } return true; } else { return false; } }
public static void BankToPlayerWithdraw(ClientInfo _cInfo, string _amount) { try { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null && _player.IsSpawned()) { ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, false); if (_itemValue != null) { int _value; if (int.TryParse(_amount, out _value)) { int _bank = GetCurrentBank(_cInfo.playerId); if (_bank >= _value) { int _maxAllowed = _itemValue.ItemClass.Stacknumber.Value; if (_value <= _maxAllowed) { ItemStack itemStack = new ItemStack(_itemValue, _value); if (itemStack != null) { SubtractCoinsFromBank(_cInfo.playerId, _value); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} has removed {2} from their bank account as {3}.", DateTime.Now, _cInfo.playerName, _value, Ingame_Coin)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (!_player.bag.CanTakeItem(itemStack)) { Phrases.Dict.TryGetValue(648, out string _phrase648); _phrase648 = _phrase648.Replace("{CoinName}", Ingame_Coin); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase648 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue(649, out string _phrase649); _phrase649 = _phrase649.Replace("{CoinName}", Ingame_Coin); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase649 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = itemStack, pos = _player.position, rot = new Vector3(20f, 0f, 20f), lifetime = 60f, belongsPlayerId = _cInfo.entityId }); GameManager.Instance.World.SpawnEntityInWorld(entityItem); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId)); GameManager.Instance.World.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned); } } else { Phrases.Dict.TryGetValue(650, out string _phrase650); _phrase650 = _phrase650.Replace("{Max}", _maxAllowed.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase650 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(651, out string _phrase651); _phrase651 = _phrase651.Replace("{Total}", _bank.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase651 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(652, out string _phrase652); _phrase652 = _phrase652.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase652 = _phrase652.Replace("{Command96}", Command96); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase652 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(647, out string _phrase647); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase647 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin)); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Bank.BankToPlayerWithdraw: {0}", e.Message)); } }
/// <summary> /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the /// block. /// </summary> public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (par1World.GetBlockMetadata(par2, par3, par4) == 0) { return(false); } else { EjectRecord(par1World, par2, par3, par4); return(true); } }
/// <summary> /// Called when the block is clicked by a player. Args: x, y, z, entityPlayer /// </summary> public override void OnBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { BlockActivated(par1World, par2, par3, par4, par5EntityPlayer); }
public static void AutoFlightCheck() { if (ConnectionManager.Instance.ClientCount() > 0) { World world = GameManager.Instance.World; List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList(); for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId); AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { if (!Players.NoFlight.Contains(_cInfo.entityId)) { EntityPlayer ep = world.Players.dict[_cInfo.entityId]; if (!ep.IsAlive() || !ep.IsSpawned()) { continue; } if (autoGetFlightCheck(ep, _cInfo) && ep.AttachedToEntity == null) { if (!Flag.ContainsKey(_cInfo.entityId)) { Flag.Add(_cInfo.entityId, 1); } else { int _value; if (Flag.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 1) { Flag[_cInfo.entityId] = 2; } else { int x = (int)ep.position.x; int y = (int)ep.position.y; int z = (int)ep.position.z; _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, -1, z), null, false)); Penalty(_cInfo); Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, flying @ {2} {3} {4}. ", _cInfo.playerName, _cInfo.playerId, x, y, z); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, flying @ {2} {3} {4}. ", _cInfo.playerName, _cInfo.playerId, x, y, z)); sw.WriteLine(); sw.Flush(); sw.Close(); } for (int j = 0; j < _cInfoList.Count; j++) { ClientInfo _cInfo1 = _cInfoList[j]; AdminToolsClientInfo Admin1 = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo1.playerId); if (Admin1.PermissionLevel <= Admin_Level) { string _phrase706; if (!Phrases.Dict.TryGetValue(706, out _phrase706)) { _phrase706 = "Cheat Detected: {PlayerName} flying @ {X} {Y} {Z}"; } _phrase706 = _phrase706.Replace("{PlayerName}", _cInfo.playerName); _phrase706 = _phrase706.Replace("{X}", x.ToString()); _phrase706 = _phrase706.Replace("{Y}", y.ToString()); _phrase706 = _phrase706.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(null, "[FF0000]" + _phrase706 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } if (Announce) { string _phrase707; if (!Phrases.Dict.TryGetValue(707, out _phrase707)) { _phrase707 = "Cheat Detected: {PlayerName} has been detected flying."; } _phrase707 = _phrase707.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, "[FF0000]" + _phrase707 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } } } else { Flag.Remove(_cInfo.entityId); } } else { Flag.Remove(_cInfo.entityId); } } } } } }
public static void Exec() { try { if (GameManager.Instance.World.Players.dict.Count > 0) { List <EntityPlayer> EntityPlayerList = GameManager.Instance.World.Players.list; for (int i = 0; i < EntityPlayerList.Count; i++) { PlayerDataFile playerDataFile = new PlayerDataFile(); EntityPlayer _player = EntityPlayerList[i] as EntityPlayer; if (_player != null) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForEntityId(_player.entityId); if (_cInfo != null) { if (_player.IsSpawned()) { var _x = (int)_player.position.x; var _y = (int)_player.position.y; var _z = (int)_player.position.z; double _regionX, _regionZ; if (_player.position.x < 0) { _regionX = Math.Truncate(_player.position.x / 512) - 1; } else { _regionX = Math.Truncate(_player.position.x / 512); } if (_player.position.z < 0) { _regionZ = Math.Truncate(_player.position.z / 512) - 1; } else { _regionZ = Math.Truncate(_player.position.z / 512); } string _ip = _cInfo.ip; using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine(string.Format("{0}: \"{1}\" SteamId {2}. IP Address {3} at Position: {4} X {5} Y {6} Z in RegionFile: r.{7}.{8}.7rg", DateTime.Now, _cInfo.playerName, _cInfo.playerId, _ip, _x, _y, _z, _regionX, _regionZ)); sw.WriteLine(); sw.Flush(); sw.Close(); } using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine(string.Format("Stats: Health={0} Stamina={1} ZombieKills={2} PlayerKills={3} PlayerLevel={4}", (int)_player.Stats.Health.Value, (int)_player.Stats.Stamina.Value, _player.KilledZombies, _player.KilledPlayers, _player.Progression.GetLevel())); sw.WriteLine(); sw.Flush(); sw.Close(); } playerDataFile.Load(GameUtils.GetPlayerDataDir(), _cInfo.playerId.Trim()); if (playerDataFile != null) { using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine(string.Format("Inventory of " + _cInfo.playerName + " steamId {0}", _cInfo.playerId)); sw.WriteLine("Belt:"); sw.Flush(); sw.Close(); } PrintInv(playerDataFile.inventory, _cInfo.entityId, "belt"); using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine("Backpack:"); sw.Flush(); sw.Close(); } PrintInv(playerDataFile.bag, _cInfo.entityId, "backpack"); using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine("Equipment:"); sw.Flush(); sw.Close(); } PrintEquipment(playerDataFile.equipment, _cInfo.entityId, "equipment"); using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine("End of inventory"); sw.WriteLine(); sw.WriteLine("----------------"); sw.WriteLine(); sw.Flush(); sw.Close(); } } } else if (!_player.IsDead() && !_player.IsSpawned()) { using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine(string.Format("{0}: \"{1}\" SteamId {2}. Player has not spawned", DateTime.Now, _cInfo.playerName, _cInfo.playerId)); sw.WriteLine(); sw.WriteLine("----------------"); sw.WriteLine(); sw.Flush(); sw.Close(); } } else if (_player.IsDead()) { using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine(string.Format("{0}: \"{1}\" SteamId {2}. Player is currently dead", DateTime.Now, _cInfo.playerName, _cInfo.playerId)); sw.WriteLine(); sw.WriteLine("----------------"); sw.WriteLine(); sw.Flush(); sw.Close(); } } } } } using (StreamWriter sw = new StreamWriter(Filepath, true)) { sw.WriteLine("***********************************************************"); sw.Flush(); sw.Close(); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PlayerLogs.Exec: {0}.", e.Message)); } }
public static void Walletcheck(ClientInfo _cInfo, string _item, string _playerName) { int _id; if (_item.Contains(" ")) { string[] _idAmount = _item.Split(' '); if (!int.TryParse(_idAmount[0], out _id)) { string _phrase620; if (!Phrases.Dict.TryGetValue(620, out _phrase620)) { _phrase620 = "{PlayerName} the item or amount # you are trying to buy is not an integer. Please input /buy 1 2 for example."; } _phrase620 = _phrase620.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase620), Config.Server_Response_Name, false, "ServerTools", false)); } else { int _amount; if (!int.TryParse(_idAmount[1], out _amount)) { string _phrase620; if (!Phrases.Dict.TryGetValue(620, out _phrase620)) { _phrase620 = "{PlayerName} the item or amount # you are trying to buy is not an integer. Please input /buy 1 2 for example."; } _phrase620 = _phrase620.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase620), Config.Server_Response_Name, false, "ServerTools", false)); } else { if (dict.ContainsKey(_id)) { string[] _stringValues; if (dict.TryGetValue(_id, out _stringValues)) { int[] _integerValues; if (dict1.TryGetValue(_id, out _integerValues)) { World world = GameManager.Instance.World; int currentCoins; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; int gameMode = world.GetGameMode(); if (gameMode == 7) { currentCoins = (_player.KilledZombies * Wallet.Zombie_Kills) + (_player.KilledPlayers * Wallet.Player_Kills) - (XUiM_Player.GetDeaths(_player) * Wallet.Deaths) + p.PlayerSpentCoins; } else { currentCoins = (_player.KilledZombies * Wallet.Zombie_Kills) - (XUiM_Player.GetDeaths(_player) * Wallet.Deaths) + p.PlayerSpentCoins; } int _newAmount = _integerValues[2] * _amount; if (currentCoins >= _newAmount) { int _newCount = _integerValues[0] * _amount; ShopPurchase(_cInfo, _stringValues[0], _newCount, _integerValues[1], _newAmount, _playerName, currentCoins, p); } else { string _phrase621; if (!Phrases.Dict.TryGetValue(621, out _phrase621)) { _phrase621 = "{PlayerName} you do not have enough {CoinName}. Your wallet balance is {WalletBalance}."; } _phrase621 = _phrase621.Replace("{PlayerName}", _playerName); _phrase621 = _phrase621.Replace("{CoinName}", Wallet.Coin_Name); _phrase621 = _phrase621.Replace("{WalletBalance}", currentCoins.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase621), Config.Server_Response_Name, false, "ServerTools", false)); } } } } } } } else { if (int.TryParse(_item, out _id)) { if (dict.ContainsKey(_id)) { string[] _stringValues; if (dict.TryGetValue(_id, out _stringValues)) { int[] _integerValues; if (dict1.TryGetValue(_id, out _integerValues)) { World world = GameManager.Instance.World; int currentCoins; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; int gameMode = world.GetGameMode(); if (gameMode == 7) { currentCoins = (_player.KilledZombies * Wallet.Zombie_Kills) + (_player.KilledPlayers * Wallet.Player_Kills) - (XUiM_Player.GetDeaths(_player) * Wallet.Deaths) + p.PlayerSpentCoins; } else { currentCoins = (_player.KilledZombies * Wallet.Zombie_Kills) - (XUiM_Player.GetDeaths(_player) * Wallet.Deaths) + p.PlayerSpentCoins; } if (currentCoins >= _integerValues[2]) { ShopPurchase(_cInfo, _stringValues[0], _integerValues[0], _integerValues[1], _integerValues[2], _playerName, currentCoins, p); } else { string _phrase621; if (!Phrases.Dict.TryGetValue(621, out _phrase621)) { _phrase621 = "{PlayerName} you do not have enough {CoinName}. Your wallet balance is {WalletBalance}."; } _phrase621 = _phrase621.Replace("{PlayerName}", _playerName); _phrase621 = _phrase621.Replace("{CoinName}", Wallet.Coin_Name); _phrase621 = _phrase621.Replace("{WalletBalance}", currentCoins.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase621), Config.Server_Response_Name, false, "ServerTools", false)); } } } } } else { string _phrase622; if (!Phrases.Dict.TryGetValue(622, out _phrase622)) { _phrase622 = "{PlayerName} there was no item # matching the shop goods. Type /shop to review the list."; } _phrase622 = _phrase622.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase622), Config.Server_Response_Name, false, "ServerTools", false)); } } }
public virtual bool canInteractWith(EntityPlayer entityplayer) { return true; }
public override void AddItemEffect(EntityPlayer player) { player.AddPower(8); SoundLoader.GetInstance().PlayEffect("super_up.mp3"); }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { base.onItemRightClick(itemstack, world, entityplayer); return new ItemStack(bowlEmpty); }
/* public virtual int GetRadius() { return this.GetTextureSize().Width > this.GetTextureSize().Height ? this.GetTextureSize().Width : this.GetTextureSize().Height; } */ /// <summary> /// 引数のプレイヤーに効果を与える /// </summary> /// <param name="player"></param> public abstract void AddItemEffect(EntityPlayer player);
public static void NewBounty(ClientInfo _cInfo, string _message, string _playerName) { int _id; string[] _idAndBounty = { }; int _cost; if (_message.Contains(" ")) { _idAndBounty = _message.Split(' ').ToArray(); if (int.TryParse(_idAndBounty[0], out _id)) { if (int.TryParse(_idAndBounty[1], out _cost)) { ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id); if (_cInfo1 != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo1.entityId]; if (_cost < Minimum_Bounty) { _cost = Minimum_Bounty; } int _currentCoins = Wallet.GetcurrentCoins(_cInfo); if (_currentCoins >= _cost) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _cost); string _sql = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId); DataTable _result = SQL.TQuery(_sql); int _bounty; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty); _result.Dispose(); _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + _cost, _cInfo1.playerId); SQL.FastQuery(_sql, "Bounties"); string _message1 = " you have added {Value} bounty to {PlayerName}.[-]"; _message1 = _message1.Replace("{Value}", _cost.ToString()); _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]"; _message1 = _message1.Replace("{Value}", _cost.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", to add a custom bounty value, type " + ChatHook.Command_Private + Command83 + " Id# Value, or the minimum with " + ChatHook.Command_Private + Command83 + " Id#.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { if (int.TryParse(_message, out _id)) { ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id); if (_cInfo1 != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo1.entityId]; int _currentCoins = Wallet.GetcurrentCoins(_cInfo); if (_currentCoins >= Minimum_Bounty) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Minimum_Bounty); string _sql = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId); DataTable _result = SQL.TQuery(_sql); int _bounty; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty); _result.Dispose(); _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + Minimum_Bounty, _cInfo1.playerId); SQL.FastQuery(_sql, "Bounties"); string _message1 = " you have added {Value} bounty to {PlayerName}.[-]"; _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString()); _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]"; _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } }
public static void PlayerKilled(EntityPlayer _player1, EntityPlayer _player2, ClientInfo _cInfo1, ClientInfo _cInfo2) { if (!_player1.IsFriendsWith(_player2) && !_player2.IsFriendsWith(_player1) && !_player1.Party.ContainsMember(_player2) && !_player2.Party.ContainsMember(_player1)) { if (ClanManager.IsEnabled) { if (ClanManager.ClanMember.Contains(_cInfo1.playerId) && ClanManager.ClanMember.Contains(_cInfo2.playerId)) { string _clanName1 = PersistentContainer.Instance.Players[_cInfo1.playerId].ClanName; string _clanName2 = PersistentContainer.Instance.Players[_cInfo2.playerId].ClanName; if (string.IsNullOrEmpty(_clanName1) && string.IsNullOrEmpty(_clanName2)) { if (_clanName1 == _clanName2) { return; } } } } int _victimBounty = PersistentContainer.Instance.Players[_cInfo1.playerId].Bounty; int _victimBountyHunter = PersistentContainer.Instance.Players[_cInfo1.playerId].BountyHunter; if (_victimBounty > 0) { int _killerWallet = PersistentContainer.Instance.Players[_cInfo2.playerId].PlayerWallet; int _killerBounty = PersistentContainer.Instance.Players[_cInfo2.playerId].Bounty; int _killerBountyHunter = PersistentContainer.Instance.Players[_cInfo2.playerId].BountyHunter; if (Kill_Streak > 0) { int _victimBountyPlus = _victimBounty + Bonus; if (_killerBountyHunter + 1 > Kill_Streak) { PersistentContainer.Instance.Players[_cInfo2.playerId].PlayerWallet = _killerWallet + _victimBountyPlus; PersistentContainer.Instance.Players[_cInfo2.playerId].BountyHunter = _killerBountyHunter + 1; PersistentContainer.Instance.Players[_cInfo2.playerId].Bounty = _killerBounty + Bonus; string _phrase913; if (!Phrases.Dict.TryGetValue(913, out _phrase913)) { _phrase913 = "{PlayerName} has collected {Kill_Streak} bounties without dying! Their bounty has increased."; } _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName); _phrase913 = _phrase913.Replace("{Kill_Streak}", _killerBountyHunter + 1.ToString()); ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _phrase913, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} has collected {2} bounties without dying. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _killerBountyHunter + 1)); sw.WriteLine(); sw.Flush(); sw.Close(); } } else if (_killerBountyHunter + 1 == Kill_Streak) { PersistentContainer.Instance.Players[_cInfo2.playerId].PlayerWallet = _killerWallet + _victimBountyPlus; PersistentContainer.Instance.Players[_cInfo2.playerId].BountyHunter = _killerBountyHunter + 1; PersistentContainer.Instance.Players[_cInfo2.playerId].Bounty = _killerBounty + Bonus; string _phrase913; if (!Phrases.Dict.TryGetValue(913, out _phrase913)) { _phrase913 = "{PlayerName} has collected {Kill_Streak} bounties without dying! Their bounty has increased."; } _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName); _phrase913 = _phrase913.Replace("{Kill_Streak}", _killerBountyHunter + 1.ToString()); ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _phrase913, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} has collected {2} bounties without dying. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _killerBountyHunter + 1)); sw.WriteLine(); sw.Flush(); sw.Close(); } } else if (_killerBountyHunter + 1 < Kill_Streak) { PersistentContainer.Instance.Players[_cInfo2.playerId].PlayerWallet = _killerWallet + _victimBounty; PersistentContainer.Instance.Players[_cInfo2.playerId].BountyHunter = _killerBountyHunter + 1; } if (_victimBountyHunter >= Kill_Streak) { string _message = "Player {Victim}' kill streak has come to an end by {Killer}."; _message = _message.Replace("{Victim}", _cInfo1.playerName); _message = _message.Replace("{Killer}", _cInfo2.playerName); ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _message, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: Player {1}' kill streak has come to an end by {2}.", DateTime.Now, _cInfo1.playerName, _cInfo2.playerName)); sw.WriteLine(); sw.Flush(); sw.Close(); } } } else if (Kill_Streak <= 0) { PersistentContainer.Instance.Players[_cInfo2.playerId].PlayerWallet = _killerWallet + _victimBounty; } PersistentContainer.Instance.Players[_cInfo1.playerId].Bounty = 0; PersistentContainer.Instance.Players[_cInfo1.playerId].BountyHunter = 0; PersistentContainer.Instance.Save(); string _message2 = "Player {Killer}' has collected the bounty of {Victim}."; _message2 = _message2.Replace("{Victim}", _cInfo1.playerName); _message2 = _message2.Replace("{Killer}", _cInfo2.playerName); ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _message2, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } }
/// <summary> /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the /// block. /// </summary> public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (par1World.IsRemote) { return(true); } int i = par1World.GetBlockMetadata(par2, par3, par4); int j = i & 7; int k = 8 - (i & 8); par1World.SetBlockMetadataWithNotify(par2, par3, par4, j + k); par1World.MarkBlocksDirty(par2, par3, par4, par2, par3, par4); par1World.PlaySoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, k <= 0 ? 0.5F : 0.6F); par1World.NotifyBlocksOfNeighborChange(par2, par3, par4, BlockID); if (j == 1) { par1World.NotifyBlocksOfNeighborChange(par2 - 1, par3, par4, BlockID); } else if (j == 2) { par1World.NotifyBlocksOfNeighborChange(par2 + 1, par3, par4, BlockID); } else if (j == 3) { par1World.NotifyBlocksOfNeighborChange(par2, par3, par4 - 1, BlockID); } else if (j == 4) { par1World.NotifyBlocksOfNeighborChange(par2, par3, par4 + 1, BlockID); } else { par1World.NotifyBlocksOfNeighborChange(par2, par3 - 1, par4, BlockID); } return(true); }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { itemstack.stackSize--; entityplayer.heal(healAmount); return itemstack; }
public override void Activate(EntityPlayer player) { terminalCanvas.SetActive(true); GameManager.Main.OpenMenu(terminalCanvas.GetComponent <ICloseableMenu>()); }
public override bool canInteractWith(EntityPlayer entityplayer) { return field_21133_a.canInteractWith(entityplayer); }
public CollisionComplex(EntityPlayer entity) { this.entity = entity; }
public static void RemoveFromJail(ClientInfo _cInfo, string _playerName) { string[] _command3 = { Command28 }; if (!GameManager.Instance.adminTools.CommandAllowedFor(_command3, _cInfo.playerId)) { string _phrase107; if (!Phrases.Dict.TryGetValue(107, out _phrase107)) { _phrase107 = " you do not have permissions to use this command."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase107 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { _playerName = _playerName.Replace("unjail ", ""); ClientInfo _PlayertoUnJail = ConsoleHelper.ParseParamIdOrName(_playerName); if (_PlayertoUnJail == null) { string _phrase201; if (!Phrases.Dict.TryGetValue(201, out _phrase201)) { _phrase201 = " player {PlayerName} was not found online."; } _phrase201 = _phrase201.Replace("{PlayerName}", _playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase201 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { int _jailTime = PersistentContainer.Instance.Players[_PlayertoUnJail.playerId].JailTime; if (_jailTime == 0) { string _phrase506; if (!Phrases.Dict.TryGetValue(506, out _phrase506)) { _phrase506 = " player {PlayerName} is not in jail."; } _phrase506 = _phrase506.Replace("{PlayerName}", _PlayertoUnJail.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase506 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { if (!Jailed.Contains(_PlayertoUnJail.playerId)) { string _phrase506; if (!Phrases.Dict.TryGetValue(506, out _phrase506)) { _phrase506 = " player {PlayerName} is not in jail."; } _phrase506 = _phrase506.Replace("{PlayerName}", _PlayertoUnJail.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase506 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { Jailed.Remove(_PlayertoUnJail.playerId); PersistentContainer.Instance.Players[_PlayertoUnJail.playerId].JailTime = 0; PersistentContainer.Instance.Save(); EntityPlayer _player = GameManager.Instance.World.Players.dict[_PlayertoUnJail.entityId]; EntityBedrollPositionList _position = _player.SpawnPoints; if (_position.Count > 0) { _PlayertoUnJail.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_position[0].x, _position[0].y + 1, _position[0].z), null, false)); } else { Vector3[] _pos = GameManager.Instance.World.GetRandomSpawnPointPositions(1); _PlayertoUnJail.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_pos[0].x, _pos[0].y + 1, _pos[0].z), null, false)); } string _phrase501; if (!Phrases.Dict.TryGetValue(501, out _phrase501)) { _phrase501 = " you have been released from jail."; } ChatHook.ChatMessage(_PlayertoUnJail, LoadConfig.Chat_Response_Color + _PlayertoUnJail.playerName + LoadConfig.Chat_Response_Color + _phrase501 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } }
public static void PlayerKilled(EntityPlayer _player1, EntityPlayer _player2, ClientInfo _cInfo1, ClientInfo _cInfo2) { if (!_player1.IsFriendsWith(_player2) && !_player2.IsFriendsWith(_player1) && !_player1.Party.ContainsMember(_player2) && !_player2.Party.ContainsMember(_player1)) { if (ClanManager.IsEnabled) { if (ClanManager.ClanMember.Contains(_cInfo1.playerId) && ClanManager.ClanMember.Contains(_cInfo2.playerId)) { string _sql1 = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo1.playerId); DataTable _result1 = SQL.TQuery(_sql1); string _clanName = _result1.Rows[0].ItemArray.GetValue(0).ToString(); _result1.Dispose(); _sql1 = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo2.playerId); DataTable _result2 = SQL.TQuery(_sql1); string _clanName2 = _result2.Rows[0].ItemArray.GetValue(0).ToString(); _result2.Dispose(); if (_clanName != "Unknown" && _clanName2 != "Unknown") { if (_clanName == _clanName2) { return; } } } } string _sql = string.Format("SELECT bounty, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo1.playerId); DataTable _result = SQL.TQuery(_sql); int _bounty; int _hunterCountVictim; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty); int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountVictim); _result.Dispose(); if (_bounty > 0) { _sql = string.Format("SELECT playerSpentCoins, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo2.playerId); DataTable _result2 = SQL.TQuery(_sql); int _playerSpentCoins; int _hunterCountKiller; int.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins); int.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountKiller); _result2.Dispose(); if (_hunterCountVictim >= Bonus) { _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty + Bonus, _hunterCountKiller + 1, _cInfo2.playerId); SQL.FastQuery(_sql, "Bounties"); } else { _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty, _hunterCountKiller + 1, _cInfo2.playerId); SQL.FastQuery(_sql, "Bounties"); } _sql = string.Format("UPDATE Players SET bounty = 0, bountyHunter = 0 WHERE steamid = '{0}'", _cInfo1.playerId); SQL.FastQuery(_sql, "Bounties"); string _phrase912; if (!Phrases.Dict.TryGetValue(912, out _phrase912)) { _phrase912 = "{PlayerName} is a bounty hunter! {Victim} was snuffed out."; } _phrase912 = _phrase912.Replace("{PlayerName}", _cInfo2.playerName); _phrase912 = _phrase912.Replace("{Victim}", _cInfo1.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase912, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} is a bounty hunter! {2} was snuffed out. Bounty was worth {3}", DateTime.Now, _cInfo2.playerName, _cInfo1.playerName, _bounty)); sw.WriteLine(); sw.Flush(); sw.Close(); } } if (Kill_Streak > 0) { if (KillStreak.ContainsKey(_cInfo1.entityId)) { KillStreak.Remove(_cInfo1.entityId); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: Player {1} kill streak has come to an end by {2}.", DateTime.Now, _cInfo1.playerName, _cInfo2.playerName)); sw.WriteLine(); sw.Flush(); sw.Close(); } } if (KillStreak.ContainsKey(_cInfo2.entityId)) { int _value; if (KillStreak.TryGetValue(_cInfo2.entityId, out _value)) { int _newValue = _value + 1; KillStreak[_cInfo2.entityId] = _newValue; if (_newValue == Bounties.Kill_Streak) { string _phrase913; if (!Phrases.Dict.TryGetValue(913, out _phrase913)) { _phrase913 = "{PlayerName} is on a kill streak! Their bounty has increased."; } _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName); ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _phrase913, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } if (_newValue >= Bounties.Kill_Streak) { _sql = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo2.playerId); DataTable _result3 = SQL.TQuery(_sql); int _oldBounty; int.TryParse(_result3.Rows[0].ItemArray.GetValue(0).ToString(), out _oldBounty); _result3.Dispose(); _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _oldBounty + Bounties.Bonus, _cInfo1.playerId); SQL.FastQuery(_sql, "Bounties"); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} is on a kill streak of {2}. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _newValue)); sw.WriteLine(); sw.Flush(); sw.Close(); } } } } else { KillStreak.Add(_cInfo2.entityId, 1); } } } }