Jump to content
Sign in to follow this  
Ximboliex

[RELEASE]GM Security - LuaSQL

Recommended Posts

print( "Loading GMSecurity By _ximboliex" )


function CheckIsvalidGM(role)

	local GMName 	= GetChaDefaultName(role)
	if(GetChaGMLv(role) == 99) and GMName == "[GM]Ximboliex" then
		return 1
	else
		return 0
	end	
end

function SecureGMAccount(role,freq,time)
	if (CheckIsvalidGM(role) == false) then
		local ChaName = GetChaDefaultName(role)
		local ChaID = GetChaID2(role)
		GMNotice("Unauthorized access by "..ChaName.." has been denied. will Banned!!")
		LG("Hacker", "Kicked Out "..ChaID.."", "\n")
		Ban(role,1)
	end
end
Hook:AddPostHook("cha_timer",SecureGMAccount)


function GetChaGMLv(Player)
    local Name = GetChaDefaultName(Player)
    local String = "SELECT gm FROM GameDB.dbo.account WHERE act_id IN (SELECT act_id FROM GameDB.dbo.character WHERE cha_name = '"..Name.."')"
    local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
    if Connect == SQL_SUCCESS_WITH_INFO then
        local Success, Query = LuaSQL("query", ConnectID, String)
        if Success == SQL_SUCCESS_WITH_INFO then
            local Data = LuaSQL("fetch", ConnectID, Query)
            LuaSQL("freehandle", ConnectID, Query)
            LuaSQL("close", ConnectID)
            return Data["gm"]
        end
    end
end


function Ban(Player,banned)--1 - banned /   0 - unbanned 
	local AccountName = GetActName(Player)
	local String = "UPDATE AccountServer.dbo.account_login SET ban = "..banned.." WHERE name = '"..AccountName.."'" 
	local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			local Data = LuaSQL("fetch", ConnectID, Query)
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
		 	KickUser(cha)
		end
	end
end

function KickUser(cha)
	local pkt = GetPacket()
	WriteCmd(pkt,1505)
	SendPacket(cha,pkt)
end

1- Need run hook and Gameserver.exe whit LuaSql

2- Make a new file whit extension .lua you can call like you want

3- add this "dofile(GetResPath("script\\extension\name of your file.lua"))" inside skilleffect.lua

 

Enjoy :) !

 

Note: I use 2.4 DB can change in 1.x in line gm in 1.x iguess is gm_lv 

Edited by Ximboliex
Satan scolded me :(
  • Like 1

Share this post


Link to post
Share on other sites

You should explain what it does, how to use and requirements if it's you who made. How do a newbie will understand it? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×