Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

How to add a restriction to speed shoes


Question

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 post

3 answers to this question

Recommended Posts

  • 0
Posted (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 by anon
fixed if condition (see edit history)
  • Love 1
Link to post
  • 0
Posted (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 :D 

if (isSpeedShoe(item->GetVnum()))

Now it's working.


Thank you.

Edited by CristianDragan (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.