Jump to content

Quest Function - Is Pvp


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

open pvp.cpp

add in ending

bool CPVPManager::IsPvP(LPCHARACTER pkChr)
{
	CPVPSetMap::iterator it = m_map_pkPVPSetByID.find(pkChr->GetPlayerID());

	if (it == m_map_pkPVPSetByID.end())
		return false;

	TR1_NS::unordered_set<CPVP*>::iterator it2 = it->second.begin();

	while (it2 != it->second.end())
	{
		CPVP * pkPVP = *it2++;
                
		if (pkPVP->IsFight())
                        return true;    
                
	}
        
        return false;
}

open pvp.h

 

find 

void			Process();

add after

bool			IsPvP(LPCHARACTER pkChr);

open questlua_pc.cpp

 

add #include

#include "pvp.h"

code

        int is_pvp(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
                lua_pushboolean(L, CPVPManager::instance().IsPvP(ch));
                return 1;
	}

quest

quest tested begin
	state start begin
		when dead or login or logout begin
			if pc.is_pvp() then
				say("test")
				return
			end
end
end
end

i tested

  • Metin2 Dev 4
  • Good 1
  • Love 11
Link to comment
Share on other sites

  • Premium

This is actually bugged. If you are in a duel and you kill monsters or other players the function will still return true.

Test it like that: make a quest where you get 1 item for killing a player in duel. Start a duel, but don't kill that player. Instead kill some monsters. Or just kill another player. I am sure that you will get that item even if you did not killed the player which you're dueling with.

 

The correct code is like that (please don't copy and say it's yours. just request thread close) - you still have to include "pvp.h" :

int is_pvp(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();

	if (npc == NULL)
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	if (!npc->IsPC())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	CPVP kPVP(ch->GetPlayerID(), npc->GetPlayerID());
	CPVP * pkPVP = CPVPManager::instance().Find(kPVP.GetCRC());

	if (!pkPVP || !pkPVP->IsFight())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	lua_pushboolean(L, 1);
	return 1;
}

EDIT: Fixed m_dwCRC;

  • Love 7
Link to comment
Share on other sites

 

This is actually bugged. If you are in a duel and you kill monsters or other players the function will still return true.

Test it like that: make a quest where you get 1 item for killing a player in duel. Start a duel, but don't kill that player. Instead kill some monsters. Or just kill another player. I am sure that you will get that item even if you did not killed the player which you're dueling with.

 

The correct code is like that (please don't copy and say it's yours. just request thread close) - you still have to include "pvp.h" :

int is_pvp(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();

	if (!npc->IsPC())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	CPVP kPVP(ch->GetPlayerID(), npc->GetPlayerID());
	CPVP * pkPVP = CPVPManager::instance().Find(kPVP.m_dwCRC);

	if (!pkPVP || !pkPVP->IsFight())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	lua_pushboolean(L, 1);
	return 1;
}
quest tested begin
    state start begin
        when kill with npc.is_pc begin
            if pc.is_pvp() then
                say("test")
                return
            end
end
end
end
Link to comment
Share on other sites

  • Premium

 

 

This is actually bugged. If you are in a duel and you kill monsters or other players the function will still return true.

Test it like that: make a quest where you get 1 item for killing a player in duel. Start a duel, but don't kill that player. Instead kill some monsters. Or just kill another player. I am sure that you will get that item even if you did not killed the player which you're dueling with.

 

The correct code is like that (please don't copy and say it's yours. just request thread close) - you still have to include "pvp.h" :

int is_pvp(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();

	if (!npc->IsPC())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	CPVP kPVP(ch->GetPlayerID(), npc->GetPlayerID());
	CPVP * pkPVP = CPVPManager::instance().Find(kPVP.m_dwCRC);

	if (!pkPVP || !pkPVP->IsFight())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	lua_pushboolean(L, 1);
	return 1;
}

quest tested begin
    state start begin
        when kill with npc.is_pc begin
            if pc.is_pvp() then
                say("test")
                return
            end
end
end
end

 

Still bugged. You know why? I start a duel with you, but I kill your friend. I will still get the message (I shouldn't!!). :)

Link to comment
Share on other sites

  • Premium

I will fix this function asap and send you back that's easy we've just to take back the name of the guy with who we started the duel by the command used p2p

 

Are you serious? That's quite stupid, you know? Also, I've provided a solution above. Check it out. I think it's the only reasonable solution :)

  • Love 1
Link to comment
Share on other sites

  • 3 months later...

This is actually bugged. If you are in a duel and you kill monsters or other players the function will still return true.

Test it like that: make a quest where you get 1 item for killing a player in duel. Start a duel, but don't kill that player. Instead kill some monsters. Or just kill another player. I am sure that you will get that item even if you did not killed the player which you're dueling with.

 

The correct code is like that (please don't copy and say it's yours. just request thread close) - you still have to include "pvp.h" :

int is_pvp(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();

	if (!npc->IsPC())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	CPVP kPVP(ch->GetPlayerID(), npc->GetPlayerID());
	CPVP * pkPVP = CPVPManager::instance().Find(kPVP.GetCRC());

	if (!pkPVP || !pkPVP->IsFight())
	{
		lua_pushboolean(L, 0);
		return 1;
	}

	lua_pushboolean(L, 1);
	return 1;
}

EDIT: Fixed m_dwCRC;

 

 

quest tested begin
    state start begin
        when kill with npc.is_pc begin
            if pc.is_pvp() then
                say("test")
                return
            end
end
end
end

Hi, sorry for revive the post, but i tried that quest, and dont work.

Source compile fine. Thanks

  • Love 1
Link to comment
Share on other sites

  • 3 months later...

The quest is just a test, I'm not sure why you'd want to use it (To quickly see if its working, I hope? You can easily extend any other quest to test, though). As for why it doesn't work, I suppose you didn't add the parenthesis after npc.is_pc()

I didn't use the quest given..
I created a system and wanted to check if the player is killing while dueling or in war. it didn't work.

And of course i used with parenthesis... 

It Just didn't work, the quest stopped working after the : if pc.is_pvp()

  • Love 1
Link to comment
Share on other sites

  • 7 months later...
  • 2 weeks later...
On 31.07.2015 at 10:10 PM, PeaceMaker said:

I didn't use the quest given..
I created a system and wanted to check if the player is killing while dueling or in war. it didn't work.

And of course i used with parenthesis... 

It Just didn't work, the quest stopped working after the : if pc.is_pvp()

you are right

In pvp.cpp

change with this code:

Spoiler

bool CPVPManager::IsPvP(LPCHARACTER pkChr)
{
    CPVPSetMap::iterator it = m_map_pkPVPSetByID.find(pkChr->GetPlayerID());

    if (it == m_map_pkPVPSetByID.end())
        return false;

    TR1_NS::unordered_set<CPVP*>::iterator it2 = it->second.begin();

    while (it2 != it->second.end())
    {
        CPVP * pkPVP = *it2++;
        
        if (!pkPVP->IsFight())
        //if (pkPVP->IsFight()) //omori pe orice alcv inafar de ala cu care ai duel
        //if (!pkPVP || !pkPVP->IsFight()) //atunci cand omori pe cineva,fie ca e duel fie ca nu
            return true; 
                
    }
        
        return false;
    
}

tested!

quest: 

Spoiler

quest test begin
    state start begin
            when kill with pc.is_pvp() begin
                say("tested")
            end
    end
end

It works only if you kill the player that you are in pvp

Edited by Marggraf
add code
Link to comment
Share on other sites

  • 5 months later...
  • 6 years later...

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.