CristianDragan 1 Posted May 11, 2020 Share Posted May 11, 2020 Version of Files : XXX 1. Description of the problem / Question : I installed three pair of speed shoes on my server, and I want to know how to make an restriction when trying to equip a second pair of shoes, with that error message: "You cannot equip this item twice." I already tried something in item.cpp : else if (GetType() == ITEM_UNIQUE) { if (ch->GetWear(SPEED_SHOES)) return SPEED_SHOES2; else return SPEED_SHOES; else return SPEED_SHOES3; } but when I'm trying to compile the source I get: 'SPEED_SHOES1/2/3' was not declared in this scope I allready added UNIQUE_ITEM_SPEED_SHOES = 72701, UNIQUE_ITEM_SPEED_SHOES2 = 72702, UNIQUE_ITEM_SPEED_SHOES3 = 72703, in unique_item.h. Sorry for my bad english. Thanks, Sincerly, Cristian Link to comment Share on other sites More sharing options...
anon 2 Posted May 11, 2020 Share Posted May 11, 2020 (edited) Hi Cristian, item.cpp isn't probably the best place to add this restriction. What I would do to implement this is : in char_item.cpp Above bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) add bool isSpeedShoe(DWORD itemVnum) { return (itemVnum == UNIQUE_ITEM_SPEED_SHOES) || (itemVnum == UNIQUE_ITEM_SPEED_SHOES2) || (itemVnum == UNIQUE_ITEM_SPEED_SHOES3); } in bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) in if (item->GetWearFlag() & WEARABLE_UNIQUE) add if (isSpeedShoe(item->GetVnum)) { if ((GetWear(WEAR_UNIQUE1) && isSpeedShoe(GetWear(WEAR_UNIQUE1)->GetVnum())) || (GetWear(WEAR_UNIQUE2) && isSpeedShoe(GetWear(WEAR_UNIQUE2)->GetVnum()))) { ChatPacket(CHAT_TYPE_INFO, "You cannot equip this item twice"); return false; } } 32 minutes ago, CristianDragan said: Version of Files : XXX 1. Description of the problem / Question : I installed three pair of speed shoes on my server, and I want to know how to make an restriction when trying to equip a second pair of shoes, with that error message: "You cannot equip this item twice." I already tried something in item.cpp : else if (GetType() == ITEM_UNIQUE) { if (ch->GetWear(SPEED_SHOES)) return SPEED_SHOES2; else return SPEED_SHOES; else return SPEED_SHOES3; } but when I'm trying to compile the source I get: 'SPEED_SHOES1/2/3' was not declared in this scope I allready added UNIQUE_ITEM_SPEED_SHOES = 72701, UNIQUE_ITEM_SPEED_SHOES2 = 72702, UNIQUE_ITEM_SPEED_SHOES3 = 72703, in unique_item.h. Sorry for my bad english. Thanks, Sincerly, Cristian Edited May 11, 2020 by anon fixed if condition 1 Link to comment Share on other sites More sharing options...
CristianDragan 1 Posted May 11, 2020 Author Share Posted May 11, 2020 Solved. Thank you so much for your time and code Link to comment Share on other sites More sharing options...
CristianDragan 1 Posted May 12, 2020 Author Share Posted May 12, 2020 (edited) Tried with your latest edit, and I get this error when compiling : char_item.cpp: In member function 'bool CHARACTER::CanEquipNow(CItem*, const TItemPos&, const TItemPos&)': char_item.cpp:7768: error: argument of type 'DWORD (CItem::)()const' does not match 'DWORD' Line 7768: if (isSpeedShoe(item->GetVnum)) You forgot to add an "(" near Vnum and one at the end if (isSpeedShoe(item->GetVnum())) Now it's working. Thank you. Edited May 12, 2020 by CristianDragan 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