Premium Galet 514 Posted July 17, 2015 Premium Share Posted July 17, 2015 Hello, I want to create a special belt with only claw in it, so I decided to create a if statement in "belt_inventory_helper.h", so I created it in lot of way but without success... Here's the first way (belt_inventory_helper.h) : static bool CanMoveIntoBeltInventory(LPITEM item) { bool canMove = false; if (item->GetVnum() == MY ITEM) { if (item->GetType() == ITEM_WEAPON) { switch (item->GetSubType()) { case WEAPON_CLAW: canMove = true; break; } } } else if (item->GetVnum() != MY ITEM) { if (item->GetType() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_NODELAY: case USE_ABILITY_UP: canMove = true; break; } } } return canMove; } Second way (belt_inventory_helper.h) : static bool CanMoveIntoBeltInventory(LPITEM item) { bool canMove = false; if (item->GetType() == ITEM_USE || item->GetType() == ITEM_WEAPON) { if (item->GetVnum() == MY ITEM) { switch (item->GetSubType()) { case WEAPON_CLAW: canMove = true; break; } } else { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_NODELAY: case USE_ABILITY_UP: canMove = true; break; } } } return canMove; } Third way in order to see if I can place everything in it and then create a special function for this special belt (input_main.cpp & char_item.cpp) : if (pkItem->GetVnum() != MY ITEM && p->ItemPos.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(pkItem)) { ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Ceintures> Vous ne pouvez pas bouger cet objet ici.")); return; } if (item->GetVnum() != MY ITEM && DestCell.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(item)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀÌ ¾ÆÀÌÅÛÀº º§Æ® Àκ¥Å丮·Î ¿Å±æ ¼ö ¾ø½À´Ï´Ù.")); return false; } And I can't put everything, I can only put the things declared in CanMoveIntoBeltInventory. Have a nice day, thanks Link to comment Share on other sites More sharing options...
Morphe 160 Posted July 17, 2015 Share Posted July 17, 2015 Try like this: static bool CanMoveIntoBeltInventory(LPITEM item) { bool canMove = false; if (item->GetType() == ITEM_WEAPON) { switch (item->GetSubType()) { case WEAPON_CLAW: canMove = true; break; } } else if (item->GetType() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_NODELAY: case USE_ABILITY_UP: canMove = true; break; } } return canMove; } 1 Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted July 17, 2015 Author Premium Share Posted July 17, 2015 Try like this: static bool CanMoveIntoBeltInventory(LPITEM item) { bool canMove = false; if (item->GetType() == ITEM_WEAPON) { switch (item->GetSubType()) { case WEAPON_CLAW: canMove = true; break; } } else if (item->GetType() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_NODELAY: case USE_ABILITY_UP: canMove = true; break; } } return canMove; } I can move claws and Potion but on all belts, not only one... I didn't try to use your script now because there'snt a check for the item_vnum in order to put claws only in a special belt (id 75500) Thanks anyway Link to comment Share on other sites More sharing options...
Ken 905 Posted July 17, 2015 Share Posted July 17, 2015 (edited) static bool CanMoveIntoBeltInventory(LPITEM item) { if (!item) return false; bool bCanMove = false; int ariClawVnums[] = { 6019, 6029, 6039, 6049 }; for (size_t i = 0; i < _countof(ariClawVnums); ++i) { if (item->GetVnum() == ariClawVnums[i]) bCanMove = true; } if (item->GetVnum() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_DELAY: case USE_ABILITY_UP: bCanMove = true; break; } } return bCanMove; } _countof or countof : template < typename T, size_t N > size_t countof( T ( & arr )[ N ] ) { return std::extent< T[ N ] >::value; } Usefull codes. Kind Regards Ken Edited July 17, 2015 by Ken 1 Do not be sorry, be better. Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted July 17, 2015 Author Premium Share Posted July 17, 2015 static bool CanMoveIntoBeltInventory(LPITEM item) { if (!item) return false; bool bCanMove = false; int ariClawVnums[] = { 6019, 6029, 6039, 6049 }; for (size_t i = 0; i < _countof(ariClawVnums); ++i) { if (item->GetVnum() == ariClawVnums[i]) bCanMove = true; } if (item->GetVnum() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_DELAY: case USE_ABILITY_UP: bCanMove = true; break; } } return bCanMove; } _countof or countof : template < typename T, size_t N > size_t countof( T ( & arr )[ N ] ) { return std::extent< T[ N ] >::value; } Usefull codes. Kind Regards Ken Thanks a lot dude ! But how to put claws in only one special item ? (vnum 75500) Because with my actual system, I can put them (and only claws) in all belts and not only one Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted July 21, 2015 Author Premium Share Posted July 21, 2015 @Ref Link to comment Share on other sites More sharing options...
Cilindro 14 Posted July 21, 2015 Share Posted July 21, 2015 what can i do for put more then normal itens in ther ? Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted July 21, 2015 Author Premium Share Posted July 21, 2015 if (item->GetType() == ITEM_USE || item->GetType() == ITEM_YOUR_TYPE) And then add : case YOUR_SUBTYPE: Link to comment Share on other sites More sharing options...
RatCatcher 77 Posted July 21, 2015 Share Posted July 21, 2015 (edited) Oh my fucking god.. static bool CanMoveIntoBeltInventory(LPITEM item) { bool canMove = false; LPITEM belt = item->GetOwner()->GetWear(WEAR_BELT); DWORD dwAllowedBeltVnum = 180; if (belt->GetVnum() == dwAllowedBeltVnum) { if (item->GetType() == ITEM_WEAPON) { switch (item->GetSubType()) { case WEAPON_CLAW: canMove = true; break; } } } if (item->GetType() == ITEM_USE) { switch (item->GetSubType()) { case USE_POTION: case USE_POTION_NODELAY: case USE_ABILITY_UP: canMove = true; break; } } return canMove; } DWORD dwAllowedBeltVnum = 180; change to vnum of the belt you want to be able to put claws into Edited July 21, 2015 by RatCatcher 1 Enough is enough Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted July 21, 2015 Author Premium Share Posted July 21, 2015 I edited the piece of code, now, it's working Thanks ! Link to comment Share on other sites More sharing options...
Cilindro 14 Posted July 21, 2015 Share Posted July 21, 2015 but i whant put more itens new auto posien and more things and not weapens o.O Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now