Elzza 0 Posted August 26, 2014 Share Posted August 26, 2014 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 More sharing options...
Night 366 Posted August 26, 2014 Share Posted August 26, 2014 isnt the dual good enough? Link to comment Share on other sites More sharing options...
Elzza 0 Posted August 26, 2014 Author Share Posted August 26, 2014 No, because I want to insert into this function something else. Link to comment Share on other sites More sharing options...
Night 366 Posted August 26, 2014 Share Posted August 26, 2014 No, because I want to insert into this function something else. like? starting a pvp when map index == ? 1 Link to comment Share on other sites More sharing options...
Elzza 0 Posted August 26, 2014 Author Share Posted August 26, 2014 Yes Link to comment Share on other sites More sharing options...
Denis 1474 Posted August 26, 2014 Share Posted August 26, 2014 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; } 2 Link to comment Share on other sites More sharing options...
Elzza 0 Posted August 26, 2014 Author Share Posted August 26, 2014 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 More sharing options...
Denis 1474 Posted August 26, 2014 Share Posted August 26, 2014 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)? 2 Link to comment Share on other sites More sharing options...
Elzza 0 Posted August 27, 2014 Author Share Posted August 27, 2014 Yea, I should use pc.myfunction but "CPVPManager::instance().Insert()" isn't starting pvp but giving invitation to fight. Hm? Link to comment Share on other sites More sharing options...
Elzza 0 Posted August 27, 2014 Author Share Posted August 27, 2014 @refresh Link to comment Share on other sites More sharing options...
Premium Zonni 230 Posted August 28, 2014 Premium Share Posted August 28, 2014 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 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now