Jump to content

Kick functions like /dc with LUA


Go to solution Solved by Aveline™,

Recommended Posts

  • Bot

I've tried, but it works only if you aren't a GM_PLAYER (a normal player).

It says, "This command doesn't exists".

I need a script that kicks the player if he/she doesn't meet some requisites.

This script needs to run with every "normal" character.

english_banner.gif

If you are using 40k source, here ;

	int pc_disconnect(lua_State* L)
	{
		if (!lua_isstring(L, 1))
		{
			LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(ch->GetName());
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		else
		{
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(lua_tostring(L, 1));
			LPCHARACTER tch = d ? d->GetCharacter() : NULL;
			if (!tch)
			{
				lua_pushnumber(L, 0);
				return 0;
			}
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		return 1;
	}

Add these your questlua_pc.cpp

#include "desc_manager.h"

If you are using r34k, here lua function;

local pc = pc or {}

function pc::disconnect(name)
	if(name == "" or tostring(name) == nil) then
		command("quit")
	else
		local s = pc.select(find_pc_by_name(name))
		command("quit")
		pc.select(s)
	end
end

Best Regards

HaveBeen

  • Love 4

Plain logic saves lives.

  • Bot

If you are using 40k source, here ;

	int pc_disconnect(lua_State* L)
	{
		if (!lua_isstring(L, 1))
		{
			LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(ch->GetName());
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		else
		{
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(lua_tostring(L, 1));
			LPCHARACTER tch = d ? d->GetCharacter() : NULL;
			if (!tch)
			{
				lua_pushnumber(L, 0);
				return 0;
			}
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		return 1;
	}

Add these your questlua_pc.cpp

#include "desc_manager.h"

If you are using r34k, here lua function;

local pc = pc or {}

function pc::disconnect(name)
	if(name == "" or tostring(name) == nil) then
		command("quit")
	else
		local s = pc.select(find_pc_by_name(name))
		command("quit")
		pc.select(s)
	end
end

Best Regards

HaveBeen

Thx, but i'm using the 2089 game files.

english_banner.gif

  • Solution

 

If you are using 40k source, here ;

	int pc_disconnect(lua_State* L)
	{
		if (!lua_isstring(L, 1))
		{
			LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(ch->GetName());
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		else
		{
			LPDESC d = DESC_MANAGER::instance().FindByCharacterName(lua_tostring(L, 1));
			LPCHARACTER tch = d ? d->GetCharacter() : NULL;
			if (!tch)
			{
				lua_pushnumber(L, 0);
				return 0;
			}
			DESC_MANAGER::instance().DestroyDesc(d);
		}
		return 1;
	}

Add these your questlua_pc.cpp

#include "desc_manager.h"

If you are using r34k, here lua function;

local pc = pc or {}

function pc::disconnect(name)
	if(name == "" or tostring(name) == nil) then
		command("quit")
	else
		local s = pc.select(find_pc_by_name(name))
		command("quit")
		pc.select(s)
	end
end

Best Regards

HaveBeen

Thx, but i'm using the 2089 game files.

 

 

 

lua function supported all versions.

 

Best Regards

HaveBeen

  • Love 2

Plain logic saves lives.

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.