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

xbx3.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...