Jump to content

Recommended Posts

questfunction:

    int npc_get_ip(lua_State* L)
    {
        LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
        lua_pushstring(L, npc->GetDesc()->GetHostName());
        return 1;
    }

 

error:

questlua_npc.cpp: In function 'int quest::npc_get_ip(lua_State*)':
questlua_npc.cpp:357: error: invalid use of incomplete type 'struct DESC'
typedef.h:4: error: forward declaration of 'struct DESC'

Link to comment
https://metin2.dev/topic/7928-npcget_ip-for-kill-own-character-check-error/
Share on other sites

	int pc_get_ip(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		
		if(!ch)
			return 0;
	 
		lua_pushstring(L, ch->GetDesc()->GetHostName());
		return 1;
	}
quest iptest begin
    state start begin
		when kill begin
			local vid = npc.get_vid()
			local old_pc = pc.select(vid)
			if old_pc != 0 then
				local e_ip = pc.get_ip()
				local e_name = pc.get_name()
				pc.select(old_pc)
				local m_ip = pc.get_ip()
				local m_name = pc.get_name()
				if e_ip == m_ip then
					syschat("same ip")
					syschat(""..e_name.." : "..e_ip.."")
					syschat(""..m_name.." : "..m_ip.."")
				else
					syschat("not same ip")
				end
			end
		end
    end
end

Try this one.

  • Premium

Find

#include "sectree_manager.h"

And add after:

#include "desc.h"

And I recommend you to use this function, otherwise your game may crash:

	int npc_get_ip(lua_State* L)
	{
		LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();

		if (!npc || !npc->GetDesc())
		{
			lua_pushstring(L, "INVALID");
			return 1;
		}

		lua_pushstring(L, npc->GetDesc()->GetHostName());
		return 1;
	}

 

If the enemy is not a PC (if you forgot to check or you don't want to) or it's an invalid instance (kinda impossible) then the function will return "INVALID" and you may do a check in your quest (if pc.get_ip() == "INVALID" then).

Tell me if that works.

  • Love 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.