Jump to content

Help Exception C++


Recommended Posts

Hey guys.

I wanted to create a exception but my core crashes...

 

here my code:
 

bool IsExceptions(DWORD dwVnum)
{
	switch (dwVnum)
	{
		case 30036:
			return true;
	}
	return false;
}

bool CItem::IsItemBox()
{
	LPITEM	item;

	return (GetType() == ITEM_MATERIAL && !IsExceptions(item->GetVnum()));
}

i Know the bool IsExceptions isnt correctly...

i wanted - that the return will load all items from ITEM_MATERIAL but i want an Exception - he should check if there is a vnum there and if yes he should ignore this vnum
So -> [return] Load all from ITEM_MATERIAL but not this item...
i tryed with an int function - but i wanted a new function like my bool IsExceptions! - because i need this in more lines and i wanted to create a global one.

Someone how could help?

Best regards!

 

Link to comment
Share on other sites

  • Premium
18 hours ago, JeeX said:

is there a possibility to use an exception?

i only tryed like martys potion on pvp map block.

static bool IsExceptions(int vnum)
{
    switch (vnum)
    {
		case 30036:
		    return true;
    }

    return false;
}

 

if (!IsExceptions(GetVnum()))
{ 
	LPITEM	item;
	return (GetType() == ITEM_MATERIAL);
}

 

 

Link to comment
Share on other sites

  • Active+ Member

Ofc it crash when you call function GetVnum() through a null pointer :facepalm:

bool CItem::IsExceptions(DWORD dwVnum)
{
	switch (dwVnum)
	{
		case 30036:
			return true;
        		break;
	}
	return false;
}

bool CItem::IsItemBox()
{
	//LPITEM	item; // why ?

	return (GetType() == ITEM_MATERIAL && !IsExceptions(GetVnum())); 
	// Just call GetVnum() or like that: this->GetVnum()
}

 

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • 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.