Minion 75 Posted January 12, 2015 Share Posted January 12, 2015 M2 Download Center This is the hidden content, please Sign In or Sign Up ( 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 5 1 11 Link to comment Share on other sites More sharing options...
tmoitoi 26 Posted January 12, 2015 Share Posted January 12, 2015 Can you explain me this function ? Thanks bro Link to comment Share on other sites More sharing options...
Premium Galet 514 Posted January 12, 2015 Premium Share Posted January 12, 2015 Thanks ! Really useful for more rp and some quests ! PS : If player are in pvp, you can do something (like giving some items, say some text, use a timer etc...) Link to comment Share on other sites More sharing options...
tmoitoi 26 Posted January 13, 2015 Share Posted January 13, 2015 When you say pvp you want say the Free mode ? Sorry for spam, thanks. Link to comment Share on other sites More sharing options...
Minion 75 Posted January 13, 2015 Author Share Posted January 13, 2015 When you say pvp you want say the Free mode ? Sorry for spam, thanks. no. Duel 1 vs 1 Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted January 16, 2015 Premium Share Posted January 16, 2015 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; 7 Link to comment Share on other sites More sharing options...
Minion 75 Posted January 17, 2015 Author Share Posted January 17, 2015 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 More sharing options...
Minion 75 Posted January 17, 2015 Author Share Posted January 17, 2015 why kPVP.m_dwCRC. Use kPVP.GetCRC() ? Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted January 17, 2015 Premium Share Posted January 17, 2015 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 More sharing options...
tmoitoi 26 Posted January 18, 2015 Share Posted January 18, 2015 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 Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted January 19, 2015 Premium Share Posted January 19, 2015 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 1 Link to comment Share on other sites More sharing options...
jma96 1 Posted April 24, 2015 Share Posted April 24, 2015 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 1 Link to comment Share on other sites More sharing options...
PeaceMaker 121 Posted July 28, 2015 Share Posted July 28, 2015 Yes it doesn't work ... Link to comment Share on other sites More sharing options...
Think 117 Posted July 29, 2015 Share Posted July 29, 2015 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() 1 Link to comment Share on other sites More sharing options...
PeaceMaker 121 Posted July 31, 2015 Share Posted July 31, 2015 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() 1 Link to comment Share on other sites More sharing options...
mdxyz 240 Posted March 9, 2016 Share Posted March 9, 2016 thx 1 Link to comment Share on other sites More sharing options...
Dollar 104 Posted March 9, 2016 Share Posted March 9, 2016 thanks 2 Link to comment Share on other sites More sharing options...
Marggraf 143 Posted March 19, 2016 Share Posted March 19, 2016 (edited) 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 March 20, 2016 by Marggraf add code Link to comment Share on other sites More sharing options...
BekirAKDMR 5 Posted September 1, 2016 Share Posted September 1, 2016 different idea to all person Link to comment Share on other sites More sharing options...
spectrum 7 Posted January 28, 2023 Share Posted January 28, 2023 /pvp and server down , nice :)))) Link to comment Share on other sites More sharing options...
Recommended Posts