Hey guys. Today i will help you for fix zombie death bug. When you replace this code, your zombies will death anymore. (Barrels too)
Go to : GameServer / Networking / Handlers / HANDLE_ROOM_DATA.cs
Open HANDLE_ROOM_DATA.cs or Download -->
Delete all code.
And replace
Check your namespace, it's might be not same with my code.
Thanks the ToXiiC for ToXiiC Base.
Credits ;
ToXiiC
Go to : GameServer / Networking / Handlers / HANDLE_ROOM_DATA.cs
Open HANDLE_ROOM_DATA.cs or Download -->
You must be registered to see links
Delete all code.
And replace
Code:
using System;
using System.Collections;
using System.Linq;
using System.Text;
using GameServer.Managers;
using GameServer.Networking.Packets;
using GameServer.Virtual_Objects.Room;
using GameServer.Virtual_Objects.User;
namespace GameServer.Networking.Handlers
{ // 9075078112141769 November 23rd 2014 /// Check 968151 // Worgin Europe Ltd. Co. & NeXuuS
class HANDLE_ROOM_DATA : PacketHandler
{
~HANDLE_ROOM_DATA()
{
GC.Collect();
}
public enum Subtype : int
{
Start = 1,
ServerStart = 4,
ServerNewRound = 5,
ServerPrepareNewRound = 6,
NewRound = 7,
BackToRoom = 9,
VoteKickActive = 14,
ReadyState = 50,
MapChange = 51,
ModeChange = 52,
TimeChange = 54,
KillLimitDeathmatchChange = 53,
KillLimitExplosiveChange = 55,
PingChange = 59,
VoteKick = 61,
AutostartChange = 62,
SwitchTeam = 56,
UserLimit = 58,
KickUser = 61,
MagicSubtype1 = 100,
MagicSubtype2 = 154,
Heal = 101,
Damage = 103,
AmmoRecharge = 105,
Spawn = 150,
ServerKill = 152,
WeaponSwitch = 155,
Flag = 156,
Suicide = 157,
Place = 400,
PlaceUse = 401,
RoomReady = 402,
ServerRoomReady = 403,
FallDamage = 500,
DeathCam = 800,
RepairVehicle = 102,
DamageVehicle = 104,
VehicleKill = 153,
JoinVehicle = 200,
ChangeVehicleSeat = 201,
LeaveVehicle = 202
}
public bool haveItem(GameServer.Virtual_Objects.User.virtualUser User, string Weapon)
{
//DF10 - DF06 - DG08 - DC04 - DH02
if (User.hasItem(Weapon) || Weapon == "DA50" || Weapon == "DL01" || Weapon == "D001" || User.PCItem && (Weapon == "D501" || Weapon == "D602" || Weapon == "DG13" || Weapon == "D801" || Weapon == "D902") || Weapon == "DF01" || User.hasRetail(Weapon) || /* Retail part */ (Weapon == "DF07" || Weapon == "DF06" || Weapon == "DG08" || Weapon == "DH02") || /*end retail part*/ Weapon == "DN01" || Weapon == "DC02" || Weapon == "DG05" || Weapon == "DB01" || Weapon == "DJ01" || Weapon == "DA02")
return true;
return false;
}
public bool AllowedAfterKill(string Weapon)
{
if (Weapon.StartsWith("DN") || Weapon.StartsWith("DM") || Weapon == "DU04")
return true;
return false;
}
public bool isZombieWeapon(string Weapon)
{
if (Weapon == "DA50" || Weapon == "DA51" || Weapon == "DA52" || Weapon == "DA53" || Weapon == "DA54" || Weapon == "DN51" || Weapon == "DN52")
return true;
return false;
}
public override void Handle(GameServer.Virtual_Objects.User.virtualUser User)
{
try
{
if (Blocks.Length >= 1 && User.Room != null)
{
int sourceSeat = int.Parse(Blocks[0]);
int roomID = int.Parse(Blocks[1]);
if (sourceSeat == User.RoomSlot && roomID == User.Room.ID)
{
bool LobbyChange = false;
virtualRoom currentRoom = User.Room;
int subtype1 = int.Parse(Blocks[3]);
Subtype subtype = (Subtype)subtype1;
int tType = int.Parse(getBlock(3));
int tValue = int.Parse(getBlock(6));
int Value = int.Parse(getBlock(9));
int Place1 = int.Parse(getBlock(6));
int Place2 = int.Parse(getBlock(7));
string[] ArrSorted = new string[getAllBlocks().Length];
Array.Copy(getAllBlocks(), ArrSorted, getAllBlocks().Length);
int P0 = int.Parse(getBlock(0));
int P1 = int.Parse(getBlock(1));
string[] sendBlocks = new string[Blocks.Length - 1];
Array.Copy(Blocks, sendBlocks, sendBlocks.Length);
switch (subtype)
{
case Subtype.Start:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
if (currentRoom.isPremMap() == true && User.Premium < 1)
{
User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Room_ToAll, "SYSTEM >> You cannot start premium map as free user!!", 999, "NULL"));
break;
}
else if (currentRoom.Channel == 4 && User.Rank < 2)
{
currentRoom.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> This channel is not available yet.", 998, "NULL"));
break;
}
else if (currentRoom.RoomType == 1)
{
if (currentRoom.getSideCount(0) != currentRoom.getSideCount(1))
{
currentRoom.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Teems need to be balanced.", 998, "NULL"));
break;
}
}
if (Config.Debug == 0)
{
if (currentRoom.Channel != 3 && currentRoom.Mode != 1) if (currentRoom.Players.Count <= 1 || currentRoom.getSideCount(0) > currentRoom.getSideCount(1) + 1 || currentRoom.getSideCount(1) > currentRoom.getSideCount(0) + 1 || currentRoom.getSideCount(0) == 0 || currentRoom.getSideCount(1) == 0) break;
}
if (currentRoom.Start())
{
subtype = Subtype.ServerStart;
sendBlocks[6] = currentRoom.MapID.ToString();
currentRoom.Channel = User.Channel;
currentRoom.RoomStatus = 2;
LobbyChange = true;
}
}
break;
}
case Subtype.MapChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
currentRoom.MapID = tValue;
sendBlocks[7] = currentRoom.Mode.ToString();
}
break;
}
case Subtype.AutostartChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
//User.send(new PACKET_MESSAGEBOX("Autostart not Works!"));
}
break;
}
case Subtype.KillLimitDeathmatchChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
currentRoom.Rounds = int.Parse(sendBlocks[6]);
}
break;
}
case Subtype.KillLimitExplosiveChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
if (currentRoom.Mode == 1)
{
if (User.Premium > 0)
currentRoom.Rounds = int.Parse(sendBlocks[6]);
else
currentRoom.Rounds = 0;
}
else
currentRoom.Rounds = int.Parse(sendBlocks[6]);
}
break;
}
case Subtype.ModeChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
int OldMode = -1;
int NewMode = -1;
OldMode = currentRoom.Mode;
NewMode = int.Parse(Blocks[6]);
#region SendChange
switch (currentRoom.Channel)
{
case 1:
if (NewMode == 1)
{
currentRoom.Mode = 1;
if (User.Premium > 0)
currentRoom.Rounds = 2;
else
currentRoom.Rounds = 0;
sendBlocks[7] = (currentRoom.MapID = 12).ToString();
sendBlocks[9] = currentRoom.Rounds.ToString();
}
else if (NewMode == 0)
{
currentRoom.Mode = 0;
sendBlocks[7] = (currentRoom.MapID = 12).ToString();
sendBlocks[8] = (currentRoom.Rounds = 3).ToString();
sendBlocks[9] = (currentRoom.Rounds = 3).ToString();
}
else if (NewMode == 2)
{
currentRoom.Mode = 2;
sendBlocks[7] = (currentRoom.MapID = 27).ToString();
sendBlocks[8] = (currentRoom.Rounds = 2).ToString();
sendBlocks[9] = (currentRoom.Rounds = 2).ToString();
sendBlocks[10] = "2";
}
break;
case 2:
if (NewMode == 3)
{
sendBlocks[7] = (currentRoom.MapID = 40).ToString();
currentRoom.MapID = 40;
sendBlocks[10] = "3";
}
else if (NewMode == 2)
{
sendBlocks[7] = (currentRoom.MapID = 1).ToString();
sendBlocks[8] = "2";
currentRoom.Kills = 2;
currentRoom.MapID = 1;
sendBlocks[10] = "3";
}
break;
case 3:
break;
case 4:
if (OldMode == 7 && NewMode == 8)
{
sendBlocks[7] = currentRoom.MapID.ToString();
}
else if (OldMode == 8 && NewMode == 7)
{
sendBlocks[7] = (currentRoom.MapID = 46).ToString();
}
break;
}
#endregion
}
break;
}
case Subtype.KickUser:
{
return;
if (currentRoom.KickAlready == true || currentRoom.Mode == 1 || currentRoom.VoteKick == 0) return;
if (currentRoom.VoteKickTime > 0)
{
if (sendBlocks[6] == "1")
{
currentRoom.KickYes++; sendBlocks[6] = "1";
}
else if (sendBlocks[6] == "0")
{
currentRoom.KickNo++; sendBlocks[6] = "0";
}
}
else
{
currentRoom.KickSeat = int.Parse(sendBlocks[7]);
currentRoom.VoteKickTime = 30;
currentRoom.KickAlready = true;
Array.Resize<string>(ref currentRoom.KickString, sendBlocks.Length);
Array.Copy(sendBlocks, currentRoom.KickString, sendBlocks.Length);
currentRoom.KickString[5] = "4";
sendBlocks[6] = "1";
}
break;
}
case Subtype.ServerKill:
{
if (User.Health > 0) return;
User.Health = 0;
break;
}
case Subtype.PingChange:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot && currentRoom.RoomStatus != 2)
{
LobbyChange = true;
currentRoom.Ping = int.Parse(Blocks[6]);
}
break;
}
case Subtype.ReadyState:
{
User.isReady = !User.isReady;
sendBlocks[6] = Convert.ToByte(User.isReady).ToString();
break;
}
case Subtype.BackToRoom:
{
User.Health = 0;
break;
}
case Subtype.Suicide:
{
if (currentRoom.Mode != 2 && currentRoom.Mode != 3 || User.Health <= 0) return;
if (User.Health > 0)
{
User.Health = 0;
User.rDeaths += 1;
User.isSpawned = false;
if (currentRoom.getSide(User) == 0) { currentRoom.KillsDeberanLeft--; } else { currentRoom.KillsNIULeft--; }
}
break;
}
case Subtype.SwitchTeam:
{
if (User.isSpectating) return;
if (currentRoom.RoomType != 1)
{
if (currentRoom.canSwitch(User) == false) return;
sendBlocks[7] = currentRoom.switchSide(User).ToString();
sendBlocks[8] = currentRoom.RoomMasterSlot.ToString();
}
break;
}
case Subtype.RoomReady:
{
subtype = Subtype.ServerRoomReady;
sendBlocks[6] = "3";
sendBlocks[7] = "882";
sendBlocks[8] = "0";
sendBlocks[9] = "1";
break;
}
case Subtype.Spawn:
{
User.Class = Convert.ToInt32(getBlock(7));
User.ClassCode = getBlock(26);
if (User.isSpawned && User.Health > 0) return;
User.Health = 1000;
if (currentRoom.Mode == 1)
{
sendBlocks[10] = currentRoom.SpawnLocation.ToString();
sendBlocks[11] = currentRoom.SpawnLocation.ToString();
sendBlocks[12] = currentRoom.SpawnLocation.ToString();
currentRoom.SpawnLocation++;
}
if (currentRoom.Channel == 3)
{
currentRoom.spawnedPlayers++;
if (currentRoom.PlayerCount >= currentRoom.spawnedPlayers)
currentRoom.readyZombie = true;
}
User.Rockets = User.Granade = User.killFromSpawn = 0;
User.SpawnProtection = 3;
User.isSpawned = true;
break;
}
case Subtype.FallDamage:
{
// TIP: Beringia bugs if you don't prevent fall damage here, beringia sends every second fall damage packet (?)
int totalDamage = int.Parse(Blocks[9]);
int Type = int.Parse(getBlock(6));
if (Type == 1)
{
if (totalDamage < 0 || User.Health <= 0) return;
User.Health -= totalDamage;
if (User.Health <= 0)
{
subtype = Subtype.Suicide;
sendBlocks[6] = User.RoomSlot.ToString();
User.Health = 0;
User.rDeaths++;
User.isSpawned = false;
if (currentRoom.getSide(User) == 0) { currentRoom.KillsDeberanLeft--; } else { currentRoom.KillsNIULeft--; }
}
else
{
sendBlocks[11] = totalDamage.ToString();
sendBlocks[12] = User.Health.ToString();
}
}
else
{
int dSubtype = int.Parse(getBlock(3));
int vehicleID = int.Parse(getBlock(8));
int vehDamage = int.Parse(getBlock(9));
currentRoom.Vehicles[vehicleID].Health -= vehDamage;
sendBlocks[2] = "2";
sendBlocks[3] = vehicleID.ToString();
sendBlocks[11] = vehDamage.ToString();
sendBlocks[12] = currentRoom.Vehicles[vehicleID].Health.ToString();
if (currentRoom.Vehicles[vehicleID].Health <= 0)
{
User.rDeaths++;
User.rPoints++;
User.Health = 0;
currentRoom.Vehicles[vehicleID].Health = 0;
User.currentVehicle = null;
User.isSpawned = false;
if (currentRoom.getSide(User) == 0) { currentRoom.KillsDeberanLeft--; } else { currentRoom.KillsNIULeft--; }
subtype = Subtype.Suicide;
sendBlocks[6] = User.RoomSlot.ToString();
currentRoom.send(new PACKET_ROOM_DATA(User, int.Parse(getBlock(0)), int.Parse(getBlock(1)), int.Parse(getBlock(2)), 153, 0, 1, 0, 0, 0, 1337, 7, 35, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "FFFF"));
}
}
break;
}
case Subtype.Place:
{
if (User.Plantings > 8) return;
string ItemCode = Blocks[26];
if (User.hasItem(ItemCode))
{
User.disconnect();
}
else if (User.Plantings < 8)
{
User.Plantings++;
sendBlocks[8] = currentRoom.AddPlacment(User, ItemCode).ToString();
}
break;
}
case Subtype.Damage:
{
/*0 0 2 103 0 1 1 4 0 39 0 39 2 0 0 1242 0 0 4488.7671 1105.4860 3464.1897 2.0000 0 14.0000 5.0000 0 DF01 */
/*4 0 2 103 0 1 1 0 4 24 0 24 4 0 0 3620 0 0 0 4571.9575 1104.7207 3315.2612 4.0000 0 20.0000 5.0000 0 DC063499 */
int HeadshotCalculation = int.Parse(getBlock(15));
string block21 = getBlock(22);
string Weapon = getBlock(27).Substring(0, 4);
int Damage = ItemManager.getDamage(Weapon);
int Point = 5;
//if (haveItem(User, Weapon) == false && isZombieWeapon(Weapon) == false) User.disconnect();
#region Zombie
if (User.Channel == 3)
{
int ZombieID = int.Parse(getBlock(7));
if (ZombieID > 3)
{
foreach (virtualZombie _Zombie in currentRoom.Zombies)
{
if (_Zombie.ID == ZombieID)
{
if (_Zombie.Points != 0)
{
if (_Zombie.Health > 1)
{
_Zombie.Health = (_Zombie.Health - Damage);
if (_Zombie.Health <= 0) return;
currentRoom.send(new SP_ROOM_INFO(103,
int.Parse(getBlock(0)),
int.Parse(getBlock(1)),
int.Parse(getBlock(2)),
int.Parse(getBlock(4)),
int.Parse(getBlock(5)),
int.Parse(getBlock(6)),
int.Parse(getBlock(7)),
int.Parse(getBlock(8)),
int.Parse(getBlock(9)),
int.Parse(getBlock(10)),
int.Parse(getBlock(11)),
int.Parse(getBlock(12)),
int.Parse(getBlock(13)),
int.Parse(getBlock(14)),
_Zombie.Health,
(_Zombie.Health + Damage),
int.Parse(getBlock(17)),
getBlock(18), // X
getBlock(19), // Z
getBlock(20), // Y
getBlock(21), // 2.0000
int.Parse(getBlock(22)),
getBlock(23), // 93.0000
getBlock(24), // 1.0000
getBlock(25), // 0
getBlock(26),
Weapon));
return;
}
else
{
subtype = Subtype.ServerKill;
currentRoom.highestKills++;
currentRoom.zombieKills++;
User.rKills++;
currentRoom.Zombies.Remove(ZombieID);
_Zombie.Health = -1;
_Zombie.ID = -1;
currentRoom.Zombies.Remove(_Zombie);
if (HeadshotCalculation == (1237 + User.SessionID))
{
if (Weapon.Contains("DA") || Weapon.Contains("DN") || Weapon.Contains(("DJ")))
{
User.rPoints += _Zombie.Points;
currentRoom.zombiePoints += _Zombie.Points;
block21 = "2.0000";
}
else
{
User.rPoints += _Zombie.Points * 2;
currentRoom.zombiePoints += _Zombie.Points * 2;
block21 = "99.0000";
}
}
else
{
User.rPoints += _Zombie.Points;
currentRoom.zombiePoints += _Zombie.Points;
}
currentRoom.send(new SP_ROOM_INFO(152,
int.Parse(getBlock(0)),
int.Parse(getBlock(1)),
int.Parse(getBlock(2)),
int.Parse(getBlock(4)),
int.Parse(getBlock(5)),
int.Parse(getBlock(6)),
int.Parse(getBlock(7)),
int.Parse(getBlock(8)),
int.Parse(getBlock(9)),
int.Parse(getBlock(10)),
int.Parse(getBlock(11)),
int.Parse(getBlock(12)),
int.Parse(getBlock(13)),
int.Parse(getBlock(14)),
int.Parse(getBlock(15)),
int.Parse(getBlock(16)),
int.Parse(getBlock(17)),
getBlock(18), // X
getBlock(19), // Z
getBlock(20), // Y
getBlock(21),
block21, // 99.0000
int.Parse(getBlock(23)),
getBlock(24), // 93.0000
getBlock(25), // 1.0000
getBlock(26), // 0
Weapon));
}
}
}
}
}
else
{
User.Health = User.Health - 100;
if (User.Health > 0)
{
currentRoom.send(new SP_ROOM_INFO(103,
int.Parse(getBlock(0)),
int.Parse(getBlock(1)),
int.Parse(getBlock(2)),
int.Parse(getBlock(4)),
int.Parse(getBlock(5)),
int.Parse(getBlock(6)),
int.Parse(getBlock(7)),
int.Parse(getBlock(8)),
int.Parse(getBlock(9)),
int.Parse(getBlock(10)),
int.Parse(getBlock(11)),
int.Parse(getBlock(12)),
int.Parse(getBlock(13)),
int.Parse(getBlock(14)),
int.Parse(getBlock(15)),
User.Health,
User.Health + 100, //Damage
getBlock(18), // X
getBlock(19), // Z
getBlock(20), // Y
getBlock(21), // 2.0000
int.Parse(getBlock(22)),
getBlock(23), // 93.0000
getBlock(24), // 1.0000
getBlock(25), // 0
getBlock(26),
Weapon));
sendBlocks[7] = User.Health.ToString();
}
else
{
if (User.isSpawned == true)
{
subtype = Subtype.ServerKill;
User.rDeaths++;
}
User.Health = 0;
User.isSpawned = false;
}
}
}
else
{
#endregion
if (Damage < 0 || User.Health <= 0 && AllowedAfterKill(Weapon) == false || User.isSpawned == false && AllowedAfterKill(Weapon) == false) return;
int TargetID = int.Parse(getBlock(7));
virtualUser Target = currentRoom.getPlayer(TargetID);
if (currentRoom.getSide(User) == currentRoom.getSide(Target) && currentRoom.Mode != 1) return;
if (Target != null && Target.isSpawned)
{
if (Target.SpawnProtection > 0 || currentRoom.getSide(User) == currentRoom.getSide(Target) && currentRoom.Mode != 1 || currentRoom.RoomStatus == 1) return;
if (currentRoom.RoomType == 2)
if (!Weapon.Contains("DA")) User.disconnect();
if (HeadshotCalculation == (1241 + User.SessionID))
Damage -= 85;
else if (HeadshotCalculation == (1239 + User.SessionID))
Damage -= 50;
else if (HeadshotCalculation == (1237 + User.SessionID))
{
if (Weapon.Contains("DA") || Weapon.Contains("DN") || Weapon.Contains("DJ") || Weapon.Contains("DM"))
{
block21 = "2.000";
}
else
{
block21 = "99.0000";
Damage += 200;
Point += 3;
if (Target.Health - Damage <= 0 && currentRoom.FirstBlood)
{
User.send(new PACKET_TO_CLIENT(1));
}
}
}
//try
if (User.Granade > 3 || User.Rockets > 13) User.disconnect();
if (Weapon.StartsWith("DJ"))
User.Rockets++;
else if (Weapon.StartsWith("DN"))
User.Granade++;
Target.Health -= Damage;
sendBlocks[16] = Target.Health.ToString(); //
sendBlocks[17] = (Target.Health + Damage).ToString(); //
sendBlocks[18] = Point + ".0000"; // UPDATE 24.07.2013 - Showen points in the center of the screen when you kill
sendBlocks[22] = block21; // Headshot or other poop handled from SessionID [ TODO: Costume calculate damage ]
sendBlocks[27] = Weapon; // Weapon (NX removes the other 4 chars ( Splitted full is ) - DF01299 = Weapon[4]|Class[1]|Damage[3]
if (Target.Health <= 2)
{
if (currentRoom.FirstBlood == false)
{
currentRoom.send(new PACKET_TO_CLIENT(0));
currentRoom.FirstBlood = true;
}
Target.isSpawned = false;
if (User.rKills > currentRoom.highestKills) { currentRoom.highestKills = User.rKills; }
if (currentRoom.getSide(Target) == 0) { currentRoom.KillsDeberanLeft--; } else { currentRoom.KillsNIULeft--; }
subtype = Subtype.ServerKill;
Target.isSpawned = false;
User.rKills++;
User.rPoints += Point;
User.killFromSpawn++;
Target.rDeaths++;
Target.rPoints++;
Target.Health = 0;
Target.isSpawned = false;
Target.ClassCode = "-1";
}
}
}
break;
}
case Subtype.RepairVehicle:
{
int vehicleID = int.Parse(getBlock(6));
int Health = currentRoom.Vehicles[vehicleID].Health;
int MaxHealth = currentRoom.Vehicles[vehicleID].MaxHealth;
int Repair = 1000;
if (Health >= MaxHealth)
return;
int newHP = MaxHealth += Repair;
if (newHP >= MaxHealth)
newHP = MaxHealth;
sendBlocks[2] = "2";
sendBlocks[3] = "101";
sendBlocks[7] = newHP.ToString();
sendBlocks[8] = MaxHealth.ToString();
break;
}
case Subtype.VehicleKill:
{
sendBlocks[7] = sendBlocks[7] + 1;
sendBlocks[15] = "100";
sendBlocks[16] = "0";
sendBlocks[17] = "1000";
break;
}
/*case Subtype.PlaceUse:
{
int plantingID = int.Parse(Blocks[8]);
string plantingCode = getBlock(26);
virtualPlacment Placment = currentRoom.getPlant(plantingID);
if (User.Health <= 0 || User.isSpawned == false) return;
if (Placment == null || Placment.Used)
{
Log.WriteError(plantingID + " plant @ room " + currentRoom.ID + " doesn't exit or used"); return;
}
virtualUser Planter = currentRoom.getPlantUser(plantingID);
int PlanterSide = currentRoom.getSide(Planter);
int UserSide = currentRoom.getSide(User);
switch (plantingCode)
{
case "DV01":
{
User.Health += 500;
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide == PlanterSide)
Planter.rPoints += 5;
}
break;
}
case "DU01":
{
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide == PlanterSide && Planter.droppedAmmo < 10)
{
Planter.droppedAmmo++;
Planter.rPoints += 3;
}
}
break;
}
case "DU02":
{
User.Health -= 50;
if (User.Health <= 1)
User.Health = 1;
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide != PlanterSide && Planter.droppedM14 < 8)
{
Planter.droppedM14++;
Planter.rPoints += 3;
}
}
break;
}
case "DS05":
{
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide != PlanterSide && Planter.droppedFlash < 6)
{
Planter.droppedFlash++;
Planter.rPoints += 5;
}
}
break;
}
}
if (User.Health >= 1000)
User.Health = 1000;
sendBlocks[10] = User.Health.ToString();
Placment.Used = true;
break;
}*/
case Subtype.PlaceUse:
{
int plantingID = int.Parse(Blocks[8]);
string plantingCode = getBlock(27);
virtualPlacment Placment = currentRoom.getPlant(plantingID);
if (User.Health <= 0 || User.isSpawned == false) return;
if (Placment == null || Placment.Used)
{
//Log.WriteError(plantingID + " plant @ room " + currentRoom.ID + " doesn't exit or used"); return;
}
virtualUser Planter = currentRoom.getPlantUser(plantingID);
int PlanterSide = currentRoom.getSide(Planter);
int UserSide = currentRoom.getSide(User);
if (plantingCode == "DV01")
{
User.Health += 400; // FIXED IDK IF THATS RIGHT BLOCK = 27 NOT 26 SNIFFED BY
Planter.rPoints += 3;
}
else if (plantingCode == "DU01")
{
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide == PlanterSide && Planter.droppedAmmo < 10)
{
Planter.droppedAmmo++;
Planter.rPoints += 3;
}
}
break;
}
else if (plantingCode == "DU02")
{
User.Health -= 50;
if (User.Health <= 1)
User.Health = 1;
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide != PlanterSide && Planter.droppedM14 < 8)
{
Planter.droppedM14++;
Planter.rPoints += 3;
}
}
break;
}
else if (plantingCode == "DS05")
{
if (Planter != null)
{
if (User.Equals(Planter) == false && UserSide != PlanterSide && Planter.droppedFlash < 6)
{
Planter.droppedFlash++;
Planter.rPoints += 3;
}
}
break;
}
if (User.Health > 1000)
User.Health = 1000;
sendBlocks[10] = User.Health.ToString();
Placment.Used = true;
break;
}
case Subtype.UserLimit:
{
if (currentRoom.RoomMasterSlot == User.RoomSlot)
{
if (currentRoom.RoomStatus == 1)
{
currentRoom.UserLimit = !currentRoom.UserLimit;
if (currentRoom.UserLimit == true)
currentRoom.UserLimitCount = currentRoom.Players.Count;
else
currentRoom.UserLimitCount = currentRoom.MaxPlayers;
sendBlocks[6] = (currentRoom.UserLimit == true ? 1 : 0).ToString();
LobbyChange = true;
}
}
break;
}
case Subtype.WeaponSwitch:
{
if (User.isSpawned == false || User.Health <= 0) return;
User.Weapon = Convert.ToInt32(sendBlocks[6]);
break;
}
case Subtype.Heal:
{
/*
* 0 0 2 101 0 0 0 0 0 0 0 0 0 0 // Normaly Heal
* 0 0 2 101 0 0 0 0 1 0 0 0 0 0 // Remove HP
* 0 0 2 101 0 0 0 1 0 0 0 0 0 0 // Medic Box Station
*/
if (User.Weapon == 101) return; // If the weapon is stamina
int TargetSlot = int.Parse(getBlock(6)); // The target
bool ToHeal = (getBlock(8) == "1" ? false : true); // If user needed to be healed or killed
bool BoxStation = (getBlock(7) == "1" ? true : false); // If is an medic station or just normal healing
if (TargetSlot >= 0 && TargetSlot <= User.Room.MaxPlayers)
{
GameServer.Virtual_Objects.User.virtualUser _Target = User.Room.getPlayer(TargetSlot);
if (_Target != null)
{
if (ToHeal)
{
if (_Target.Health <= 0 || _Target.Health >= 1000 || (User.Room.Mode != 1 && User.Room.getSide(User) != User.Room.getSide(_Target))) return; // Check for the health and don't let user to heal the other side players
if (_Target.RoomSlot != User.RoomSlot && _Target.Health <= 300) // Player assist
User.rPoints += 5;
switch (User.Weapon)
{
case 99: // Adrenaline
{
if (_Target.Health < 300)
_Target.Health = 300;
else _Target.Health += 100;
break;
}
case 102: // HP Kit
{
_Target.Health += 800;
break;
}
case 94: // Medic_Kit 1
{
_Target.Health += 300;
break;
}
case 95: // Medic_Kit 2
{
_Target.Health += 400;
break;
}
case 96: // Medic_Kit 3
{
_Target.Health += 600;
break;
}
}
if (BoxStation)
_Target.Health += 500;
if (_Target.Health > 1000)
_Target.Health = 1000;
}
else // If needed to be killed
{
_Target.Health -= 100; // Remove 1HP for tick!
if (_Target.Health <= 1) // Send suicide if user has no HP
{
subtype = Subtype.Suicide;
_Target.isSpawned = false;
}
}
sendBlocks[7] = _Target.Health.ToString();
}
}
break;
}
case Subtype.JoinVehicle:
{
int vehicleID = int.Parse(getBlock(7));
currentRoom.Vehicles[vehicleID].Join(User);
sendBlocks[8] = currentRoom.Vehicles[vehicleID].Health.ToString();
sendBlocks[9] = currentRoom.Vehicles[vehicleID].MaxHealth.ToString();
sendBlocks[10] = currentRoom.Vehicles[vehicleID].FindSeat(User).MainCT.ToString();
sendBlocks[11] = currentRoom.Vehicles[vehicleID].FindSeat(User).SubCT.ToString();
sendBlocks[13] = currentRoom.Vehicles[vehicleID].GetSeat(User).ToString();
User.currentVehicle = currentRoom.Vehicles[vehicleID];
break;
}
case Subtype.ChangeVehicleSeat:
{
int oldSeat = User.currentVehicle.GetSeat(User);
User.currentVehicle.TakeSeat(int.Parse(Blocks[7]), User);
int targetSeat = User.currentVehicle.GetSeat(User);
sendBlocks[7] = targetSeat.ToString();
sendBlocks[8] = oldSeat.ToString();
sendBlocks[9] = User.currentVehicle.FindSeat(User).MainCT.ToString();
sendBlocks[10] = User.currentVehicle.FindSeat(User).SubCT.ToString();
sendBlocks[11] = "0";
sendBlocks[12] = oldSeat.ToString();
break;
}
case Subtype.LeaveVehicle:
{
int vehicleID = int.Parse(Blocks[6]);
if (vehicleID >= 0 && vehicleID <= currentRoom.Vehicles.Length)
{
currentRoom.Vehicles[vehicleID].FindSeat(User).MainCT = int.Parse(Blocks[8]);
currentRoom.Vehicles[vehicleID].FindSeat(User).SubCT = int.Parse(Blocks[9]);
sendBlocks[7] = currentRoom.Vehicles[vehicleID].GetSeat(User).ToString();
currentRoom.Vehicles[vehicleID].Leave(User);
User.currentVehicle = null;
}
break;
}
case Subtype.DamageVehicle:
{
int DamageDealt = 0;
int vehicleID = int.Parse(getBlock(7));
string Weapon = getBlock(27).Substring(0, 4);
DamageDealt = ItemManager.getDamage(Weapon);
if (!Weapon.Contains("DJ"))
DamageDealt = DamageDealt / 2;
if (User.currentVehicle != null)
{
DamageDealt = 500;
}
if (currentRoom.Channel == 3 && isZombieWeapon(Weapon) == true)
DamageDealt = 150 * (currentRoom.ZombieDifficulty + 1);
string[] DamageData = new string[2];
if ((currentRoom.MapID == 48 && vehicleID == 5 || currentRoom.MapID == 50 && vehicleID == 1 || (currentRoom.MapID == 51 && vehicleID == 5 || currentRoom.MapID == 52 && vehicleID == 13)) && !this.isZombieWeapon(Weapon) == false) return;
DamageData[0] = (currentRoom.Vehicles[vehicleID].Health - DamageDealt).ToString();
DamageData[1] = currentRoom.Vehicles[vehicleID].Health.ToString();
currentRoom.Vehicles[vehicleID].Health -= DamageDealt;
if (currentRoom.Vehicles[vehicleID].Health <= 1)
{
if (vehicleID == 1 && currentRoom.MapID == 50 || vehicleID == 5 && currentRoom.MapID == 48 || currentRoom.MapID == 51 && vehicleID == 5 || currentRoom.MapID == 52 && vehicleID == 13)
currentRoom.endGame();
tType = 153;
}
currentRoom.send(new PACKET_ROOM_DATA(User,
int.Parse(getBlock(0)),
int.Parse(getBlock(1)),
int.Parse(getBlock(2)),
tType,
int.Parse(getBlock(4)),
int.Parse(getBlock(5)),
int.Parse(getBlock(6)),
int.Parse(getBlock(7)),
int.Parse(getBlock(8)),
int.Parse(getBlock(9)),
int.Parse(getBlock(10)),
int.Parse(getBlock(11)),
int.Parse(getBlock(12)),
int.Parse(getBlock(13)),
int.Parse(getBlock(14)),
DamageData[0],
DamageData[1],
int.Parse(getBlock(17)),
getBlock(18), // X
getBlock(19), // Z
getBlock(20), // Y
getBlock(21), // 2.0000
int.Parse(getBlock(22)),
getBlock(23), // 93.0000
getBlock(24), // 1.0000
getBlock(25), // 0
getBlock(26),
Weapon));
return;
}
/*case Subtype.Flag: //old source code.
{
int flagNumber = int.Parse(getBlock(6));
int Side = currentRoom.getSide(User);
int oldState = currentRoom.Flags[flagNumber];
if (oldState == Side) return;
bool toRemove = (currentRoom.Rounds > 2 ? true : false);
//Log.WriteDebug("Flag " + flagNumber + " is now of the team n: " + Side + " [Old state: " + oldState + " / New state: " + Side + "]");
/*if (oldState == -1)
{
currentRoom.Flags[flagNumber] = Side;
if (User.rFlags < 30)
User.rPoints += 3;
User.rFlags++;
}
else
{
currentRoom.Flags[flagNumber] = -1;
}*//*
if (oldState != -1)
{
currentRoom.Flags[flagNumber] = -1;
}
else
{
currentRoom.Flags[flagNumber] = Side;
if (User.rFlags < 30)
User.rPoints += 3;
User.rFlags++;
}
if (toRemove)
{
switch (Side)
{
case 0: currentRoom.KillsNIULeft--; break;
case 1: currentRoom.KillsDeberanLeft--; break;
}
}
currentRoom.UpdateTime();
currentRoom.send(new SP_ROOM_INFO(156,
int.Parse(getBlock(0)),
int.Parse(getBlock(1)),
int.Parse(getBlock(2)),
0,
0,
flagNumber,
currentRoom.Flags[flagNumber],
oldState,
flagNumber,
0,
0,
0,
0));
return;
}
}
sendBlocks[3] = ((int)subtype).ToString();
*/
case Subtype.Flag:
{
if (!currentRoom.GameActive) return;
int flagId = int.Parse(getBlock(6));
if (currentRoom.MapData == null) return;
int flagSide = currentRoom.Flags[flagId];
int mySide = currentRoom.getSide(User);
//Log.WriteLine(mySide + " -> taking " + flagId + " [" + flagSide + "]");
if (flagSide == mySide) return;
bool RemovePoints = (currentRoom.Rounds > 2);
if (flagSide == -1) // Neutral
{
currentRoom.Flags[flagId] = mySide;
if (User.rFlags < 30) User.rPoints += 3;
User.rFlags++;
}
else
{
currentRoom.Flags[flagId] = -1; // Make it neutral before acquiring it
}
if (RemovePoints)
{
switch (mySide)
{
case 0: currentRoom.KillsNIULeft--; break;
case 1: currentRoom.KillsDeberanLeft--; break;
}
}
sendBlocks[6] = flagId.ToString(); // Flag ID
sendBlocks[7] = currentRoom.Flags[flagId].ToString(); // Actual State
sendBlocks[8] = flagSide.ToString(); // Old State
sendBlocks[9] = flagId.ToString(); // Flag ID
sendBlocks[11] = "0";
break;
}
}
sendBlocks[3] = ((int)subtype).ToString();
if (subtype == Subtype.ServerRoomReady)
{
//User.send(new PACKET_INIT_PLAYER(User));
User.send(new PACKET_MAP_DATA(currentRoom));
User.send(new PACKET_ROOM_DATA(User, sendBlocks));
}
else if (subtype == Subtype.KickUser)
{
foreach (virtualUser Players in currentRoom.getTeamPlayer(currentRoom.getSide(User)))
Players.send(new PACKET_ROOM_DATA(User, sendBlocks));
}
else
{
currentRoom.send(new PACKET_ROOM_DATA(User, sendBlocks));
}
if (LobbyChange)
{
foreach (virtualUser _User in UserManager.getUsersInChannel(currentRoom.Channel, false))
if (_User.Page == Math.Floor(Convert.ToDecimal(currentRoom.ID / 14)))
_User.send(new PACKET_ROOMLIST_UPDATE(currentRoom));
}
}
}
}
catch (Exception)
{
//Log.WriteError(ex.Message + " at handle room data");
}
}
}
}
Check your namespace, it's might be not same with my code.
Thanks the ToXiiC for ToXiiC Base.
Credits ;
ToXiiC