public static serverMessage createMessageBoxCast(string Text) { serverMessage retCast = new serverMessage(139); // "BK" retCast.Append(Text); return retCast; }
public static serverMessage createCastAction(string target, string action) { serverMessage retCast = new serverMessage(71); // "AG" retCast.Append($"{target} {action}"); return(retCast); }
public static serverMessage createBanCast(string banReason) { serverMessage retCast = new serverMessage(35); // "@c" retCast.Append(banReason); return retCast; }
/// <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(); }
public static serverMessage createDefaultMessageBox(string Text) { serverMessage retCast = new serverMessage(139); // "BK" retCast.Append(Text); return(retCast); }
/// <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(); } } }
public static serverMessage createBanCast(string banReason) { serverMessage retCast = new serverMessage(35); // "@c" retCast.Append(banReason); return(retCast); }
public void broadcastMessage(serverMessage Message) { string sMessage = Message.ToString(); lock (_userSessions) { foreach (Session lSession in _userSessions.Values) { lSession.gameConnection.sendMessage(sMessage); } } }
public void deliverItemsToSession(int userID, List<stripItem> Items, bool Refresh) { Session Receiver = ObjectTree.Game.Users.getUserSession(userID); if (Receiver != null) // Receiver was online { Receiver.itemStripHandler.addHandItems(Items); if (Refresh) { serverMessage Message = new serverMessage(101); // "Ae" Receiver.gameConnection.sendMessage(Message); } } }
public void requestSaleShipping(int receivingUserID, string saleCode, bool isNewPurchase, bool purchaseAsPresent, string presentNote, string customData) { storeCatalogueSale pSale = this.getSale(saleCode); if (pSale == null) { Logging.Log("Failed to purchase sale '" + saleCode + "' for user " + receivingUserID + ", the requested sale ('" + saleCode + "') was not found!", Logging.logType.commonWarning); return; } List<stripItem> shippedItems = new List<stripItem>(); if (purchaseAsPresent) { stripItem presentBox = this.createPresent(receivingUserID, saleCode, presentNote, customData); if (presentBox != null) shippedItems.Add(presentBox); else return; } else { int itemIdOffset = ObjectTree.Game.Items.getItemIdOffset(); foreach (stripItem lItem in pSale.getItemInstances()) { lItem.ID = ++itemIdOffset; lItem.ownerID = receivingUserID; #region Special events upon purchase if (lItem.Definition.Behaviour.isTeleporter) // Teleporter, create linking teleporter { stripItem Teleporter2 = new stripItem(); Teleporter2.ID = ++itemIdOffset; Teleporter2.ownerID = receivingUserID; Teleporter2.Definition = lItem.Definition; Teleporter2.teleporterID = lItem.ID; lItem.teleporterID = Teleporter2.ID; shippedItems.Add(Teleporter2); } else if (lItem.Definition.Behaviour.isPostIt) { lItem.customData = "20"; } else if (lItem.Definition.Behaviour.isDecoration || lItem.Definition.Behaviour.isPrizeTrophy) { lItem.customData = customData; } else if (lItem.Definition.Behaviour.isRedeemable) { int creditValue = 0; if (int.TryParse(lItem.Definition.Sprite.Split('_')[1], out creditValue)) lItem.customData = creditValue.ToString(); } else if (lItem.Definition.Sprite == "nest") { string[] petData = customData.Split(Convert.ToChar(2)); string Name = petData[0]; char Type = char.Parse(petData[1]); byte Race = byte.Parse(petData[2]); string Color = petData[3]; ObjectTree.Game.Items.createPet(lItem.ID, Name, Type, Race, Color); } #endregion shippedItems.Add(lItem); } ObjectTree.Game.Items.createItemInstances(shippedItems); } Session Receiver = ObjectTree.Game.Users.getUserSession(receivingUserID); if (Receiver != null) // Receiver was online { Receiver.itemStripHandler.addHandItems(shippedItems); serverMessage Notification = new serverMessage(); if (isNewPurchase) { Notification.Initialize(67); // "AC" } else #region Open as present box { stripItem displayItem = shippedItems[0]; Notification.Initialize(129); // "BA" Notification.appendNewLineValue(displayItem.Definition.Sprite); string displaySprite = displayItem.Definition.Sprite; //if (displayItem.Definition.isPartialSprite && displayItem.customData != null) // displaySprite += " " + displayItem.customData; Notification.appendNewLineValue(displaySprite); if (!displayItem.Definition.Behaviour.isWallItem) { Notification.appendStripValue(displayItem.Definition.Length.ToString()); Notification.appendStripValue(displayItem.Definition.Width.ToString()); Notification.appendStripValue(displayItem.Definition.Color); } } #endregion Receiver.gameConnection.sendMessage(Notification); } }
/// <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 = ObjectTree.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); } }
/// <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(ObjectTree.Game.Roles.getRightsForRole(this.User.Role, this.User.hasClub)); this.gameConnection.sendMessage(Message); } }
/// <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> /// Refreshes the session user's club status. /// </summary> public void refreshClubStatus() { if (this.isHoldingUser) { serverMessage Message = new serverMessage(7); // "@G" Message.appendClosedValue("club_habbo"); Message.appendWired(this.User.clubDaysLeft); Message.appendWired(this.User.clubMonthsExpired); Message.appendWired(this.User.clubMonthsLeft); Message.appendWired(true); // Hide/shows 'days left' label this.gameConnection.sendMessage(Message); } }
/// <summary> /// Sends a game message to a session. Tries to find the session for a given session ID. If the session is found and the session is ready, then the message is sent. /// </summary> /// <param name="sessionID">The ID of the session to send the message to.</param> /// <param name="Message">The Woodpecker.Net.Game.Messages.gameMessage to send.</param> public void sendGameMessage(uint sessionID, serverMessage Message) { if (this._Sessions.ContainsKey(sessionID)) { Session Session = this._Sessions[sessionID]; if (Session.isReady) Session.gameConnection.sendMessage(Message); } }
/// <summary> /// Sends the current serverMessage object as a response and resets the response object. /// </summary> public void sendResponse() { this.Session.gameConnection.sendMessage(this.Response); this.Response = new serverMessage(); }
/// <summary> /// Tries to send a game message (serverMessage object) to a user, catching & dumping any exceptions that occur. /// </summary> /// <param name="userID">The database ID of the user to send the message to.</param> /// <param name="Message">The message to send to the user as serverMessage object.</param> public void trySendGameMessage(int userID, serverMessage Message) { try { _userSessions[userID].gameConnection.sendMessage(Message); } catch { } }
/// <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> /// Only works if the session user is in a room. If so, then a whisper with a given message is sent to the user only. /// </summary> /// <param name="Message">The text message to whisper to the user.</param> public void castWhisper(string sMessage) { if (this.inRoom) { serverMessage Message = new serverMessage(25); // "@Y" Message.appendWired(this.roomInstance.getSessionRoomUnitID(this.ID)); Message.appendClosedValue(sMessage); this.gameConnection.sendMessage(Message); } }
/// <summary> /// Refreshes the badges for this session user and re-builds the badges message. (229, "Ce") /// </summary> public void refreshBadgeList() { if (this.isHoldingUser) { List<string> myBadges = ObjectTree.Game.Roles.getDefaultBadgesForRole(this.User.Role); myBadges.Remove("HC1"); ObjectTree.Game.Users.addPrivateBadgesToList(this.User.ID, this.User.Role, ref myBadges); if (this.User.hasClub) // Regular club member myBadges.Add("HC1"); // TODO: make this configurable if (this.User.hasGoldClub) // Gold club member myBadges.Add("HC2"); // TODO: make this configurable if (!myBadges.Contains(this.User.Badge)) // Set badge not valid anymore this.User.Badge = ""; serverMessage Message = new serverMessage(229); // "Ce" Message.appendWired(myBadges.Count); int badgeSlot = 0; int slotCounter = 0; foreach (string lBadge in myBadges) { Message.appendClosedValue(lBadge); if (lBadge == this.User.Badge) // Current badge, set slot badgeSlot = slotCounter; slotCounter++; } Message.appendWired(badgeSlot); Message.appendWired((this.User.Badge.Length > 0)); this.gameConnection.sendMessage(Message); } }
private void refreshRoomUnitStatuses() { bool isUpdated = false; serverMessage Updates = new serverMessage(34); // "@b" if (hasPets) { lock (this.roomPets) { foreach (roomPet lPet in this.roomPets) { if (!lPet.requiresUpdate) continue; lPet.requiresUpdate = false; if (lPet.Moves) this.moveRoomUnit(lPet); Updates.Append(lPet.ToStatusString()); isUpdated = true; if (lPet.nextX != 0 && lPet.nextY != 0) { lPet.X = lPet.nextX; lPet.Y = lPet.nextY; lPet.Z = lPet.nextZ; } } } } lock (this.roomUsers) { foreach (roomUser lUser in this.roomUsers.Values) { if (!lUser.requiresUpdate) continue; lUser.requiresUpdate = false; if (lUser.Moves) this.moveRoomUnit(lUser); Updates.Append(lUser.ToStatusString()); isUpdated = true; if(lUser.nextX != 0 && lUser.nextY != 0) { lUser.X = lUser.nextX; lUser.Y = lUser.nextY; lUser.Z = lUser.nextZ; } } } if (isUpdated) this.sendMessage(Updates); }
/// <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> /// 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> /// 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); } }
/// <summary> /// Sends a single message in a serverMessage object to the client. /// </summary> /// <param name="Message">The serverMessage object representing the message.</param> public void sendMessage(serverMessage Message) { Logging.Log("Session " + this.Session.ID + ">> " + Message, Logging.logType.serverMessageEvent); this.sendMessage(Message.ToString()); }
/// <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); } }
private void runRollers() { if (mRollerTimer > DateTime.Now.TimeOfDay.TotalSeconds && mRollerDay == DateTime.Today.DayOfYear) return; StringBuilder Updates = new StringBuilder(); List<int> movedRoomUnitIDs = new List<int>(); List<int> movedItemIDs = new List<int>(); try { foreach (floorItem lRoller in this.floorItems) { if (!lRoller.Definition.Behaviour.isRoller) continue; // Not a roller item #region General // Workout direction for roller byte nextX = lRoller.X; byte nextY = lRoller.Y; if (lRoller.Rotation == 0) nextY--; else if (lRoller.Rotation == 2) nextX++; else if (lRoller.Rotation == 4) nextY++; else if (lRoller.Rotation == 6) nextX--; if (!tileExists(nextX, nextY) || tileBlockedByRoomUnit(nextX, nextY)) continue; // Can't roll off room map / on room unit #endregion #region Get objects on current tile and verify roomUnit pUnit = this.getRoomUnitOnTile(lRoller.X, lRoller.Y); // Get room unit on this roller List<floorItem> pItems = new List<floorItem>(); foreach (floorItem lItem in this.getFloorItems(lRoller.X, lRoller.Y)) { if (!lItem.Definition.Behaviour.isRoller && !movedItemIDs.Contains(lItem.ID)) pItems.Add(lItem); } if (pUnit != null && (pUnit.Moves || movedRoomUnitIDs.Contains(pUnit.ID))) { pUnit = null; // Invalid room unit } if (pUnit == null && pItems.Count == 0) continue; // No items on roller and no room unit aswell #endregion // Get items on next tile and perform some checks bool nextTileIsRoller = false; bool canMoveItems = (this.gridState[nextX, nextY] == roomTileState.Free); bool canMoveUnit = canMoveItems; bool nextTileUnitInteractiveStance = false; foreach (floorItem lItem in this.getFloorItems(nextX, nextY)) { if (lItem.Definition.Behaviour.isRoller) { nextTileIsRoller = true; continue; } if (lItem.Definition.Behaviour.isSolid) { canMoveItems = false; canMoveUnit = false; if (lItem.Definition.Behaviour.isDoor) { if (lItem.customData == "O") // Door is open canMoveUnit = true; // Can move unit in door } } else if (pUnit != null && lItem.Definition.isInteractiveStance) { nextTileUnitInteractiveStance = true; if(!nextTileIsRoller) canMoveUnit = true; } } if (!canMoveItems) // Can't move items { if (!canMoveUnit) // Can't move unit aswell continue; // Can't run this roller pItems.Clear(); // Clear items to move } #region Generate notification and move objects serverMessage eventNotification = new serverMessage(230); // "Cf" eventNotification.appendWired(lRoller.X); eventNotification.appendWired(lRoller.Y); eventNotification.appendWired(nextX); eventNotification.appendWired(nextY); eventNotification.appendWired(pItems.Count); foreach (floorItem lItem in pItems) { float nextZ = lItem.Z; if (!nextTileIsRoller) nextZ -= lRoller.Definition.topHeight; eventNotification.appendWired(lItem.ID); eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(lItem.Z)); eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(nextZ)); lItem.X = nextX; lItem.Y = nextY; lItem.Z = nextZ; lItem.requiresUpdate = true; movedItemIDs.Add(lItem.ID); generateFloorMap(); } eventNotification.appendWired(lRoller.ID); if (pUnit != null) // Room unit lifting with roller { float nextZ = pUnit.Z; if (!nextTileIsRoller) nextZ -= lRoller.Definition.topHeight; pUnit.X = nextX; pUnit.Y = nextY; pUnit.Z = nextZ; pUnit.requiresUpdate = true; if (!nextTileIsRoller || nextTileUnitInteractiveStance) this.setRoomUnitTileState(pUnit); this.gridUnit[lRoller.X, lRoller.Y] = false; this.gridUnit[pUnit.X, pUnit.Y] = true; eventNotification.appendWired(2); eventNotification.appendWired(pUnit.ID); eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(pUnit.Z)); eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(nextZ)); movedRoomUnitIDs.Add(pUnit.ID); } #endregion Updates.Append(eventNotification.ToString()); } if (Updates.Length > 0) { this.sendMessage(Updates.ToString()); } this.mRollerTimer = DateTime.Now.TimeOfDay.TotalSeconds + rollerDelaySeconds; this.mRollerDay = DateTime.Today.DayOfYear; } catch (Exception ex) { Core.Logging.Log("Rollers in room instance of room " + this.roomID + " crashed, exception: " + ex.Message); this.hasRollers = false; } }
/// <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> /// Sends a serverMessage object to all active room users in the room, after a given delay in milliseconds. /// </summary> /// <param name="Message">The serverMessage object to send.</param> /// <param name="delayMilliseconds">The amount of milliseconds to sleep before sending the message.</param> public void sendMessage(serverMessage Message, int delayMilliseconds) { this.sendMessage(Message.ToString(), delayMilliseconds); }
/// <summary> /// 56 - "@x" /// </summary> public void WHISPER() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (!Me.isMuted) { string whisperBody = Request.getParameter(0); string receiverName = whisperBody.Substring(0, whisperBody.IndexOf(' ')); string Text = whisperBody.Substring(receiverName.Length + 1); stringFunctions.filterVulnerableStuff(ref Text, true); serverMessage Whisper = new serverMessage(25); // "@Y" Whisper.appendWired(Me.ID); Whisper.appendClosedValue(Text); Session.gameConnection.sendMessage(Whisper); if (receiverName.Length > 0 && receiverName != Session.User.Username) { roomUser Receiver = Session.roomInstance.getRoomUser(receiverName); if (Receiver != null) Receiver.Session.gameConnection.sendMessage(Whisper); ObjectTree.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, Receiver.Session.User.ID, chatType.whisper, ref Text); } } }
/// <summary> /// Aborts the current trade. /// </summary> public void abortTrade() { if (this.itemStripHandler.isTrading && this.inRoom) { serverMessage tradeWindowCloser = new serverMessage(110); // "An" serverMessage forcedRefresh = new serverMessage(101); // "Ae" Session partnerSession = ObjectTree.Sessions.getSession(this.itemStripHandler.tradePartnerSessionID); this.itemStripHandler.stopTrade(); partnerSession.itemStripHandler.stopTrade(); this.roomInstance.getRoomUser(this.ID).removeStatus("trd"); this.roomInstance.getRoomUser(partnerSession.ID).removeStatus("trd"); this.gameConnection.sendMessage(tradeWindowCloser); this.gameConnection.sendMessage(forcedRefresh); partnerSession.gameConnection.sendMessage(tradeWindowCloser); partnerSession.gameConnection.sendMessage(forcedRefresh); } }
/// <summary> /// Removes all users from the room and nullifies all objects. /// </summary> public void Destroy() { this.roomWorker.Abort(); this.roomWorker = null; if (this.userAmount > 0) // Users in room { // Broadcoast 'kick' message serverMessage Notify = new serverMessage(18); // "@R" sendMessage(Notify); Notify = null; Type pCommonReactor = new roomReactor().GetType(); Type pFlatReactor = new flatReactor().GetType(); lock (this.roomUsers) { foreach (roomUser lRoomUser in this.roomUsers.Values) { if (this.Information.isUserFlat) lRoomUser.Session.gameConnection.reactorHandler.unRegister(pFlatReactor); else lRoomUser.Session.gameConnection.reactorHandler.unRegister(pCommonReactor); lRoomUser.Session.roomID = 0; lRoomUser.Session.roomInstance = null; } } this.roomUsers.Clear(); } this.updateUserAmount(); this.roomUsers = null; this.roomUnitIdentifiers.Clear(); this.roomUnitIdentifiers = null; this.enteringSessions.Clear(); this.enteringSessions = null; this.saveItems(); this.unloadItems(); this.Information = null; this.gridState = null; this.gridHeight = null; this.gridUnit = null; }
/// <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); } }