المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : npc open to full TitleStorage


ElSaher
2020-04-01, 12:59 PM
اضافت npc علي السريع كدا

الانبي سي دا بيفتحلك كل الاشكال الي عندك في السورس تيتل وا ونج


#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

medo2020
2020-04-01, 02:28 PM
مش بيفتح حاجه ومش شغال بيظ

ElSaher
2020-04-02, 05:30 PM
نسيت حاجا يا جدعان ياريت حد يعدل علي الاضافت

هتخوش علي كلاس

ضيف دول في اخر الكلاس Wardrobe.cs

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;
}

}

medo2020
2020-04-02, 06:50 PM
فين اضيفهم تحت ايه