ѕeмa™ 308 Posted February 27, 2015 Share Posted February 27, 2015 Hi, someone know if is possible get the hp of one mob/npc from the vid? example: when xxx.chat."test" begin begin npc.get_hp(npc.get_vid()) end npc.get_hp(arg) new function in c++. Thanks,. https://m2admin.net/ Link to comment Share on other sites More sharing options...
Denis 1474 Posted February 27, 2015 Share Posted February 27, 2015 //currently hp int npc_get_hp(lua_State * L) { CQuestManager& q = CQuestManager::instance(); LPCHARACTER npc = q.GetCurrentNPCCharacterPtr(); lua_pushnumber(L, npc->GetHP()); } //maximum hp int npc_get_max_hp(lua_State * L) { CQuestManager& q = CQuestManager::instance(); LPCHARACTER npc = q.GetCurrentNPCCharacterPtr(); lua_pushnumber(L, npc->GetMaxHP()); } 2 Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted February 27, 2015 Author Share Posted February 27, 2015 thanks u so much i will try it now, but if i can see the hp of the pet? i cant do .chat., but work with .click? https://m2admin.net/ Link to comment Share on other sites More sharing options...
Denis 1474 Posted February 27, 2015 Share Posted February 27, 2015 Yes, probably it should work. Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted February 27, 2015 Author Share Posted February 27, 2015 Yes, probably it should work. and if i need send the hp to the client in a loop_timer, how can i do? i cant do click every second to the pet, for this i put with the vid of the pet to save the vid on a variable and check in the loop_timer with the variable of the vid. :/ https://m2admin.net/ Link to comment Share on other sites More sharing options...
Denis 1474 Posted February 27, 2015 Share Posted February 27, 2015 //currently hp int npc_get_hp(lua_State * L) { DWORD vid = (DWORD) lua_tonumber(L, 1); LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid); lua_pushnumber(L, npc->GetHP()); } //maximum hp int npc_get_max_hp(lua_State * L) { DWORD vid = (DWORD) lua_tonumber(L, 1); LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid); lua_pushnumber(L, npc->GetMaxHP()); } 2 Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted February 28, 2015 Author Share Posted February 28, 2015 (edited) *EDIT: Fail. I have errors in the functions get_hp from the vid. Ingame error, Quest. C++ functions The function without the vid work fine, but with vid, doesnt work :/ Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal 1 https://m2admin.net/ Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted February 28, 2015 Author Share Posted February 28, 2015 #BUMP https://m2admin.net/ Link to comment Share on other sites More sharing options...
Solution newja 53 Posted February 28, 2015 Solution Share Posted February 28, 2015 (edited) int npc_get_hp_by_vid(lua_State* L) { lua_Number vid = lua_tonumber(L, 1); LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid); if(npc) { lua_pushnumber(L, npc->GetHP()); } else { lua_pushnumber(L, 0); } return 1; } int npc_get_max_hp_by_vid(lua_State* L) { lua_Number vid = lua_tonumber(L, 1); LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid); if(npc) { lua_pushnumber(L, npc->GetMaxHP()); } else { lua_pushnumber(L, 0); } return 1; } + Quest Regards, newja Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal 1 1 Link to comment Share on other sites More sharing options...
Krixius 13 Posted February 28, 2015 Share Posted February 28, 2015 can u put ur pet.is_mine() function please newja? Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted February 28, 2015 Author Share Posted February 28, 2015 Thanks u, solved. All work fine. https://m2admin.net/ Link to comment Share on other sites More sharing options...
newja 53 Posted February 28, 2015 Share Posted February 28, 2015 can u put ur pet.is_mine() function please newja? http://metin2dev.org/board/index.php?/topic/2795-c-some-usefull-stuffs/ Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted March 1, 2015 Premium Share Posted March 1, 2015 sema / newja, did your quest are release or not ? Or how to put the pet level before his name please ? Link to comment Share on other sites More sharing options...
newja 53 Posted March 1, 2015 Share Posted March 1, 2015 sema / newja, did your quest are release or not ? Or how to put the pet level before his name please ? What do you mean by saying your quest are released which one? ############################## To see pet level you must go to PetSystem.cpp find void CPetActor::SetName(const char* name) and replace whole function with this void CPetActor::SetName(const char* name) { std::string petName = ""; if (0 != m_pkOwner && 0 == name && 0 != m_pkOwner->GetName()) { petName += ""; } else petName += name; if (true == IsSummoned()) m_pkChar->SetName(petName); m_name = petName; } If you want to know how to set pet name, look into this quest pet begin state start begin when seal_id.use begin level = 99 -- here, you can insert a variable or anything you want vnum = 53008 -- pet ID name = "Petty-chan" -- pet Name pet.summon(vnum, "[Lv."..level.."] - "..name, false) end end end Regards, newja 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