masodikbela

item_change_vnum

Jul 19th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1.     int item_change_vnum(lua_State* L)
  2.     {
  3.         LPITEM item = CQuestManager::instance().GetCurrentItem();
  4.         LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  5.  
  6.         if (!item || !ch || lua_gettop(L) < 1 || !lua_isnumber(L, 1))
  7.         {
  8.             lua_pushboolean(L, 0);
  9.             return 1;
  10.         }
  11.  
  12.         LPITEM itemNew = ch->AutoGiveItem(lua_tonumber(L, 1), item->GetCount());
  13.         if (!itemNew)
  14.         {
  15.             lua_pushboolean(L, 0);
  16.             return 1;
  17.         }
  18.  
  19.         for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
  20.             itemNew->SetSocket(i, item->GetSocket(i));
  21.  
  22.         for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
  23.             itemNew->SetForceAttribute(i, item->GetAttributeType(i), item->GetAttributeValue(i));
  24.  
  25.         ITEM_MANAGER::instance().RemoveItem(item);
  26.        
  27.         lua_pushboolean(L, 1);
  28.  
  29.         return 1;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment