|
المشاركات 1,993 |
+التقييم 1.00 |
تاريخ التسجيل Jun 2019 |
الاقامة |
نظام التشغيل |
رقم العضوية 279 |
#region Titly by elsaher
case 17526:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello " + client.Player.Name + ", How are you ? I am the manager of the new titles / wings");
dialog.Text("Do you want to buy wings / titles For free?");
dialog.Option("All Wing&Titel", 1);
break;
}
case 1:
{
new TitleStorage().GetAll(client);
break;
}
}
break;
}
#endregion
public void Handle(Client.GameState client)
{
switch (Info.ActionId)
{
case Action.Unequip:
{
if (StorageManager.Wing<bool>(Info.Type, Info.Id))
{
client.Player.EquippedWing = 0;
client.Player.NowEquippedWing.Clear();
}
else if (StorageManager.Title<bool>(Info.Type, Info.Id))
{
client.Player.EquippedTitle = 0;
client.Player.NowEquippedTitle.Clear();
}
client.Send(FinalizeProtoBuf(Info));
break;
}
case Action.Equip:
{
if (client.Player.UTitlePoints < StorageManager.GetTitlePoints((short)Info.Type, (short)Info.Id))
break;
if (StorageManager.Wing<bool>(Info.Type, Info.Id))
{
client.Player.EquippedWing = StorageManager.Wing<int>(Info.Type, Info.Id);
client.Player.NowEquippedWing.Clear();
client.Player.NowEquippedWing.Add(Info.Type + "~" + Info.Id);
}
else if (StorageManager.Title<bool>(Info.Type, Info.Id))
{
client.Player.EquippedTitle = StorageManager.Title<int>(Info.Type, Info.Id);
client.Player.NowEquippedTitle.Clear();
client.Player.NowEquippedTitle.Add(Info.Type + "~" + Info.Id);
}
Info = new TitleStorageProto()
{
ActionId = Action.Equip,
Points = client.Player.UTitlePoints,
Type = Info.Type,
Id = Info.Id,
};
client.Send(FinalizeProtoBuf(Info));
break;
}
}
new TitleStorage().CheckTitles(client);
}
public void GetAll(Client.GameState client)
{
foreach (var title in Database.WardrobeTable.Titles.Values)
{
AddTitle(client, (short)title.Type, (short)title.ID, false);
}
client.Player.haveallTitles = true;
}
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;
[Flags]
public enum Action : int
{
Update = 0,
UseTitle = 1,
RemoveTitle = 3,
Equip = 4,
Unequip = 5,
}
}
[ProtoContract]
public class TitleStorageProto
{
[ProtoMember(1, IsRequired = true)]
public TitleStorage.Action ActionId;
[ProtoMember(2, IsRequired = true)]
public int Points;
[ProtoMember(3, IsRequired = true)]
public int Type;
[ProtoMember(4, IsRequired = true)]
public int Id;
[ProtoMember(5, IsRequired = true)]
public TitleValue Value;
}
[ProtoContract]
public class TitleValue
{
[ProtoMember(1, IsRequired = true)]
public int Type;
[ProtoMember(2, IsRequired = true)]
public int Id;
[ProtoMember(3, IsRequired = true)]
public bool Equipped;
[ProtoMember(4, IsRequired = true)]
public int Time;
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
Poker Open Source | Mostafa Shalby | تطوير سيرفرات كونكر | 49 | 2024-10-29 06:32 AM |
Npc Open All New Wing~Titel | Users | تطوير سيرفرات كونكر | 6 | 2020-04-23 09:29 AM |
NewServer Open 21/4/2020 | abdo22 | اعلانات السيرفيرات الشخصية | 0 | 2020-04-21 07:59 PM |
Big Monsters full system | Tefa | تطوير سيرفرات كونكر | 6 | 2019-12-21 05:21 PM |
Demon Box Full Add | Mero | تطوير سيرفرات كونكر | 0 | 2019-04-28 02:33 PM |