daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Tokens.cpp
  2.  
  3. #include "StdAfx.h"
  4. #include "Setup.h"
  5.  
  6. #define TokenID 29434
  7. #define amt 1
  8.  
  9. void addToken(Player* pPlayer)
  10. {
  11. int RandomNumberGenerator = RandomUInt(100);
  12.  
  13. ItemPrototype* it = ItemPrototypeStorage.LookupEntry(TokenID);
  14. Item * add = pPlayer->GetItemInterface()->FindItemLessMax(TokenID, amt, false);
  15. SlotResult slotresult = pPlayer->GetItemInterface()->FindFreeInventorySlot(it);
  16.  
  17. if(RandomNumberGenerator <= 50)
  18. {
  19. pPlayer->BroadcastMessage("You have gained a token.");
  20. if (!add)
  21. {
  22. if(!slotresult.Result)
  23. {
  24. pPlayer->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
  25. } else {
  26. Item *item = objmgr.CreateItem( TokenID, pPlayer);
  27. item->SetUInt32Value( ITEM_FIELD_STACK_COUNT, amt );
  28. if( pPlayer->GetItemInterface()->SafeAddItem( item, slotresult.ContainerSlot, slotresult.Slot ))
  29. {
  30. pPlayer->GetSession()->SendItemPushResult(item,false,true,true,true,slot r esult.ContainerSlot,slotresult.Slot,1);
  31. sQuestMgr.OnPlayerItemPickup(pPlayer,item);
  32. } else {
  33. item->DeleteMe();
  34. }
  35. }
  36. } else {
  37. add->SetCount(add->GetUInt32Value(ITEM_FIELD_STACK_COUNT) + amt);
  38. add->m_isDirty = true;
  39. pPlayer->GetSession()->SendItemPushResult(add, false, true, true, false, pPlayer->GetItemInterface()->GetBagSlotByGuid(add->GetGUID()), 0xFFFFFFFF, 1);
  40. }
  41. } else {
  42. pPlayer->BroadcastMessage("You have not gained a token.");
  43. }
  44. }
  45.  
  46. void SetupTokens(ScriptMgr * mgr)
  47. {
  48. mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, (void*)addToken);
  49. }
  50.  
  51.  
  52. setup.cpp
  53. //Projectfile remade by Keazain
  54.  
  55. #include "StdAfx.h"
  56. #include "Setup.h"
  57. #define SKIP_ALLOCATOR_SHARING 1
  58. #include <ScriptSetup.h>
  59.  
  60. extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
  61. {
  62. return SCRIPT_TYPE_MISC;
  63. }
  64.  
  65. extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
  66. {
  67. SetupTokens(mgr);
  68. }
  69.  
  70. #ifdef WIN32
  71.  
  72. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
  73. {
  74. return TRUE;
  75. }
  76.  
  77. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top