
Results 1 to 10 of 11
Threaded View
-
08-09-08, 01:42 PM #1
#food,#drink,#both Player - command's
So i got bored and made this. Note: Not tested or compiled so any errors Post.
PlayerCommands.cpp:
Code:#include "StdAfx.h" #include "Setup.h" #define FOOD_ADD 33254 #define DRINK_ADD 33236 #define BOTH_ADD 34062 #define MPOT_ADD 32948 #define HPOT_ADD 32947 #define STACK_COUNT 20 static string food = "#food"; static string food = "#drink"; static string food = "#both"; static string food = "#mpot"; static string food = "#hpot"; void EventPlayerCommands(Player * Plr, uint32 Type, uint32 Lang, const char * Message, const char * Misc) { if(Message == food) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(FOOD_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == drink) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(DRINK_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(DRINK_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == both) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(BOTH_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == hpot) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(HPOT_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == mpot) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(MPOT_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } } void SetupPlayerCommands(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (void *) EventPlayerCommands); }#include "StdAfx.h" #include "Setup.h" #define FOOD_ADD 33254 #define DRINK_ADD 33236 #define BOTH_ADD 34062 #define MPOT_ADD 32948 #define HPOT_ADD 32947 #define STACK_COUNT 20 static string food = "#food"; static string food = "#drink"; static string food = "#both"; static string food = "#mpot"; static string food = "#hpot"; void EventPlayerCommands(Player * Plr, uint32 Type, uint32 Lang, const char * Message, const char * Misc) { if(Message == food) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(FOOD_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == drink) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(DRINK_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(DRINK_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == both) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(BOTH_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == hpot) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(HPOT_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } elseif(Message == mpot) { ItemPrototype *proto; ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_ADD); SlotResult slot; Item * pItem = objmgr.CreateItem(MPOT_ADD, Plr); proto = pItem->GetProto(); slot = Plr->GetItemInterface()->FindFreeInventorySlot(proto); if(slot.Result) { pItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, STACK_COUNT); pItem->SetOwner(Plr); if (pItem->GetProto()->Bonding == ITEM_BIND_ON_PICKUP) pItem->SoulBind(); pItem->m_isDirty = true; Plr->GetItemInterface()->SafeAddItem(pItem,slot.ContainerSlot,slot.Slot); if(Plr->IsInWorld() && !pItem->IsInWorld()) { pItem->PushToWorld(Plr->GetMapMgr()); ByteBuffer buf(2500); uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, Plr); Plr->PushCreationData(&buf, count); } } } } void SetupPlayerCommands(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (void *) EventPlayerCommands); }
Last edited by You_Got_Tescoed; 08-09-08 at 02:13 PM.