public void goOffline() { foreach (Buddy Buddy in Buddies.Values) { if (UserManager.containsUser(Buddy.userID)) { ConnectedUser thisBuddy = UserManager.getUser(Buddy.userID); thisBuddy.sendData("029" + thisBuddy.Messenger.getUpdates() + "#"); } } }
public void changeMission(string newMission) { foreach (Buddy Buddy in Buddies.Values) { if (UserManager.containsUser(Buddy.userID)) { ConnectedUser thisBuddy = UserManager.getUser(Buddy.userID); ((Buddy)thisBuddy.Messenger.Buddies[User._UserID]).mission = newMission; thisBuddy.sendData("029" + thisBuddy.Messenger.getUpdates() + "#"); } } }
public void sendRoomData2(ConnectedUser User) { string sendText = ""; foreach (ConnectedUser usr in _Users.Values) { AddAvatarPacket avatars = new AddAvatarPacket(); avatars.I = usr._UserID; avatars.U = usr._Username; avatars.M = usr._Mission; avatars.C = usr._Figure; avatars.B = usr._Badge; avatars.D = usr._Drink; avatars.Brb = usr._Brb; avatars.S = usr._Room_Sit; avatars.X = usr._Room_X; avatars.Y = usr._Room_Y; avatars.H = usr._Room_Dir; avatars.F = false; avatars.R = usr._HasRights; string stringavatars = JsonConvert.SerializeObject(avatars); sendText += "056" + stringavatars + "#"; } foreach (RoomBot bot in _Bots.Values) { // TODO: make it have a better id and different id AddAvatarPacket avatars = new AddAvatarPacket(); avatars.I = bot._MyAvatarID; avatars.U = bot._MyName; avatars.M = bot._MyMission; avatars.C = bot._MyFigure; avatars.B = "7"; // bot badge avatars.D = ""; avatars.Brb = 0; avatars.S = bot._Sit; avatars.X = bot._MyX; avatars.Y = bot._MyY; avatars.H = bot._MyZ; avatars.F = false; avatars.R = false; string stringavatars = JsonConvert.SerializeObject(avatars); sendText += "056" + stringavatars + "#"; } sendText += "044" + "#"; User.sendData(sendText); }
public void vote(string vote, ConnectedUser user) { if (user._UserID != RoomOwner && !user._Room_Voted) { if (vote == "up") { MySQL.runQuery("UPDATE rooms SET score = " + ++score + " WHERE id = '" + RoomID + "'"); } else if (vote == "down") { MySQL.runQuery("UPDATE rooms SET score = " + --score + " WHERE id = '" + RoomID + "'"); } MySQL.runQuery("INSERT INTO room_votes SET user='******', room='" + RoomID + "'"); user._Room_Voted = true; } RoomScorePacket toremove = new RoomScorePacket(); toremove.S = score; string scorePacketString = JsonConvert.SerializeObject(toremove); user.sendData("066" + scorePacketString + "#"); }
private void processPacket(string currentPacket) { int musHeader = int.Parse(currentPacket.Substring(0, 3)); string musData = currentPacket.Substring(3); Console.WriteLine("[WEB] RECV " + currentPacket); switch (musHeader) { default: sendData("ERR!"); break; case 1: sendData("error"); break; case 2: string answer = "error"; int userID = int.Parse(musData.Split((char)2)[0]); string caption = musData.Split((char)2)[1]; string code = musData.Split((char)2)[2]; string newFurniPacketString = ""; ConnectedUser user = UserManager.getUser(userID); int price = 1; if (user._Money >= price || RankManager.containsRight(user._Rank, "dont_pay")) { answer = "ok"; bool pay = true; bool tradeable = true; if (RankManager.containsRight(user._Rank, "dont_pay")) { pay = false; if (!RankManager.containsRight(user._Rank, "dont_pay_tradeable")) // staff kan spullen die gekocht zijn met te weinig geld niet ruilen { tradeable = false; } } string tradeable_text = "0"; if (tradeable) { tradeable_text = "1"; } int newFurniID = MySQL.insertGetLast("INSERT INTO items SET owner='" + user._UserID + "', furni='picture', tradeable='" + tradeable_text + "'"); MySQL.runQuery("INSERT INTO furni_history SET id='" + newFurniID + "', `date`='" + timestamp.get + "', `type`='cata', `from`='0', `to`='" + user._UserID + "', credits='" + price + "';"); MySQL.runQuery("INSERT INTO camera SET id='" + newFurniID + "', `caption`='" + caption + "', `code`='" + code + "';"); Packets.Game.FurniturePacket newFurni = new Packets.Game.FurniturePacket(); newFurni.I = newFurniID; newFurni.T = "inv"; newFurni.S = 1; newFurni.SH = 0; newFurni.H = 1; newFurni.A = 0; newFurni.F = "picture"; newFurniPacketString += "047" + JsonConvert.SerializeObject(newFurni) + "#"; if (pay) { user._Money = int.Parse(MySQL.runRead("SELECT money FROM members WHERE id = '" + user._UserID + "'")); user._Money = user._Money - price; MySQL.runQuery("UPDATE members SET money = '" + user._Money + "' WHERE id = '" + user._UserID + "'"); Packets.Game.UpdateMoneyPacket UpdateMoney = new Packets.Game.UpdateMoneyPacket(); UpdateMoney.M = user._Money; UpdateMoney.S = user._SessionEarned; string UpdateMoneyString = JsonConvert.SerializeObject(UpdateMoney); user.sendData("033" + UpdateMoneyString + "#"); } } else { answer = "price"; } Packets.Game.BuyAnswerPacket buyFurniAnswer = new Packets.Game.BuyAnswerPacket(); buyFurniAnswer.A = answer; string buyFurniAnswerString = JsonConvert.SerializeObject(buyFurniAnswer); user.sendData(newFurniPacketString + "035" + buyFurniAnswerString + "#"); break; } }