public void HandleGrabPet(byte slot, int ItemID)
{
try
{
//Checks before we continue (Level check).
if (!CheckItemLevel(Character.Information.Level, ItemID))
{
client.Send(Packet.MoveItemError(0x6C, 0x18));
}
//Else we continue
else
{
//Our database query for loading pet information.
MsSQL ms = new MsSQL("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
//Get detailed item information.
Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);
//Get item model information
int model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName);
//Create new pet object
pet_obj o = new pet_obj();
//Our sql data reader
using (SqlDataReader reader = ms.Read())
{
//While our reader is open we read all info below.
while (reader.Read())
{
int itemid = reader.GetInt32(7);
Character.Grabpet.Grabpetid = item.dbID;
o.UniqueID = Character.Grabpet.Grabpetid;
o.Model = model;
o.Slots = reader.GetByte(8);
o.x = Character.Position.x + rnd.Next(1, 3);
o.z = Character.Position.z;
o.y = Character.Position.y + rnd.Next(1, 3);
o.xSec = Character.Position.xSec;
o.ySec = Character.Position.ySec;
o.OwnerID = Character.Information.CharacterID;
o.OwnerName = Character.Information.Name;
o.Walking = Character.Position.Walking;
o.Petname = reader.GetString(3);
o.Named = 2;
o.Run = Character.Speed.RunSpeed;
o.Walk = Character.Speed.WalkSpeed;
o.Zerk = Character.Speed.BerserkSpeed;
}
ms.Close();
}
//We set our pet active bool, so user cannot spawn multiple.
Character.Grabpet.Active = true;
o.Information = true;
//Set all details above to definitions
Character.Grabpet.Details = o;
//Global spawn the pet
Systems.HelperObject.Add(o);
//Spawn ourselfs
o.SpawnMe();
//Send then packet required (Pet information block).
client.Send(Packet.Pet_Information_grab(o, slot));
//Update pet status to active (For relog purposes).
MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
}
}
catch (Exception ex)
{
Console.WriteLine("Grab pet spawn error : " + ex);
}
}