Jump to content

<Question> Removing an item from each member of a party


Recommended Posts

Hi - I've created a new dungeon etc which requires a ticket to enter, it's easy to sort this for an individual player so he pays the ticket then enters etc but i've gotten stuck on how to do it for each individual member of a group.

 

My initial idea was to just make everyone give it to the party leader and use party.get_near_count with a for loop but then not everyone trusts each other so this isn't a viable option.

 

my second idea is jumping the entire group the map without paying for the entry then once on that map it'll check each individual member for a ticket and either remove the ticket or kick them from the dungeon.

 

 

i was wondering if there were any other ways to do this prior to putting them in the dungeon like my second more viable idea.

 

Regards,

Invictus

Link to comment
Share on other sites

void CParty::RemoveItem(int iVnum)
{
	TMemberMap::iterator it;
	for (it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
	{
		if (!it->second.pCharacter)
			continue;

		LPCHARACTER ch = it->second.pCharacter;
		ch->RemoveSpecifyItem(iVnum);
	}
}
void CParty::HasItem(int iVnum)
{
        TMemberMap::iterator it;
        for (it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
        {
                if (!it->second.pCharacter)
                        continue;
 
                LPCHARACTER ch = it->second.pCharacter;
               if(!ch->CountSpecifyItem(iVnum))
                        return false;
        }
        return true;
}

 

It should works, add the lua part and the function prototype.

Link to comment
Share on other sites

void CParty::RemoveItem(int iVnum)
{
	TMemberMap::iterator it;
	for (it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
	{
		if (!it->second.pCharacter)
			continue;

		LPCHARACTER ch = it->second.pCharacter;
		ch->RemoveSpecifyItem(iVnum);
	}
}
void CParty::HasItem(int iVnum)
{
        TMemberMap::iterator it;
        for (it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
        {
                if (!it->second.pCharacter)
                        continue;
 
                LPCHARACTER ch = it->second.pCharacter;
               if(!ch->CountSpecifyItem(iVnum))
                        return false;
        }
        return true;
}

 

It should works, add the lua part and the function prototype.

 

In HasItem you have return false/true but you need to change it lua_pushnumber(L, 1/0)

Link to comment
Share on other sites

  • Developer

 

Try this:

function party.has_item(vnum)
	local pids = {party.get_member_pids()}
	for i, pid in pids do
		q.begin_other_pc_block(pid)
		if pc.count_item(vnum) > 0 then return 1 else return 0 end
		q.end_other_pc_block(pid)
	end
end

 

Should be:

for i, pid in ipairs/pairs(pids) do

or

for i, pid in next, pids do

Otherwise it'll attempt to call a table value.

 

But, he wants to remove that item so instead of return anything just use pc.remove_item(vnum).

  • Love 3

when you return 0 and server doesn't boot:

unknown.png

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.