static bool Zoneupdate(LoginClient client, CMSG msgID, BinReader data) { uint newZone = (uint)data.ReadUInt32(); client.Character.Zone = newZone; client.Character.Dirty = true; DataServer.Database.SaveObject(client.Character); ScriptPacket WorldZoneUpdate = new ScriptPacket(SCRMSG.ZONEUPDATE); WorldZoneUpdate.Write(client.Character.ObjectId); WorldZoneUpdate.Write(newZone); client.WorldConnection.Send(WorldZoneUpdate); if (client.Character.OnFriends != null) { foreach (DBFriendList Friend in client.Character.OnFriends) { LoginClient FriendOnline = LoginServer.GetLoginClientByCharacterID(Friend.Owner_ID); if (FriendOnline != null) { BinWriter flist = LoginClient.NewPacket(SMSG.FRIEND_STATUS); Chat.System(FriendOnline, client.Character.Name + "'s zone updated"); flist.Write((char)0x02); flist.Write((ulong)client.Character.ObjectId); flist.Write((int)newZone); flist.Write((int)client.Character.Level); flist.Write((int)client.Character.Class); client.Send(flist); } } } return(true); }
public static void SendToWorld(LoginClient client, DBCharacter tChar) { ScriptPacket scrpkg = new ScriptPacket(SCRMSG.GUILDUPDATE); scrpkg.Write(tChar.ObjectId); scrpkg.Write(tChar.GuildID); scrpkg.Write(tChar.GuildRank); client.WorldConnection.Send(scrpkg); return; }
static bool OnSetSelected(LoginClient client, CMSG msgID, BinReader data) { try { client.Character.Selected = data.ReadUInt64(); ScriptPacket pkg = new ScriptPacket(SCRMSG.SELECTION); pkg.Write(client.Character.ObjectId); pkg.Write(client.Character.Selected); client.WorldConnection.Send(pkg); return(true); } catch (Exception) {} return(true); }
static bool OnGiveTabard(LoginClient client, string input) { if (client.Character.GuildID == 0 || client.Character.GuildRank > 1) { Chat.System(client, "Only a guild leader or first officer may give out tabards"); return(true); } if (client.Character.Guild.Color == 0xFFFFFFFF) { Chat.System(client, "You must first purchase a tabard from a tabard vendor before you can give them out"); return(true); } string[] split = input.Split(' '); if (split.Length < 2) { return(false); } DBCharacter targetmember = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), split[1]); if (targetmember == null) { Chat.System(client, "Player not found"); return(true); } if (targetmember.GuildID != client.Character.GuildID) { Chat.System(client, "That player is not a member of your guild"); return(true); } DBItem newItem = new DBItem(); newItem.OwnerID = targetmember.ObjectId; newItem.OwnerSlot = 18; newItem.TemplateID = 343; DataServer.Database.AddNewObject(newItem); DataServer.Database.FillObjectRelations(newItem); client.WorldConnection.Send(newItem); ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM); Item.Write(targetmember.ObjectId); Item.Write(newItem.ObjectId); Item.Write((int)0); client.WorldConnection.Send(Item); return(true); }
static bool BuyItemVendor(LoginClient client, CMSG msgID, BinReader data) { ulong vendorGUID2 = data.ReadUInt64(); int itembuy = data.ReadInt32(); byte targetslot = 0; if (msgID == CMSG.BUY_ITEM_IN_SLOT) { data.ReadUInt64(); targetslot = data.ReadByte(); } DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + vendorGUID2 + "'"); if (obj.Length == 0) { Chat.System(client, "Vendor not found"); return(true); } DBVendor tvendor = (DBVendor)obj[0]; foreach (DBVendorItem item in tvendor.VendorItems) { if (item.TemplateID == itembuy) { DBItem newItem = new DBItem(); newItem.OwnerID = client.Character.ObjectId; newItem.OwnerSlot = targetslot; //temp, checks for open slot on world side newItem.TemplateID = item.TemplateID; newItem.Template = item.Template; DataServer.Database.AddNewObject(newItem); client.WorldConnection.Send(newItem); ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM); Item.Write(client.Character.ObjectId); Item.Write(newItem.ObjectId); Item.Write(item.Price); // Item.Write(23); // NEED TO MAKE THE SCRIPT SEND TO NEXT-FREE-SLOT, INSTEAD OF FIRST client.WorldConnection.Send(Item); // Chat.System(client, "Buy Item Working, Vendor GUI = "+vendorGUID2+" and item = "+itembuy+" on LoginServer"); return(true); } } Chat.System(client, "Item not found on this vendor"); return(true); }
static bool AcceptTrade(LoginClient client, CMSG msgID, BinReader data) { uint flag = data.ReadUInt32(); uint inviteeGUID = client.Character.LastTradeID; LoginClient invitee = LoginServer.GetLoginClientByCharacterID((uint)inviteeGUID); BinWriter pkg = LoginClient.NewPacket(SMSG.TRADE_STATUS); if (invitee.Character.TradeCompleted == true) { ScriptPacket Money = new ScriptPacket(SCRMSG.TRADEMONEY); Money.Write(client.Character.ObjectId); Money.Write(invitee.Character.ObjectId); Money.Write(client.Character.TradeMoney); Money.Write(invitee.Character.TradeMoney); client.WorldConnection.Send(Money); pkg.Write((int)8); invitee.Send(pkg); client.Send(pkg); client.Character.LastTradeID = 0; client.Character.TradeMoney = 0; client.Character.TradeCompleted = false; invitee.Character.LastTradeID = 0; invitee.Character.TradeMoney = 0; invitee.Character.TradeCompleted = false; } else { pkg.Write((int)4); client.Character.TradeCompleted = true; invitee.Send(pkg); } return(true); }
static bool OnGuildTabard(LoginClient client, CMSG msgID, BinReader data) { DBGuild tguild = client.Character.Guild; ulong vGUID = data.ReadUInt64(); tguild.Icon = data.ReadUInt32(); tguild.IconColor = data.ReadUInt32(); tguild.Border = data.ReadUInt32(); tguild.BorderColor = data.ReadUInt32(); tguild.Color = data.ReadUInt32(); DataServer.Database.SaveObject(tguild); SendToWorld(client, client.Character); DBItem newItem = new DBItem(); newItem.OwnerID = client.Character.ObjectId; newItem.OwnerSlot = 18; newItem.TemplateID = 343; DataServer.Database.AddNewObject(newItem); DataServer.Database.FillObjectRelations(newItem); client.WorldConnection.Send(newItem); ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM); Item.Write(client.Character.ObjectId); Item.Write(newItem.ObjectId); Item.Write((int)100000); client.WorldConnection.Send(Item); BinWriter tpkg = LoginClient.NewPacket(SMSG.TABARDVENDOR_ACTIVATE); tpkg.Write(client.Character.Selected); client.Send(tpkg); string gmsg = "Congratulations on your purchase, You may now give them to your members using !givetabard <member>"; Chat.GuildSay(0, client, gmsg, CHATMESSAGETYPE.GUILD); return(true); } //OnGuildTabard
static bool OnGiveitem(LoginClient client, string input) { if (client.Account.AccessLvl < ACCESSLEVEL.GM) { Chat.System(client, "You do not have access to this command"); return(true); } string[] split = input.Split(' '); if (split.Length < 2) { return(false); } uint templateId = (uint)int.Parse(split[1]); DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), templateId); if (!(template == null)) { DBItem newItem = new DBItem(); newItem.OwnerID = client.Character.ObjectId; newItem.OwnerSlot = 0; newItem.TemplateID = templateId; newItem.Template = template; DataServer.Database.AddNewObject(newItem); client.WorldConnection.Send(newItem); ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM); Item.Write(client.Character.ObjectId); Item.Write(newItem.ObjectId); Item.Write((int)0); client.WorldConnection.Send(Item); return(true); } Chat.System(client, "Item not found"); return(true); }
} //GuildPackets public static bool RemoveMember(DBGuildMembers tMember, LoginClient client) { DBCharacter tChar; LoginClient tClient = null; DBGuild oldGuild = client.Character.Guild; if (tMember == null) { Chat.System(client, "tMember was null"); return(false); } if (tMember.MemberID != client.Character.ObjectId) { tClient = LoginServer.GetLoginClientByCharacterID(tMember.MemberID); } else { tClient = client; } if (tClient != null) { tChar = tClient.Character; if (client.Character.ObjectId == tMember.MemberID) { Chat.System(tClient, "You have left " + oldGuild.Name); GuildMessage(oldGuild, client.Character.Name + " has left the guild"); } else { Chat.System(tClient, "You have been removed from " + oldGuild.Name + " by " + client.Character.Name); GuildMessage(oldGuild, tClient.Character.Name + " has removed from the guild by " + client.Character.Name); } //SendToWorld(client, tChar); ScriptPacket scrpkg = new ScriptPacket(SCRMSG.GUILDUPDATE); scrpkg.Write(tClient.Character.ObjectId); scrpkg.Write(0); scrpkg.Write(0); client.WorldConnection.Send(scrpkg); } else { tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), tMember.MemberID); if (tChar == null) { Console.WriteLine("Character not found when removing member from guild"); return(false); } } tChar.GuildID = 0; tChar.GuildRank = 0; tChar.GuildName = " "; tChar.Guild = null; DataServer.Database.SaveObject(tChar); if (tMember == null) { return(false); } DataServer.Database.DeleteObject(tMember); DataServer.Database.FillObjectRelations(oldGuild); return(true); } //RemoveMember
/// <summary> /// Spawns a temp mob on a worldmap /// </summary> /// <param name="client"></param> /// <param name="input"></param> //[ChatCmdAttribute("spawncircle", "spawncircle <name> <displayid>")] static bool OnSpawnCircle(LoginClient client, string input) { string[] split = input.Split('\"'); if (split.Length == 3) { split[2] = split[2].TrimStart(' '); } else if (split.Length == 1) { split = input.Split(' '); } if (split.Length != 3) { return(false); } int displayID = 0; try { if (split[2].StartsWith("0x")) { displayID = int.Parse(split[2].Substring(2), System.Globalization.NumberStyles.HexNumber); } else { displayID = int.Parse(split[2]); } } catch (Exception) { return(false); } if (displayID == 0) { Chat.System(client, "You must set a displayID."); return(true); } string name = split[1]; name = name.Replace("'", ""); // bleh!! if (name.Length > 20) { name = name.Substring(0, 20); } DataObject[] objs; try { objs = DataServer.Database.SelectObjects(typeof(DBCreature), "Name = '" + name + "'"); } catch (Exception) { Chat.System(client, "Error looking up name in database."); return(true); } DBCreature creature; if (objs.Length == 0) { creature = new DBCreature(); creature.Name = name; DataServer.Database.AddNewObject(creature); } else { creature = (DBCreature)objs[0]; } client.WorldConnection.Send(creature); ScriptPacket pkg = new ScriptPacket(0x02); pkg.Write(client.Character.ObjectId); pkg.Write(creature.ObjectId); pkg.Write(displayID); client.WorldConnection.Send(pkg); return(true); }
static bool OnSpawn(LoginClient client, string input) { if (client.Account.AccessLvl < ACCESSLEVEL.TEMPGM) { Chat.System(client, "You do not have access to this command"); return(true); } bool isVendor = false; char[] delim = new char[2]; delim[0] = '\"'; delim[1] = '^'; string[] split = input.Split(delim); string script = "WorldScripts.Living."; // Rewritten by Phaze so that only the first 2 parameters are necessary, and has defaults for the rest string name = ""; int displayID = 0; int level = 1; int health = 1; int mana = 1; int faction = 14; uint npc_flags = 0; // string facString="monster"; string subName = ""; bool bWalking = true; string cmd = ""; string input2 = ""; if (split.Length == 3) { cmd = split[0].TrimEnd(delim); cmd = split[0].TrimEnd(' '); name = split[1]; input2 = "cmd name" + split[2]; } else if (split.Length == 1) { split = input.Split(' '); if (split.Length == 1) { return(false); } cmd = split[0]; name = split[1]; input2 = input; } else { return(false); } split = input2.Split(' '); if (split.Length > 2) { try { if (split[2].StartsWith("0x")) { displayID = int.Parse(split[2].Substring(2), System.Globalization.NumberStyles.HexNumber); } else { displayID = int.Parse(split[2]); } } catch (Exception) { return(false); } if (cmd.Length > 6) { isVendor = true; } if (split.Length > 3) { level = int.Parse(split[3]); if (level == 0) { level = 1; } if (split.Length > 4) { // facString=split[4]; // New code so that faction can be assigned by name or number - Phaze FACTION NewFaction; try { NewFaction = (FACTION)Enum.Parse(typeof(FACTION), split[4].ToUpper()); } catch (System.ArgumentException) { Chat.System(client, "Invalid Faction"); Chat.System(client, "Available Factions are: "); string Factions = ""; foreach (string eFaction in Enum.GetNames(typeof(FACTION))) { Factions += eFaction + ", "; } Chat.System(client, Factions); return(true); } faction = (int)NewFaction; if (split.Length > 5) { try { bWalking = bool.Parse(split[5]); } catch (Exception) { Chat.System(client, "Walking must be either TRUE or FALSE"); return(true); } if (split.Length > 6) { subName = split[6]; if (split.Length > 7) { health = int.Parse(split[7]); } // script += split[7]; } } } } if (health < 2) { health = 25 + 50 * level; } } else { return(false); } if (isVendor) { switch (cmd.ToLower()) { case "createtalker": npc_flags = 1; Chat.System(client, "Creating Talker: " + name); break; case "createquester": npc_flags = 2; Chat.System(client, "Creating Quester: " + name); break; case "createvendor": npc_flags = 4; subName = "Merchant"; Chat.System(client, "Creating Vendor: " + name); break; case "createtrainer": npc_flags = 80; subName = "Trainer"; Chat.System(client, "Creating Trainer: " + name); break; case "createtaxi": npc_flags = 200; subName = "Taxi Vendor"; Chat.System(client, "Creating Taxi Vendor: " + name); break; case "createtabard": npc_flags = 512; //512 for tabard subName = "Tabard Vendor"; Chat.System(client, "Creating Tabard Vendor: " + name); break; case "createbank": npc_flags = 128; // This was for testing... Phaze subName = "Banker"; Chat.System(client, "Creating Banker: " + name); break; case "createtest": npc_flags = 96; // This was for testing... Phaze subName = "Test Vendor 96"; Chat.System(client, "Creating Test Vendor: " + name); break; } if (faction == 14) { faction = 0; } script += "VendorBase"; health = 1000; bWalking = false; } else { script += "MonsterBase"; } name = name.Replace("'", ""); // bleh!! if (name.Length > 20) { name = name.Substring(0, 20); } DataObject[] objs; try { objs = DataServer.Database.SelectObjects(typeof(DBCreature), "Name = '" + name + "'"); } catch (Exception) { Chat.System(client, "Error looking up name in database."); return(true); } DBCreature creature; if (objs.Length == 0) { creature = new DBCreature(); creature.Name = name; creature.Script = script; creature.Title = subName; creature.Roam = bWalking; creature.NPCFlags = npc_flags; DataServer.Database.AddNewObject(creature); } else { creature = (DBCreature)objs[0]; } DBSpawn spawn = new DBSpawn(); spawn.Creature = creature; spawn.CreatureID = creature.ObjectId; spawn.Level = level; spawn.Health = health; spawn.Power = mana; spawn.DisplayID = displayID; spawn.Faction = faction; spawn.Roam = bWalking; DataServer.Database.AddNewObject(spawn); client.WorldConnection.Send(creature); client.WorldConnection.Send(spawn); ScriptPacket pkg = new ScriptPacket(SCRMSG.SPAWN); pkg.Write(client.Character.ObjectId); pkg.Write(creature.ObjectId); pkg.Write(spawn.ObjectId); client.WorldConnection.Send(pkg); return(true); }
static bool OnOp(LoginClient client, string input) { if (client.Account.AccessLvl < ACCESSLEVEL.ADMIN) { Chat.System(client, "You do not have access to this command"); return(true); } // return true; //temp til command works string[] split = input.Split(' '); if (split.Length < 2) { return(false); } string target = split[1]; DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBCharacter), "Name = '" + target + "'"); if (objs.Length == 0) { Chat.System(client, "No such player."); return(true); } LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(objs[0].ObjectId); if (targetClient == null || targetClient.Character == null) { Chat.System(client, "That player is not online."); return(true); } ACCESSLEVEL NewAccessLevel; try { NewAccessLevel = (ACCESSLEVEL)Enum.Parse(typeof(ACCESSLEVEL), split[2].ToUpper()); } catch (System.ArgumentException) { Chat.System(client, "Invalid Access Level"); Chat.System(client, "Current Access Levels are: "); string Levels = ""; foreach (string level in Enum.GetNames(typeof(ACCESSLEVEL))) { Levels += level + " "; } Chat.System(client, Levels); return(true); } targetClient.Account.AccessLvl = NewAccessLevel; if (NewAccessLevel != ACCESSLEVEL.TEMPGM) { targetClient.Account.Dirty = true; DataServer.Database.SaveObject(targetClient.Account); } ScriptPacket UpdatePlayer = new ScriptPacket(SCRMSG.ACCESSUPDATE); UpdatePlayer.Write(targetClient.Character.ObjectId); UpdatePlayer.Write((byte)NewAccessLevel); client.WorldConnection.Send(UpdatePlayer); Chat.System(client, "Update of " + targetClient.Character.Name + " to " + NewAccessLevel.ToString() + " Successful!"); Console.WriteLine(targetClient.Character.Name + " was upgraded to " + NewAccessLevel.ToString() + " by " + client.Character.Name); return(true); }