You can usethat's only if you have your own private string, void, etc.. it won't stop the server.PHP Code:Thread.Sleep(500);
Printable View
Hey Yifanlu I used your Onewaycode but there is one bug,
If I place the onewaygate for a obstacle (example a teleport) and when I click on the onewaydoor, the client crash :S (see Picture)
http://img5.imagebanana.com/img/80q3nvun/onewaybug.png
Someone knows how to fix?
Thanks, Mark
It needs checking to see whether the next path is full or not. I would do it but no time.
Can you do it another time? tromsplit?
- Mark
Get me name right and maybe.
Oops, Sorry TomSpit
I hope you want do it for me ,
Thanks , Mark
thx work 100% one way doors v26 server xD respeckt :D::D:
-----------------------------------------------------------
help me the friends console no work
1.offline 0% work v26
2.search 0% work v26
help me pleace
Ok, fixed my code, but this was written in a few minutes, so it's not that great.
(Also, the bool Room.squareBlocked() only returns if there's a user/bot/pet on the square, it ignores other furni, that's why I didn't use it)
Edit virtualRoom.cs (around line 68), you should see:
Replace it with:Code:private squareState[,] sqSTATE;
Now, go down to ~line 2453 and REMOVE this block of codeCode:public squareState[,] sqSTATE;
(this may screw up something else in the code, but after playing in the hotel for an hour, I didn't see any side effects, but if you find one, please report it)Code:internal bool sqSTATE(int p, int p_2)
{
throw new NotImplementedException();
}
Now go to virtualUser.cs and replace the one-way-door code with this new version:
Now it works like Habbo, if the square is blocked, you're left inside the one-way-gate.Code:case "Ch": // Ch + ONE-WAY-DOOR-FURNI-ID (answer: Dx + WIRE(FURNI-ID) + I + WIRE(ROOM-UID-OF-CLICKER)) (sprite: 'one_way_door*#)
{
if (Room == null || roomUser == null || _inPublicroom)
return;
int itemID = Encoding.decodeVL64(currentPacket.Substring(2));
Rooms.Items.floorItem Item = Room.floorItemManager.getItem(itemID); // Find the item.
try
{
if (Room.floorItemManager.containsItem(itemID) && stringManager.getStringPart(Item.Sprite, 0, 12) == "one_way_door")
{
Room.sendData("Dx" + Encoding.encodeVL64(itemID) + "I" + Encoding.encodeVL64(Room.roomID)); // Opens the gate, with green light
Room.setSquareState(Item.X, Item.Y, 1, 1, virtualRoom.squareState.Open);
roomUser.walkLock = true;
switch (Item.Z) // Walk into the item
{
case 0: roomUser.goalY = Room.sqSTATE[Item.X, Item.Y + 1] == virtualRoom.squareState.Blocked ? Item.Y : Item.Y + 1; roomUser.goalX = Item.X; break;
case 2: roomUser.goalX = Room.sqSTATE[Item.X - 1, Item.Y] == virtualRoom.squareState.Blocked ? Item.X : Item.X - 1; roomUser.goalY = Item.Y; break;
case 4: roomUser.goalY = Room.sqSTATE[Item.X, Item.Y - 1] == virtualRoom.squareState.Blocked ? Item.Y : Item.Y - 1; roomUser.goalX = Item.X; break;
case 6: roomUser.goalX = Room.sqSTATE[Item.X + 1, Item.Y] == virtualRoom.squareState.Blocked ? Item.X : Item.X + 1; roomUser.goalY = Item.Y; break;
}
roomUser.walkLock = false;
while (true)
if (roomUser.statusManager.containsStatus("mv"))
break;
Room.sendData("Dx" + Encoding.encodeVL64(itemID) + "H" + Encoding.encodeVL64(Room.roomID), 1000);
Room.setSquareState(Item.X, Item.Y, 1, 1, virtualRoom.squareState.Blocked);
break;
}
}
catch {}
break;
}
Cant find
internal bool sqSTATE(int p, int p_2)
{
throw new NotImplementedException();
}
I use dissis TDBP
I have not delete this now, is that a big problem?
- Mark
Only this :
public squareState[,] sqSTATE;
/// <summary>
/// The rotation of the item on a certain coord on the room map.
/// </summary>
Is what I find
- Mark
Dude! This will make your server lagg when you go trough the door!
If you use the Thread.Sleep(int timeout); metoh, you'll "pause" the user including some other classes. To avoid this, use magicTiles, or add the function in the cycleStatus. The best way (I think) is to add a bool in the virtualUser that is set to true when a user enters a onewaydoor. Then in the cycle, add a if-statement that checks wether the bool we added in virtualUser is set to true or false. Then, walk trough the door using TomSpits code posted some posts before this. And remember to set it to false aggain so it doesent fuckup ;)Code:case "Ch": // Ch + ONE-WAY-DOOR-FURNI-ID (answer: Dx + WIRE(FURNI-ID) + I + WIRE(ROOM-UID-OF-CLICKER)) (sprite: 'one_way_door*#)
{
try
{
int itemID = Encoding.decodeVL64(currentPacket.Substring(2));
if (Room.floorItemManager.containsItem(itemID))
{
Rooms.Items.floorItem Item = Room.floorItemManager.getItem(itemID); // Find the itemID.
if (Item.Sprite == "one_way_door*1")
{
Room.sendData("Dx" + Encoding.encodeVL64(itemID) + "I" + Encoding.encodeVL64(Room.roomID)); // Opens the gate, with green light
Room.moveUser(this.roomUser, Item.X, Item.Y, true); // Walk into the item
Thread.Sleep(350);//<= LAGG!!!!
if (Item.Z == 0)
Room.moveUser(this.roomUser, roomUser.X, roomUser.Y+1, true);
else if (Item.Z == 2)
Room.moveUser(this.roomUser, roomUser.X-1, roomUser.Y, true);
else if (Item.Z == 4)
Room.moveUser(this.roomUser, roomUser.X, roomUser.Y-1, true);
else if (Item.Z == 6)
Room.moveUser(this.roomUser, roomUser.X+1, roomUser.Y, true);
Thread.Sleep(350);// <= LAGG!!!!
Room.sendData("Dx" + Encoding.encodeVL64(itemID) + "H" + Encoding.encodeVL64(Room.roomID));
}
}
}
catch { }
break;
}
- Martin
Works the Habbo Rollers not at the same way?
Ummm this is probably ripped from OpenHotel's Server.I figured because its the exact same code.Anyways nice release I could be wrong but it isnt so terrible because it works.
It wasn't ripped atall. Also, how would I get my hands' on openhotel's server? They leaked a source but it didn't have one way doors in it. Fool.
Here, I nicked this from Phoenix Emu Source:
Needs a little editing, I will do when i cba.Code:case "Ch":
{
string[] strArray2 = DB.runReadRow("SELECT id,name,owner,description,state,visitors_now,visitors_max FROM rooms WHERE id = '" + this.Room.roomID + "'");
string[] strArray3 = DB.runReadRow("SELECT id,name,credits FROM users WHERE name = '" + strArray2[2] + "'");
int num3 = DB.runRead("SELECT credits FROM users WHERE name = '" + strArray3[1] + "'", null);
this.Room.sendData("Dx" + currentPacket.Substring(2) + "IH");
this.roomUser.goalX = -1;
str3 = "";
int x = this.roomUser.X;
int y = this.roomUser.Y;
if (x == (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1))
{
str3 = "X1";
}
if (x == (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1))
{
str3 = "X-1";
}
if (y == (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1))
{
str3 = "Y1";
}
if (y == (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1))
{
str3 = "Y-1";
}
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
Thread.Sleep(500);
if (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Sprite == "one_way_door*0")
{
switch (str3)
{
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
if (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Sprite == "one_way_door*1")
{
if (((this._Credits - 5) > -1) && !this._isOwner)
{
this._Credits -= 5;
num3 += 5;
this.sendData("@F" + this._Credits);
this.sendData("BKYou have been charged 5 credits for entry.");
DB.runQuery(string.Concat(new object[] { "UPDATE users SET credits = '", num3, "' WHERE id = '", strArray3[0], "'" }));
switch (str3)
{
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
else if (this._isOwner)
{
switch (str3)
{
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
else
{
this.sendData("BKYou cannot afford entry here.");
switch (str3)
{
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
}
}
}
if (this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Sprite == "one_way_door*2")
{
if (this._isRoomStaff)
{
switch (str3)
{
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
else if (this._isOwner)
{
switch (str3)
{
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
else
{
this.sendData("BKStaff Access Only.");
switch (str3)
{
case "X1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X + 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "X-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X - 1, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y, true);
break;
case "Y1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y + 1, true);
break;
case "Y-1":
this.Room.moveUser(this.roomUser, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).X, this.Room.floorItemManager.getItem(Encoding.decodeVL64(currentPacket.Substring(2))).Y - 1, true);
break;
}
}
}
Thread.Sleep(500);
this.Room.sendData("Dx" + currentPacket.Substring(2) + "HH");
}
}
Funny thing I never tried coding one way doors or any of that I always just messed with habbo to learn programming in general which is what I did. I also loved learning how to improve performance for server environment development. I don't know why but I like the 'behind the scenes code' as opposed to the UI. In any case this is at least a contribution towards the community, regardless of the true quality of the code behind the snippet. Thanks.
o.O
coming out of a tele with the gate in front of it the server crashes.