Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Football Bug
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Central" data-source="post: 448094" data-attributes="member: 57042"><p>I tried it on my hotel and it works, try this?</p><p>[CODE=csharp]using System;</p><p>using System.Linq;</p><p>using System.Drawing;</p><p>using System.Collections.Generic;</p><p>using System.Collections.Concurrent;</p><p></p><p>using Plus.Communication.Packets.Incoming;</p><p></p><p>using Plus.HabboHotel.Items;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Engine;</p><p>using Plus.HabboHotel.Rooms.Games.Teams;</p><p>using Plus.HabboHotel.Items.Wired;</p><p>using Plus.HabboHotel.Rooms.PathFinding;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Games.Football</p><p>{</p><p> public class Soccer</p><p> {</p><p> private Room _room;</p><p> private Item[] gates;</p><p> private ConcurrentDictionary<int, Item> _balls;</p><p> private bool _gameStarted;</p><p></p><p> public Soccer(Room room)</p><p> {</p><p> this._room = room;</p><p> this.gates = new Item[4];</p><p> this._balls = new ConcurrentDictionary<int, Item>();</p><p> this._gameStarted = false;</p><p> }</p><p> public bool GameIsStarted</p><p> {</p><p> get { return this._gameStarted; }</p><p> }</p><p> public void StopGame(bool userTriggered = false)</p><p> {</p><p> this._gameStarted = false;</p><p></p><p> if (!userTriggered)</p><p> _room.GetWired().TriggerEvent(WiredBoxType.TriggerGameEnds, null);</p><p> }</p><p></p><p> public void StartGame()</p><p> {</p><p> this._gameStarted = true;</p><p> }</p><p></p><p> public void AddBall(Item item)</p><p> {</p><p> this._balls.TryAdd(item.Id, item);</p><p> }</p><p></p><p> public void RemoveBall(int itemID)</p><p> {</p><p> Item Item = null;</p><p> this._balls.TryRemove(itemID, out Item);</p><p> }</p><p></p><p> public void OnUserWalk(RoomUser User)</p><p> {</p><p> if (User == null)</p><p> return;</p><p></p><p> foreach (Item item in this._balls.Values.ToList())</p><p> {</p><p> int NewX = 0;</p><p> int NewY = 0;</p><p> int differenceX = User.X - item.GetX;</p><p> int differenceY = User.Y - item.GetY;</p><p></p><p> if (differenceX == 0 && differenceY == 0)</p><p> {</p><p> if (User.RotBody == 4)</p><p> {</p><p> NewX = User.X;</p><p> NewY = User.Y + 2;</p><p></p><p> }</p><p> else if (User.RotBody == 6)</p><p> {</p><p> NewX = User.X - 2;</p><p> NewY = User.Y;</p><p></p><p> }</p><p> else if (User.RotBody == 0)</p><p> {</p><p> NewX = User.X;</p><p> NewY = User.Y - 2;</p><p></p><p> }</p><p> else if (User.RotBody == 2)</p><p> {</p><p> NewX = User.X + 2;</p><p> NewY = User.Y;</p><p></p><p> }</p><p> else if (User.RotBody == 1)</p><p> {</p><p> NewX = User.X + 2;</p><p> NewY = User.Y - 2;</p><p></p><p> }</p><p> else if (User.RotBody == 7)</p><p> {</p><p> NewX = User.X - 2;</p><p> NewY = User.Y - 2;</p><p></p><p> }</p><p> else if (User.RotBody == 3)</p><p> {</p><p> NewX = User.X + 2;</p><p> NewY = User.Y + 2;</p><p></p><p> }</p><p> else if (User.RotBody == 5)</p><p> {</p><p> NewX = User.X - 2;</p><p> NewY = User.Y + 2;</p><p> }</p><p></p><p> if (!this._room.GetRoomItemHandler().CheckPosItem(User.GetClient(), item, NewX, NewY, item.Rotation, false, false))</p><p> {</p><p> if (User.RotBody == 0)</p><p> {</p><p> NewX = User.X;</p><p> NewY = User.Y + 1;</p><p> }</p><p> else if (User.RotBody == 2)</p><p> {</p><p> NewX = User.X - 1;</p><p> NewY = User.Y;</p><p> }</p><p> else if (User.RotBody == 4)</p><p> {</p><p> NewX = User.X;</p><p> NewY = User.Y - 1;</p><p> }</p><p> else if (User.RotBody == 6)</p><p> {</p><p> NewX = User.X + 1;</p><p> NewY = User.Y;</p><p> }</p><p> else if (User.RotBody == 5)</p><p> {</p><p> NewX = User.X + 1;</p><p> NewY = User.Y - 1;</p><p> }</p><p> else if (User.RotBody == 3)</p><p> {</p><p> NewX = User.X - 1;</p><p> NewY = User.Y - 1;</p><p> }</p><p> else if (User.RotBody == 7)</p><p> {</p><p> NewX = User.X + 1;</p><p> NewY = User.Y + 1;</p><p> }</p><p> else if (User.RotBody == 1)</p><p> {</p><p> NewX = User.X - 1;</p><p> NewY = User.Y + 1;</p><p> }</p><p> }</p><p> }</p><p> else if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1 && VerifyBall(User, item.Coordinate.X, item.Coordinate.Y))//VERYFIC BALL CHECAR SI ESTA EN DIRECCION ASIA LA PELOTA</p><p> {</p><p> NewX = differenceX * -1;</p><p> NewY = differenceY * -1;</p><p></p><p> NewX = NewX + item.GetX;</p><p> NewY = NewY + item.GetY;</p><p> }</p><p></p><p> if (item.GetRoom().GetGameMap().ValidTile(NewX, NewY))</p><p> {</p><p> MoveBall(item, NewX, NewY, User);</p><p> }</p><p> }</p><p> }</p><p></p><p> private bool VerifyBall(RoomUser user, int actualx, int actualy)</p><p> {</p><p> return Rotation.Calculate(user.X, user.Y, actualx, actualy) == user.RotBody;</p><p> }</p><p></p><p> public void RegisterGate(Item item)</p><p> {</p><p> if (gates[0] == null)</p><p> {</p><p> item.team = TEAM.BLUE;</p><p> gates[0] = item;</p><p> }</p><p> else if (gates[1] == null)</p><p> {</p><p> item.team = TEAM.RED;</p><p> gates[1] = item;</p><p> }</p><p> else if (gates[2] == null)</p><p> {</p><p> item.team = TEAM.GREEN;</p><p> gates[2] = item;</p><p> }</p><p> else if (gates[3] == null)</p><p> {</p><p> item.team = TEAM.YELLOW;</p><p> gates[3] = item;</p><p> }</p><p> }</p><p></p><p> public void UnRegisterGate(Item item)</p><p> {</p><p> switch (item.team)</p><p> {</p><p> case TEAM.BLUE:</p><p> {</p><p> gates[0] = null;</p><p> break;</p><p> }</p><p> case TEAM.RED:</p><p> {</p><p> gates[1] = null;</p><p> break;</p><p> }</p><p> case TEAM.GREEN:</p><p> {</p><p> gates[2] = null;</p><p> break;</p><p> }</p><p> case TEAM.YELLOW:</p><p> {</p><p> gates[3] = null;</p><p> break;</p><p> }</p><p> }</p><p> }</p><p></p><p> public void onGateRemove(Item item)</p><p> {</p><p> switch (item.GetBaseItem().InteractionType)</p><p> {</p><p> case InteractionType.FOOTBALL_GOAL_RED:</p><p> case InteractionType.footballcounterred:</p><p> {</p><p> _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.RED);</p><p> break;</p><p> }</p><p> case InteractionType.FOOTBALL_GOAL_GREEN:</p><p> case InteractionType.footballcountergreen:</p><p> {</p><p> _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.GREEN);</p><p> break;</p><p> }</p><p> case InteractionType.FOOTBALL_GOAL_BLUE:</p><p> case InteractionType.footballcounterblue:</p><p> {</p><p> _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.BLUE);</p><p> break;</p><p> }</p><p> case InteractionType.FOOTBALL_GOAL_YELLOW:</p><p> case InteractionType.footballcounteryellow:</p><p> {</p><p> _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.YELLOW);</p><p> break;</p><p> }</p><p> }</p><p> }</p><p></p><p> public void MoveBall(Item item, int newX, int newY, RoomUser user)</p><p> {</p><p> if (item == null || user == null)</p><p> return;</p><p></p><p> if (!_room.GetGameMap().itemCanBePlacedHere(newX, newY))</p><p> return;</p><p></p><p> Point oldRoomCoord = item.Coordinate;</p><p> if (oldRoomCoord.X == newX && oldRoomCoord.Y == newY)</p><p> return;</p><p></p><p> double NewZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];</p><p></p><p> _room.SendPacket(new SlideObjectBundleComposer(item.Coordinate.X, item.Coordinate.Y, item.GetZ, newX, newY, NewZ, item.Id, item.Id, item.Id));</p><p></p><p> item.ExtraData = "11";</p><p> item.UpdateNeeded = true;</p><p></p><p> _room.GetRoomItemHandler().SetFloorItem(null, item, newX, newY, item.Rotation, false, false, false, false);</p><p></p><p> this._room.OnUserShoot(user, item);</p><p> }</p><p></p><p> public void Dispose()</p><p> {</p><p> Array.Clear(gates, 0, gates.Length);</p><p> gates = null;</p><p> _room = null;</p><p> _balls.Clear();</p><p> _balls = null;</p><p> }</p><p> }</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="Central, post: 448094, member: 57042"] I tried it on my hotel and it works, try this? [CODE=csharp]using System; using System.Linq; using System.Drawing; using System.Collections.Generic; using System.Collections.Concurrent; using Plus.Communication.Packets.Incoming; using Plus.HabboHotel.Items; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Engine; using Plus.HabboHotel.Rooms.Games.Teams; using Plus.HabboHotel.Items.Wired; using Plus.HabboHotel.Rooms.PathFinding; namespace Plus.HabboHotel.Rooms.Games.Football { public class Soccer { private Room _room; private Item[] gates; private ConcurrentDictionary<int, Item> _balls; private bool _gameStarted; public Soccer(Room room) { this._room = room; this.gates = new Item[4]; this._balls = new ConcurrentDictionary<int, Item>(); this._gameStarted = false; } public bool GameIsStarted { get { return this._gameStarted; } } public void StopGame(bool userTriggered = false) { this._gameStarted = false; if (!userTriggered) _room.GetWired().TriggerEvent(WiredBoxType.TriggerGameEnds, null); } public void StartGame() { this._gameStarted = true; } public void AddBall(Item item) { this._balls.TryAdd(item.Id, item); } public void RemoveBall(int itemID) { Item Item = null; this._balls.TryRemove(itemID, out Item); } public void OnUserWalk(RoomUser User) { if (User == null) return; foreach (Item item in this._balls.Values.ToList()) { int NewX = 0; int NewY = 0; int differenceX = User.X - item.GetX; int differenceY = User.Y - item.GetY; if (differenceX == 0 && differenceY == 0) { if (User.RotBody == 4) { NewX = User.X; NewY = User.Y + 2; } else if (User.RotBody == 6) { NewX = User.X - 2; NewY = User.Y; } else if (User.RotBody == 0) { NewX = User.X; NewY = User.Y - 2; } else if (User.RotBody == 2) { NewX = User.X + 2; NewY = User.Y; } else if (User.RotBody == 1) { NewX = User.X + 2; NewY = User.Y - 2; } else if (User.RotBody == 7) { NewX = User.X - 2; NewY = User.Y - 2; } else if (User.RotBody == 3) { NewX = User.X + 2; NewY = User.Y + 2; } else if (User.RotBody == 5) { NewX = User.X - 2; NewY = User.Y + 2; } if (!this._room.GetRoomItemHandler().CheckPosItem(User.GetClient(), item, NewX, NewY, item.Rotation, false, false)) { if (User.RotBody == 0) { NewX = User.X; NewY = User.Y + 1; } else if (User.RotBody == 2) { NewX = User.X - 1; NewY = User.Y; } else if (User.RotBody == 4) { NewX = User.X; NewY = User.Y - 1; } else if (User.RotBody == 6) { NewX = User.X + 1; NewY = User.Y; } else if (User.RotBody == 5) { NewX = User.X + 1; NewY = User.Y - 1; } else if (User.RotBody == 3) { NewX = User.X - 1; NewY = User.Y - 1; } else if (User.RotBody == 7) { NewX = User.X + 1; NewY = User.Y + 1; } else if (User.RotBody == 1) { NewX = User.X - 1; NewY = User.Y + 1; } } } else if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1 && VerifyBall(User, item.Coordinate.X, item.Coordinate.Y))//VERYFIC BALL CHECAR SI ESTA EN DIRECCION ASIA LA PELOTA { NewX = differenceX * -1; NewY = differenceY * -1; NewX = NewX + item.GetX; NewY = NewY + item.GetY; } if (item.GetRoom().GetGameMap().ValidTile(NewX, NewY)) { MoveBall(item, NewX, NewY, User); } } } private bool VerifyBall(RoomUser user, int actualx, int actualy) { return Rotation.Calculate(user.X, user.Y, actualx, actualy) == user.RotBody; } public void RegisterGate(Item item) { if (gates[0] == null) { item.team = TEAM.BLUE; gates[0] = item; } else if (gates[1] == null) { item.team = TEAM.RED; gates[1] = item; } else if (gates[2] == null) { item.team = TEAM.GREEN; gates[2] = item; } else if (gates[3] == null) { item.team = TEAM.YELLOW; gates[3] = item; } } public void UnRegisterGate(Item item) { switch (item.team) { case TEAM.BLUE: { gates[0] = null; break; } case TEAM.RED: { gates[1] = null; break; } case TEAM.GREEN: { gates[2] = null; break; } case TEAM.YELLOW: { gates[3] = null; break; } } } public void onGateRemove(Item item) { switch (item.GetBaseItem().InteractionType) { case InteractionType.FOOTBALL_GOAL_RED: case InteractionType.footballcounterred: { _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.RED); break; } case InteractionType.FOOTBALL_GOAL_GREEN: case InteractionType.footballcountergreen: { _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.GREEN); break; } case InteractionType.FOOTBALL_GOAL_BLUE: case InteractionType.footballcounterblue: { _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.BLUE); break; } case InteractionType.FOOTBALL_GOAL_YELLOW: case InteractionType.footballcounteryellow: { _room.GetGameManager().RemoveFurnitureFromTeam(item, TEAM.YELLOW); break; } } } public void MoveBall(Item item, int newX, int newY, RoomUser user) { if (item == null || user == null) return; if (!_room.GetGameMap().itemCanBePlacedHere(newX, newY)) return; Point oldRoomCoord = item.Coordinate; if (oldRoomCoord.X == newX && oldRoomCoord.Y == newY) return; double NewZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; _room.SendPacket(new SlideObjectBundleComposer(item.Coordinate.X, item.Coordinate.Y, item.GetZ, newX, newY, NewZ, item.Id, item.Id, item.Id)); item.ExtraData = "11"; item.UpdateNeeded = true; _room.GetRoomItemHandler().SetFloorItem(null, item, newX, newY, item.Rotation, false, false, false, false); this._room.OnUserShoot(user, item); } public void Dispose() { Array.Clear(gates, 0, gates.Length); gates = null; _room = null; _balls.Clear(); _balls = null; } } }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Football Bug
Top