Jump to content

[C++]How to make pvp?


Recommended Posts

I want to make a new quest function, which will start pvp between 2 players.

I don't know how I can do it.

 

Could You give me an example how to make this function? 

 

Now, I have this code:

	int pc_start_pvp(lua_State* L)
	{
		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
		DWORD pid1 = pChar1->GetPlayerID();

		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
		DWORD pid2 = pChar2->GetPlayerID;
		if ( pChar1 == NULL || pChar2 == NULL )
		{
			lua_pushnumber(L, 0);
			return 0;
		}
		lua_pushnumber(L, 0);
		return 1;
	}

Pls, help me.

Link to comment
Share on other sites

I want to make a new quest function, which will start pvp between 2 players.

I don't know how I can do it.

 

Could You give me an example how to make this function? 

 

Now, I have this code:

	int pc_start_pvp(lua_State* L)
	{
		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
		DWORD pid1 = pChar1->GetPlayerID();

		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
		DWORD pid2 = pChar2->GetPlayerID;
		if ( pChar1 == NULL || pChar2 == NULL )
		{
			lua_pushnumber(L, 0);
			return 0;
		}
		lua_pushnumber(L, 0);
		return 1;
	}

Pls, help me.

 

It should work:

#include <pvp.h>
...
	int pc_start_pvp(lua_State* L)
	{
		LPCHARACTER me = CQuestManager::instance().GetCurrentCharacterPtr();
		LPCHARACTER vic = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
		if (me && vic)
		{
			CPVPManager::instance().Insert(me, vic);
		}
		return 1;
	}
  • Love 2
Link to comment
Share on other sites

It's not work.

 

 

#edit

I have to do somewere mistake, because my code looks like this:

	int pc_start_pvp(lua_State* L)
	{
		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
		//DWORD pid1 = pChar1->GetPlayerID();

		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
		//DWORD pid2 = pChar2->GetPlayerID;
		if ( pChar1 == NULL || pChar2 == NULL )
		{
			//lua_pushnumber(L, 0);
			return 0;
		}
		CPVPManager::instance().Insert(pChar1, pChar2);
		pChar1->ChatPacket(CHAT_TYPE_INFO, "It's not work1!");
		pChar2->ChatPacket(CHAT_TYPE_INFO, "It's not work2!");
		return 1;
	}

1. I include: "#include "pvp.h" and add: "{ "start_pvp", pc_start_pvp }," to "void RegisterPCFunctionTable()".

2. I was add this: "start_pvp()" in "quest_funcitons" and I was create quest:

quest pvp begin
	state start begin
		when blacksmith.chat."test_pvp" begin
			say("Nick")
			local nick= input()
			start_pvp(nick)
			say("done!")
		end
	end
end

But when I wirte nick, nothing happened.

Link to comment
Share on other sites

It's not work.

 

 

#edit

I have to do somewere mistake, because my code looks like this:

	int pc_start_pvp(lua_State* L)
	{
		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
		//DWORD pid1 = pChar1->GetPlayerID();

		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
		//DWORD pid2 = pChar2->GetPlayerID;
		if ( pChar1 == NULL || pChar2 == NULL )
		{
			//lua_pushnumber(L, 0);
			return 0;
		}
		CPVPManager::instance().Insert(pChar1, pChar2);
		pChar1->ChatPacket(CHAT_TYPE_INFO, "It's not work1!");
		pChar2->ChatPacket(CHAT_TYPE_INFO, "It's not work2!");
		return 1;
	}

1. I include: "#include "pvp.h" and add: "{ "start_pvp", pc_start_pvp }," to "void RegisterPCFunctionTable()".

2. I was add this: "start_pvp()" in "quest_funcitons" and I was create quest:

quest pvp begin
	state start begin
		when blacksmith.chat."test_pvp" begin
			say("Nick")
			local nick= input()
			start_pvp(nick)
			say("done!")
		end
	end
end

But when I wirte nick, nothing happened.

 

Shouldn't you use pc.start_pvp(nick)?

  • Love 2
Link to comment
Share on other sites

  • Premium

Yea, I should use pc.myfunction but "CPVPManager::instance().Insert()" isn't starting pvp but giving invitation to fight.

 

Hm?

Then find function which making accept to pvp? It's really so hard to think?

 

 

 

Okey, I describe to you way. You must code this.

When player accept PVP using TPacketGCPVP. This packet is good described in pvp.cpp in function CPVP::Packet. What you should do? Send this packet OMG.

 

 

TPacketGCPVP pack;
pack.bHeader = HEADER_GC_PVP;
pack.bMode = PVP_MODE_FIGHT;

pack.dwVIDSrc = me;
pack.dwVIDDst = oponent;

As i said. This is only way. You can find another PVP modes in packet.h -> EPVPModes

  • Love 2
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.