public void interactWithDice(int itemID, uint sessionID, bool spinDice) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isDice) // Valid item { roomUser pUser = this.getRoomUser(sessionID); if (pUser == null || !tilesTouch(pItem.X, pItem.Y, pUser.X, pUser.Y)) return; // Invalid position of room user and dice item pUser = null; serverMessage Message = new serverMessage(90); // "AZ" Message.Append(itemID); itemID *= 38; int randomNumber = 0; if (spinDice) // New spin { this.sendMessage(Message); // Start spin animation for clients // Generate random number randomNumber = new Random(DateTime.Now.Millisecond).Next(1, 7); // 1-6 itemID += randomNumber; } Message.Append(" " + itemID.ToString()); // Append 'new' item ID if (spinDice) // New spin, send delayed message this.sendMessage(Message.ToString(), 1000); else // Send message immediately this.sendMessage(Message); pItem.customData = randomNumber.ToString(); // Set custom data pItem.requiresUpdate = true; // Request update of dice customdata } }
/// <summary> /// 66 - "AB" /// </summary> public void FLATPROPBYITEM() { if (Session.roomInstance.sessionHasRights(Session.ID)) // Permission { int itemID = int.Parse(Request.Content.Split('/')[1]); stripItem pItem = Session.itemStripHandler.getHandItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isDecoration) { Session.itemStripHandler.removeHandItem(itemID, true); int decorationValue = int.Parse(pItem.customData); if (pItem.Definition.Sprite == "wallpaper") { Session.roomInstance.Information.Wallpaper = decorationValue; } else // Floor { Session.roomInstance.Information.Floor = decorationValue; } serverMessage msgUpdate = new serverMessage(46); // "@n" msgUpdate.Append(pItem.Definition.Sprite); msgUpdate.Append("/"); msgUpdate.Append(decorationValue); Session.roomInstance.sendMessage(msgUpdate); Session.roomInstance.Information.updateFlatProperties(); } } }
/// <summary> /// Accepts a buddy request and notifies the sender (if online) and the receiver. /// </summary> /// <param name="Session">The Woodpecker.Sessions.Session object of the user that accepts the request.</param> /// <param name="senderID">The database ID of the user that sent the request.</param> public void acceptBuddyRequest(ref Session Session, int senderID) { Database Database = new Database(false, false); Database.addParameterWithValue("userid", Session.User.ID); Database.addParameterWithValue("senderid", senderID); Database.Open(); if (Database.findsResult("SELECT userid FROM messenger_buddylist WHERE userid = @senderid AND buddyid = @userid AND accepted = '0' LIMIT 1")) { Database.runQuery("UPDATE messenger_buddylist SET accepted = '1' WHERE userid = @senderid AND buddyid = @userid LIMIT 1"); Database.Close(); serverMessage Message = new serverMessage(); if (ObjectTree.Game.Users.userIsLoggedIn(senderID)) // Sender is online! { Message.Initialize(137); // "BI" Message.Append(getBuddy(Session.User.ID).ToString()); ObjectTree.Game.Users.trySendGameMessage(senderID, Message); } Message.Initialize(137); // "BI" Message.Append(getBuddy(senderID).ToString()); Session.gameConnection.sendMessage(Message); } else { Database.Close(); } }
/// <summary> /// Refreshes the session user's credit amount. (message 6: @F) /// </summary> public void refreshCredits() { if (this.isHoldingUser) { serverMessage Message = new serverMessage(6); // "@F" Message.Append(this.User.Credits); Message.Append(".0"); this.gameConnection.sendMessage(Message); } }
/// <summary> /// Modifies the hand page index with a given mode and sends the current hand page of this user. /// </summary> /// <param name="szMode">'How-to' modify the hand page index.</param> public void sendHandStrip(string szMode) { if (this.itemStripHandler != null) { this.itemStripHandler.changeHandStripPage(szMode); // Switch! serverMessage Message = new serverMessage(140); // "BL" Message.Append(this.itemStripHandler.getHandItemCasts()); Message.appendChar(13); Message.Append(this.itemStripHandler.handItemCount); this.gameConnection.sendMessage(Message); } }
/// <summary> /// 86 - "AV" /// </summary> public void CRYFORHELP() { string[] args = Request.getMixedParameters(); Database Database = new Database(false, false); Database.addParameterWithValue("userid", Session.User.ID); Database.addParameterWithValue("senderip", Session.ipAddress); Database.addParameterWithValue("msg", args[0]); Database.addParameterWithValue("roomid", Session.roomID); Database.addParameterWithValue("ip", Session.ipAddress); Database.addParameterWithValue("sended", DateTime.Now.ToString()); Database.Open(); string row = ""; string room = ""; if (Database.Ready) { Database.runQuery("INSERT INTO callforhelp (id, sended, uid, rid, date, message, send_ip, pickedup, pickedup_person, pickedup_ip, pickedup_date) VALUES ('', @sended, @userid, @roomid, @msg, '" + DateTime.Now.ToString() + "', @senderip, '0', '', '', '')"); row = Database.getString("SELECT id FROM `callforhelp` ORDER BY `callforhelp`.`id` DESC LIMIT 1"); room = Database.getString("SELECT roomname FROM `rooms` WHERE `id` = '" + Session.roomID + "' LIMIT 1"); Database.Close(); } ArrayList list = Engine.Game.Users.UserFuses("fuse_receive_calls_for_help"); foreach (int x in list) { Session S = Engine.Game.Users.getUserSession(x); if (S == null) { return; } serverMessage Message = new serverMessage(); Message.Initialize(148); Message.Append(row); Message.appendChar(2); Message.Append("ISent: "); Message.Append(DateTime.Now.ToString()); Message.appendChar(2); Message.Append(Session.User.Username); Message.appendChar(2); Message.Append(args[0]); Message.appendChar(2); Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID)); Message.appendChar(2); Message.Append("Room: " + room); Message.appendChar(2); Message.Append("I"); Message.appendChar(2); Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID)); S.gameConnection.sendMessage(Message); } }
/// <summary> /// Broadcoasts the removal of a wall item to all room users. /// </summary> /// <param name="itemID">The database ID of the wall item that is removed.</param> private void broadcoastWallItemRemoval(int itemID) { serverMessage Message = new serverMessage(84); // "AT" Message.Append(itemID); this.sendMessage(Message); }
/// <summary> /// Gets the transactions (credit log) of a user on given user session and sends it to the session's game connection. /// </summary> /// <param name="Session">The Woodpecker.Sessions.Session object to get the transaction for and to send the message to.</param> public void sendTransactions(ref Session Session) { if (Session.User == null) { return; } serverMessage Message = new serverMessage(209); // "CQ" Database Database = new Database(false, true); Database.addParameterWithValue("userid", Session.User.ID); Database.Open(); if (Database.Ready) { DataTable creditLogData = Database.getTable("SELECT moment,type,activity FROM users_creditlog WHERE userid = @userid LIMIT 50"); foreach (DataRow dRow in creditLogData.Rows) { DateTime Moment = (DateTime)dRow["moment"]; Message.appendTabbedValue(Moment.ToString("dd/MM/yyyy")); Message.appendTabbedValue(Moment.ToString("hh:mm")); Message.appendTabbedValue(dRow["activity"].ToString()); Message.appendTabbedValue("0"); Message.appendTabbedValue(""); Message.Append(dRow["type"].ToString()); Message.appendChar(13); } } Session.gameConnection.sendMessage(Message); }
/// <summary> /// Broadcoasts the removal of a floor item to all room users. /// </summary> /// <param name="itemID">The database ID of the floor item that is removed.</param> private void broadcoastFloorItemRemoval(int itemID) { serverMessage Message = new serverMessage(94); // "A^" Message.Append(itemID); this.sendMessage(Message); }
/// <summary> /// 105 - "Ai" /// </summary> public void BUY_TICKETS() { int bundleID = Request.getNextWiredParameter(); int ticketsPurchased = (bundleID == 1) ? 2 : 20; Users.userInformation recipient = Engine.Game.Users.getUserInfo(Request.Content.Substring(3), true); if (recipient != null) { Sessions.Session session = Engine.Game.Users.getUserSession(recipient.ID); if (session != null) { session.User.Tickets += ticketsPurchased; session.refreshTickets(); if (session != this.Session) { serverMessage alert = new serverMessage(139); // "BK" alert.Append($"{this.Session.User.Username} has sent you {ticketsPurchased} tickets."); session.gameConnection.sendMessage(alert); } else { Response.Initialize(139); // "BK" Response.Append("Tickets purchased."); sendResponse(); } } else { recipient.Tickets += ticketsPurchased; recipient.updateValueables(); } } }
/// <summary> /// Broadcoasts the state update of a given wall item to all active room users. /// </summary> /// <param name="pItem">The wallItem instance of the wall item that is updated.</param> private void broadcoastWallItemStateUpdate(wallItem pItem) { serverMessage Message = new serverMessage(85); // "AU" Message.Append(pItem.ToString()); this.sendMessage(Message); }
public void broadcoastHeightmap() { serverMessage Message = new serverMessage(31); // "@_" Message.Append(this.getClientFloorMap()); this.sendMessage(Message); }
/// <summary> /// Broacoasts the placement of a wall item to all room users. /// </summary> /// <param name="pItem">The wallItem instance of the wall item that is placed.</param> private void broadcoastWallItemPlacement(wallItem pItem) { serverMessage Message = new serverMessage(83); // "AS" Message.Append(pItem.ToString()); this.sendMessage(Message); }
/// <summary> /// Sends the key of an error, whose description value is inside the external_texts of the client. /// </summary> /// <param name="localizedKey">The external_texts key of the error description.</param> public void sendLocalizedError(string localizedKey) { serverMessage Message = new serverMessage(33); // "@a" Message.Append(localizedKey); this.sendMessage(Message); }
/// <summary> /// 199 - "CG" /// </summary> public void MESSAGETOCALLER() { string[] args = Request.getMixedParameters(); if (Session.User.hasFuseRight("fuse_receive_calls_for_help")) { Database Database = new Database(false, false); Database.addParameterWithValue("id", args[0]); Database.addParameterWithValue("msg", args[1]); Database.Open(); if (Database.Ready) { DataRow dRow = Database.getRow("SELECT * FROM callforhelp WHERE id = @id"); if (dRow != null) { Session S = Engine.Game.Users.getUserSession(Convert.ToInt32(dRow["uid"])); if (S == null) { return; } serverMessage Message = new serverMessage(); Message.Initialize(274); Message.Append(args[1]); Message.appendChar(2); S.gameConnection.sendMessage(Message); Database.runQuery("INSERT INTO callforhelp_msg VALUES ('', @id, @msg, '" + Session.User.ID + "', '" + Session.ipAddress + "', '" + DateTime.Now.ToString() + "')"); } } } }
/// <summary> /// Makes a room unit (so a room user, a pet, or a bot) visible to all users in the room. /// </summary> /// <param name="szDetails"></param> private void castRoomUnit(string szDetails) { serverMessage Cast = new serverMessage(28); // "@\" Cast.Append(szDetails); this.sendMessage(Cast); }
public bool requestRoomAlert(int userID, int roomID, string Message, string extraInfo) { if (ObjectTree.Game.Rooms.roomInstanceRunning(roomID)) { serverMessage Alert = new serverMessage(33); // "@a" Alert.Append("mod_warn/"); Alert.Append(Message); ObjectTree.Game.Rooms.getRoomInstance(roomID).sendMessage(Alert); logModerationAction(userID, "roomalert", roomID, Message, extraInfo); return(true); } return(false); }
/// <summary> /// Sends the available figure parts for this session user. /// </summary> public void refreshFigureParts() { serverMessage Message = new serverMessage(8); // "@H" Message.Append("["); if (this.isHoldingUser && this.User.hasClub) // Can use 'Club' parts { Message.Append(Configuration.getConfigurationValue("users.figure.parts.club")); } else { Message.Append(Configuration.getConfigurationValue("users.figure.parts.default")); } Message.Append("]"); this.gameConnection.sendMessage(Message); }
/// <summary> /// Notifies all room users that a given room unit has left the room and releases the map spot for the room user. /// </summary> /// <param name="roomUnitID">The room unit ID of the room unit that has left the room.</param> /// <param name="mapX">The current X position of the room unit on the map.</param> /// <param name="mapY">The current Y position of the room unit on the map.</param> private void releaseRoomUnit(int roomUnitID, byte mapX, byte mapY) { serverMessage Message = new serverMessage(29); // "@]" Message.Append(roomUnitID); this.sendMessage(Message); this.gridUnit[mapX, mapY] = false; }
/// <summary> /// Refreshes the session user's game ticket amount. (message 124: A|) /// </summary> public void refreshTickets() { if (this.isHoldingUser) { serverMessage Message = new serverMessage(124); // "A|" Message.Append(this.User.Credits); this.gameConnection.sendMessage(Message); } }
/// <summary> /// Retrieves the FUSE rights for the user on this session and sends it to the client. /// </summary> public void refreshFuseRights() { if (this.isHoldingUser) { serverMessage Message = new serverMessage(2); // "@B" Message.Append(Engine.Game.Roles.getRightsForRole(this.User.Role, this.User.hasClub)); this.gameConnection.sendMessage(Message); } }
public void broadcoastTeleportActivity(int itemID, string Username, bool disappearUser) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isTeleporter) { serverMessage Message = new serverMessage(); if (disappearUser) Message.Initialize(89); // "AY" else Message.Initialize(92); // "A\" Message.Append(pItem.ID); Message.Append("/"); Message.Append(Username); Message.Append("/"); Message.Append(pItem.Definition.Sprite); this.sendMessage(Message); } }
/// <summary> /// Refreshes the session user's film amount for the camera. (message 4: @D) /// </summary> public void refreshFilm() { if (this.isHoldingUser) { serverMessage Message = new serverMessage(4); // "@D" Message.Append(this.User.Film); this.gameConnection.sendMessage(Message); } }
public void interactWithDice(int itemID, uint sessionID, bool spinDice) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isDice) // Valid item { roomUser pUser = this.getRoomUser(sessionID); if (pUser == null || !tilesTouch(pItem.X, pItem.Y, pUser.X, pUser.Y)) { return; // Invalid position of room user and dice item } pUser = null; serverMessage Message = new serverMessage(90); // "AZ" Message.Append(itemID); itemID *= 38; int randomNumber = 0; if (spinDice) // New spin { this.sendMessage(Message); // Start spin animation for clients // Generate random number randomNumber = new Random(DateTime.Now.Millisecond).Next(1, 7); // 1-6 itemID += randomNumber; } Message.Append(" " + itemID.ToString()); // Append 'new' item ID if (spinDice) // New spin, send delayed message { this.sendMessage(Message.ToString(), 1000); } else // Send message immediately { this.sendMessage(Message); } pItem.customData = randomNumber.ToString(); // Set custom data pItem.requiresUpdate = true; // Request update of dice customdata } }
/// <summary> /// Refreshes the session user's game ticket amount. (message 124: A|) /// </summary> public void refreshTickets() { if (this.isHoldingUser) { this.User.updateValueables(); serverMessage Message = new serverMessage(124); // "A|" Message.Append(this.User.Tickets); this.gameConnection.sendMessage(Message); } }
/// <summary> /// Refresh the trade boxes for this session's user and his/her trade partner's session user. Only works when both users are trading. /// </summary> public void refreshTradeBoxes() { if (this.itemStripHandler.isTrading) { Session partnerSession = Engine.Sessions.getSession(this.itemStripHandler.tradePartnerSessionID); if (partnerSession == null || !partnerSession.itemStripHandler.isTrading) { return; } string myBox = itemStripHandler.generateTradeBox(this); string partnerBox = itemStripHandler.generateTradeBox(partnerSession); serverMessage Message = new serverMessage(108); // "Al" Message.Append(myBox); Message.Append(partnerBox); this.gameConnection.sendMessage(Message); Message.Initialize(108); // "Al" Message.Append(partnerBox); Message.Append(myBox); partnerSession.gameConnection.sendMessage(Message); } }
public void broadcoastTeleportActivity(int itemID, string Username, bool disappearUser) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isTeleporter) { serverMessage Message = new serverMessage(); if (disappearUser) { Message.Initialize(89); // "AY" } else { Message.Initialize(92); // "A\" } Message.Append(pItem.ID); Message.Append("/"); Message.Append(Username); Message.Append("/"); Message.Append(pItem.Definition.Sprite); this.sendMessage(Message); } }
/// <summary> /// Broacoasts the placement of a floor item to all room users. /// </summary> /// <param name="pItem">The floorItem instance of the wall item that is placed.</param> /// <param name="isPlacement">True if this item is new in the room, false otherwise.</param> private void broadcoastFloorItemMove(floorItem pItem, bool isPlacement) { serverMessage Message = new serverMessage(); if (isPlacement) { Message.Initialize(93); // "A]" } else { Message.Initialize(95); // "A_" } Message.Append(pItem.ToString()); this.sendMessage(Message); }
/// <summary> /// Tries to redeem a credit/item voucher for a user session. /// </summary> /// <param name="Session">The Woodpecker.Sessions.Session object to redeem the voucher with.</param> /// <param name="Code">The vouchercode the user entered.</param> public void redeemVoucher(ref Session Session, string Code) { serverMessage Response = new serverMessage(); Database Database = new Database(false, false); Database.addParameterWithValue("code", Code); Database.Open(); if (Database.Ready) { DataRow dRow = Database.getRow("SELECT type,value FROM users_vouchers WHERE code = @code AND ISNULL(redeemer_userid)"); if (dRow != null) // Voucher found { // Mark voucher as redeemed Database.addParameterWithValue("userid", Session.User.ID); Database.runQuery("UPDATE users_vouchers SET redeemer_userid = @userid WHERE code = @code"); Database.Close(); string Type = (string)dRow["type"]; if (Type == "credits") { int Credits = int.Parse(dRow["value"].ToString()); Session.User.Credits += Credits; Session.User.updateValueables(); this.logTransaction(Session.User.ID, "win_voucher", Credits); Session.refreshCredits(); } else if (Type == "item") { string[] Items = ((string)dRow["value"]).Split(';'); } // Success! Response.Initialize(212); // "CT" Session.gameConnection.sendMessage(Response); return; } else { // Error 1! (not found) Response.Initialize(213); // "CU" Response.Append(1); } Session.gameConnection.sendMessage(Response); } }
private void _launchBird(int[] receiverIDs, messengerMessage pMessage) { Database Database = new Database(false, false); Database.addParameterWithValue("senderid", pMessage.senderID); Database.addParameterWithValue("sent", pMessage.Sent); Database.addParameterWithValue("body", pMessage.Body); Database.Open(); if (Database.Ready) { //DateTime now = DateTime.Now; //Woodpecker.Core.Logging.Log("Start: " + now.ToString("hh:mm:ss:fff")); foreach (int receiverID in receiverIDs) { if (Engine.Game.Users.userIsLoggedIn(receiverID)) // Receiver is logged in, retrieve the next message ID, write the message in the database & send it to the receiver { int messageID = Database.getInteger("SELECT MAX(messageid) + 1 FROM messenger_messages WHERE receiverid = '" + receiverID + "' LIMIT 1"); Database.runQuery("INSERT INTO messenger_messages(receiverid,messageid,senderid,sent,body) VALUES ('" + receiverID + "','" + messageID + "',@senderid,@sent,@body)"); serverMessage Message = new serverMessage(134); // "BF" Message.appendWired(1); pMessage.ID = messageID; Message.Append(pMessage.ToString()); Engine.Game.Users.trySendGameMessage(receiverID, Message); } else // Receiver is not online, no need for getting our hands on the next message ID etc { Database.runQuery( "INSERT INTO messenger_messages(receiverid,messageid,senderid,sent,body) " + "SELECT " + "'" + receiverID + "'," + "(MAX(messageid) + 1)," + "@senderid," + "@sent," + "@body " + "FROM messenger_messages WHERE receiverid = '" + receiverID + "' LIMIT 1"); } } //now = DateTime.Now; //Woodpecker.Core.Logging.Log("Stop: " + now.ToString("hh:mm:ss:fff")); Database.Close(); } }
/// <summary> /// Broadcoasts the message that a user is waiting for a doorbell response. This message is only broadcoasted to users who have room rights, and True is returned if at least one room user with room rights has received it. /// </summary> /// <param name="Username">The username of the user.</param> public bool castDoorbellUser(string Username) { bool isHeard = false; serverMessage Notify = new serverMessage(91); // "A[" Notify.Append(Username); lock (roomUsers) { foreach (roomUser lRoomUser in roomUsers.Values) { if (lRoomUser.hasRights) { lRoomUser.Session.gameConnection.sendMessage(Notify); isHeard = true; } } } return(isHeard); }
public static serverMessage CreateVoiceSpeakMessage(string text) { // 'Speaker' floorItem pItem = new floorItem(); pItem.ID = int.MaxValue; pItem.Rotation = 0; pItem.X = 255; pItem.Y = 255; pItem.Z = -1f; pItem.customData = "voiceSpeak(\"" + text + "\")"; pItem.Definition = new itemDefinition(); pItem.Definition.Sprite = "spotlight"; pItem.Definition.Length = 1; pItem.Definition.Width = 1; serverMessage msg = new serverMessage(93); // "A]" msg.Append(pItem.ToString()); return(msg); }
/// <summary> /// Broacoasts the placement of a wall item to all room users. /// </summary> /// <param name="pItem">The wallItem instance of the wall item that is placed.</param> private void broadcoastWallItemPlacement(wallItem pItem) { serverMessage Message = new serverMessage(83); // "AS" Message.Append(pItem.ToString()); this.sendMessage(Message); }
/// <summary> /// Broadcoasts the state update of a given wall item to all active room users. /// </summary> /// <param name="pItem">The wallItem instance of the wall item that is updated.</param> private void broadcoastWallItemStateUpdate(wallItem pItem) { serverMessage Message = new serverMessage(85); // "AU" Message.Append(pItem.ToString()); this.sendMessage(Message); }
public void broadcoastHeightmap() { serverMessage Message = new serverMessage(31); // "@_" Message.Append(this.getClientFloorMap()); this.sendMessage(Message); }
/// <summary> /// Broacoasts the placement of a floor item to all room users. /// </summary> /// <param name="pItem">The floorItem instance of the wall item that is placed.</param> /// <param name="isPlacement">True if this item is new in the room, false otherwise.</param> private void broadcoastFloorItemMove(floorItem pItem, bool isPlacement) { serverMessage Message = new serverMessage(); if (isPlacement) Message.Initialize(93); // "A]" else Message.Initialize(95); // "A_" Message.Append(pItem.ToString()); this.sendMessage(Message); }
/// <summary> /// Broadcoasts the removal of a floor item to all room users. /// </summary> /// <param name="itemID">The database ID of the floor item that is removed.</param> private void broadcoastFloorItemRemoval(int itemID) { serverMessage Message = new serverMessage(94); // "A^" Message.Append(itemID); this.sendMessage(Message); }
/// <summary> /// Broadcoasts the removal of a wall item to all room users. /// </summary> /// <param name="itemID">The database ID of the wall item that is removed.</param> private void broadcoastWallItemRemoval(int itemID) { serverMessage Message = new serverMessage(84); // "AT" Message.Append(itemID); this.sendMessage(Message); }