Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemHandlerScript
- {
- public static void Handle(MsgItemInfo UseItem, GameState client)
- {
- using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("itemscript").Where("useitemid", UseItem.ID))
- using (var rdr = new MySqlReader(cmd))
- {
- if (rdr.Read())
- {
- if (!client.Inventory.Contains(UseItem.ID, rdr.ReadByte("removecount")))
- return;
- if (rdr.ReadUInt32("giveitemid") > 0)
- {
- Database.ConquerItemInformation infos = new Database.ConquerItemInformation(rdr.ReadUInt32("giveitemid"), 0);
- if (infos == null)
- return;
- if (infos.BaseInformation.StackSize > 0)
- {
- if (client.Inventory.Count <= 39)
- {
- if (rdr.ReadUInt32("chance") > 0)
- {
- if (Kernel.ChanceSuccess((int)rdr.ReadUInt32("chance")))
- {
- client.Inventory.Add(infos.BaseInformation.ID, rdr.ReadByte("giveitemplus"), rdr.ReadByte("givecount"));
- }
- }
- else
- {
- client.Inventory.Add(infos.BaseInformation.ID, rdr.ReadByte("giveitemplus"), rdr.ReadByte("givecount"));
- }
- }
- else
- {
- client.Send(Constants.FullInventory);
- return;
- }
- }
- else if (infos.BaseInformation.StackSize == 0)
- {
- if (client.Inventory.Count <= (40 - rdr.ReadByte("givecount")))
- {
- if (rdr.ReadUInt32("chance") > 0)
- {
- if (Kernel.ChanceSuccess((int)rdr.ReadUInt32("chance")))
- {
- client.Inventory.Add(infos.BaseInformation.ID, rdr.ReadByte("giveitemplus"), rdr.ReadByte("givecount"));
- }
- }
- else
- {
- client.Inventory.Add(infos.BaseInformation.ID, rdr.ReadByte("giveitemplus"), rdr.ReadByte("givecount"));
- }
- }
- else
- {
- client.Send(Constants.FullInventory);
- return;
- }
- }
- infos = null;
- }
- else if (rdr.ReadUInt16("actionid") > 0)
- {
- client.Send(MsgAction.Custom(rdr.ReadUInt16("actionid"), client.Player.UID));
- }
- if (rdr.ReadBoolean("removeused"))
- {
- client.Inventory.Remove(UseItem.ID, rdr.ReadByte("removecount"));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement