regal 20 Posted December 13, 2020 Share Posted December 13, 2020 Hello, everyone! I hope you have/had a nice day. So, I want to spawn a NPC via quest. I've used the pc.setqf so that after it's spawned when another flag is triggered(kill 100 mobs) the action is stopped. The problem is that as I've seen, pc.setqf is PID specific, so another player can spawn another NPC because he doesn't have that flag set yet. So, as a another "safety" action, is there any way to check if a specific npc is in a specific map(at least map index)? Or.. maybe.. set the flag as general for all PIDS? I tried to play with npc.is_available0() but I think that this function is for other means... P.S.: It is for a normal map, not dungeon.. with dungeon functions I think that I would've found a workaround. Thank you for taking your time! Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4873 Posted December 13, 2020 Bot Share Posted December 13, 2020 Im not sure if I understand well, but I think you want something like: find_npc_by_vnum(npc_vnum) This is usually used for target, but maybe it could work for what you're trying to do 1 Link to comment Share on other sites More sharing options...
Solution ondry 333 Posted December 13, 2020 Solution Share Posted December 13, 2020 7 hours ago, regal said: Or.. maybe.. set the flag as general for all PIDS? game.set_event_flag("isSpawned", 1) if game.get_event_flag("isSpawned") == 1 then return end 1 Link to comment Share on other sites More sharing options...
Endymion 319 Posted December 13, 2020 Share Posted December 13, 2020 (edited) struct FCountRaceInMap { size_t count; uint32_t dwVnum; FCountRaceInMap(uint32_t _dwVnum) : dwVnum(_dwVnum), count(0) {} void operator() (LPENTITY ent) { if (!ent->IsType(ENTITY_CHARACTER)) return; LPCHARACTER ch = static_cast<LPCHARACTER>(ent); if (ch->IsPC()) return; if (ch->GetRaceNum() == dwVnum) ++count; } }; size_t SECTREE_MANAGER::GetRaceCountInMap(long lMapIndex, uint32_t dwVnum) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); if (!sectree) return 0; FCountRaceInMap f(dwVnum); sectree->for_each(f); return f.count; } It should work, but I didn't test. Edited December 13, 2020 by Endymion 1 Link to comment Share on other sites More sharing options...
regal 20 Posted December 14, 2020 Author Share Posted December 14, 2020 Thanks everyone for answering! game.set_event_flag looks fine for now, but I appreciate all the answers. Regards, regal. 1 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