|
|
public void AddTitle(Client.GameState client, short _type, short _id, bool equipped = false, int TimeInSeconds = 0)
{
if (StorageManager.Wing<bool>(_type, _id))
{
if (!client.Player.Wings.ContainsValue((uint)_id))
client.Player.Wings.Add((uint)_type, (uint)_id);
else return;
}
else
{
if (!client.Player.WTitles.ContainsValue((uint)_id))
client.Player.WTitles.Add((uint)_type, (uint)_id);
else return;
}
client.Player.UTitlePoints += StorageManager.GetTitlePoints(_type, _id);
var pkt = new TitleStorageProto()
{
ActionId = Action.Update,
Points = client.Player.UTitlePoints,
Value = new TitleValue()
{
Type = _type,
Id = _id,
Equipped = equipped,
Time = TimeInSeconds,
}
};
client.Send(FinalizeProtoBuf(pkt));
if (equipped)
{
if (StorageManager.Wing<bool>(_type, _id))
{
client.Player.EquippedWing = StorageManager.Wing<int>(_type, _id);
client.Player.NowEquippedWing.Clear();
client.Player.NowEquippedWing.Add(_type + "~" + _id);
}
else if (StorageManager.Title<bool>(_type, _id))
{
client.Player.EquippedTitle = StorageManager.Title<int>(_type, _id);
client.Player.NowEquippedTitle.Clear();
client.Player.NowEquippedTitle.Add(_type + "~" + _id);
}
}
}
public void RemoveTitle(Client.GameState client, short _type, short _id, bool equipped = false)
{
if (StorageManager.Wing<bool>(_type, _id))
{
if (client.Player.Wings.ContainsValue((uint)_id))
{
client.Player.Wings.Remove((uint)_type);
if (client.Player.EquippedWing == StorageManager.Wing<int>(_type, _id))
{
client.Player.EquippedWing = 0;
client.Player.NowEquippedWing.Clear();
var pkt = new TitleStorageProto()
{
ActionId = Action.Unequip,
Id = _id,
Type = _type,
Points = client.Player.UTitlePoints,
Value = new TitleValue()
{
Type = _type,
Id = _id,
Equipped = false
}
};
client.Send(FinalizeProtoBuf(pkt));
}
client.Player.UTitlePoints -= StorageManager.GetTitlePoints(_type, _id);
var pkt2 = new TitleStorageProto()
{
ActionId = Action.RemoveTitle,
Id = _id,
Type = _type,
Points = client.Player.UTitlePoints,
Value = new TitleValue()
{
Type = _type,
Id = _id,
Equipped = false
}
};
client.Send(FinalizeProtoBuf(pkt2));
}
else return;
}
else
{
if (client.Player.WTitles.ContainsValue((uint)_id))
{
client.Player.WTitles.Remove((uint)_type);
if (client.Player.EquippedTitle == StorageManager.Title<int>(_type, _id))
{
client.Player.EquippedTitle = 0;
client.Player.NowEquippedTitle.Clear();
var pkt = new TitleStorageProto()
{
ActionId = Action.Unequip,
Id = _id,
Type = _type,
Points = client.Player.UTitlePoints,
Value = new TitleValue()
{
Type = _type,
Id = _id,
Equipped = false
}
};
client.Send(FinalizeProtoBuf(pkt));
}
client.Player.UTitlePoints -= StorageManager.GetTitlePoints(_type, _id);
var pkt2 = new TitleStorageProto()
{
ActionId = Action.RemoveTitle,
Id = _id,
Type = _type,
Points = client.Player.UTitlePoints,
Value = new TitleValue()
{
Type = _type,
Id = _id,
Equipped = false
}
};
client.Send(FinalizeProtoBuf(pkt2));
}
else return;
}
}
public byte[] FinalizeProtoBuf(TitleStorageProto titleStorageProto)
{
using (var memoryStream = new MemoryStream())
{
Serializer.SerializeWithLengthPrefix(memoryStream, titleStorageProto, PrefixStyle.Fixed32);
var pkt = new byte[8 + memoryStream.Length];
memoryStream.ToArray().CopyTo(pkt, 0);
Writer.Write((ushort)memoryStream.Length, 0, pkt);
Writer.Write((ushort)3301, 2, pkt);
return pkt;
}
}
public TitleStorageProto Info;
#region wing Titel
case 17526:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello " + client.Entity.Name + " i can open New Wing - New Title 1 = 10000 CPs");
dialog.Option("New - Wings And Title ", 1);
dialog.Option("Wait a minute.", 255);
dialog.Avatar(114);
dialog.Send();
break;
}
#region New - Wings
case 1:
{
new TitleStorage().AddTitle(client, 4001, 1000, false);
new TitleStorage().AddTitle(client, 6001, 20, false);
new TitleStorage().AddTitle(client, 6002, 21, false);
new TitleStorage().AddTitle(client, 6003, 22, false);
new TitleStorage().AddTitle(client, 6004, 23, false);
new TitleStorage().AddTitle(client, 6005, 6005, false);
new TitleStorage().AddTitle(client, 6007, 6007, false);
new TitleStorage().AddTitle(client, 6008, 6008, false);
new TitleStorage().AddTitle(client, 6009, 6009, false);
new TitleStorage().AddTitle(client, 6010, 6010, false);
new TitleStorage().AddTitle(client, 6011, 6011, false);
new TitleStorage().AddTitle(client, 1, 1000, false);
new TitleStorage().AddTitle(client, 2018, 1, false);
new TitleStorage().AddTitle(client, 2001, 2, false);
new TitleStorage().AddTitle(client, 2002, 3, false);
new TitleStorage().AddTitle(client, 2003, 4, false);
new TitleStorage().AddTitle(client, 2004, 5, false);
new TitleStorage().AddTitle(client, 2005, 6, false);
new TitleStorage().AddTitle(client, 2006, 7, false);
new TitleStorage().AddTitle(client, 2020, 2020, false);
new TitleStorage().AddTitle(client, 2021, 2021, false);
new TitleStorage().AddTitle(client, 2022, 2022, false);
new TitleStorage().AddTitle(client, 2023, 2023, false);
new TitleStorage().AddTitle(client, 2024, 2024, false);
new TitleStorage().AddTitle(client, 2025, 2025, false);
new TitleStorage().AddTitle(client, 2026, 2026, false);
new TitleStorage().AddTitle(client, 2027, 2027, false);
new TitleStorage().AddTitle(client, 2028, 2028, false);
new TitleStorage().AddTitle(client, 2029, 2029, false);
new TitleStorage().AddTitle(client, 2030, 2030, false);
new TitleStorage().AddTitle(client, 2031, 2031, false);
new TitleStorage().AddTitle(client, 2032, 2032, false);
new TitleStorage().AddTitle(client, 2033, 2033, false);
new TitleStorage().AddTitle(client, 2034, 2034, false);
new TitleStorage().AddTitle(client, 2035, 2035, false);
new TitleStorage().AddTitle(client, 2036, 2036, false);
new TitleStorage().AddTitle(client, 2016, 17, false);
new TitleStorage().AddTitle(client, 2015, 16, false);
new TitleStorage().AddTitle(client, 2014, 15, false);
new TitleStorage().AddTitle(client, 2013, 14, false);
break;
}
#endregion
}
break;
}
#endregion
#region wing titel
case 17526:
{
switch (npcrequest.optionid)
{
case 0:
{
dialog.text("hello " + client.entity.name + " i can open new wing - new title 1 = 10000 cps");
dialog.option("new - wings and title ", 1);
dialog.option("wait a minute.", 255);
dialog.avatar(114);
dialog.send();
break;
}
#region new - wings
case 1:
{
new titlestorage().addtitle(client, 4001, 1000, false);
new titlestorage().addtitle(client, 6001, 20, false);
new titlestorage().addtitle(client, 6002, 21, false);
new titlestorage().addtitle(client, 6003, 22, false);
new titlestorage().addtitle(client, 6004, 23, false);
new titlestorage().addtitle(client, 6005, 6005, false);
new titlestorage().addtitle(client, 6007, 6007, false);
new titlestorage().addtitle(client, 6008, 6008, false);
new titlestorage().addtitle(client, 6009, 6009, false);
new titlestorage().addtitle(client, 6010, 6010, false);
new titlestorage().addtitle(client, 6011, 6011, false);
new titlestorage().addtitle(client, 1, 1000, false);
new titlestorage().addtitle(client, 2018, 1, false);
new titlestorage().addtitle(client, 2001, 2, false);
new titlestorage().addtitle(client, 2002, 3, false);
new titlestorage().addtitle(client, 2003, 4, false);
new titlestorage().addtitle(client, 2004, 5, false);
new titlestorage().addtitle(client, 2005, 6, false);
new titlestorage().addtitle(client, 2006, 7, false);
new titlestorage().addtitle(client, 2020, 2020, false);
new titlestorage().addtitle(client, 2021, 2021, false);
new titlestorage().addtitle(client, 2022, 2022, false);
new titlestorage().addtitle(client, 2023, 2023, false);
new titlestorage().addtitle(client, 2024, 2024, false);
new titlestorage().addtitle(client, 2025, 2025, false);
new titlestorage().addtitle(client, 2026, 2026, false);
new titlestorage().addtitle(client, 2027, 2027, false);
new titlestorage().addtitle(client, 2028, 2028, false);
new titlestorage().addtitle(client, 2029, 2029, false);
new titlestorage().addtitle(client, 2030, 2030, false);
new titlestorage().addtitle(client, 2031, 2031, false);
new titlestorage().addtitle(client, 2032, 2032, false);
new titlestorage().addtitle(client, 2033, 2033, false);
new titlestorage().addtitle(client, 2034, 2034, false);
new titlestorage().addtitle(client, 2035, 2035, false);
new titlestorage().addtitle(client, 2036, 2036, false);
new titlestorage().addtitle(client, 2016, 17, false);
new titlestorage().addtitle(client, 2015, 16, false);
new titlestorage().addtitle(client, 2014, 15, false);
new titlestorage().addtitle(client, 2013, 14, false);
break;
}
#endregion
}
break;
}
#endregion
|
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|