Jump to content
Sign in to follow this  
kyleflow

Issues with LuaSQL.dll

Recommended Posts

Hello @kyleflow,

 

this only shows that LuaSQL.dll is attached to the process. It is impossible to understand if the library is loaded properly.


Share this post


Link to post
Share on other sites

Every time I try to call the injected LuaSQL.dll in GS, it return a nil value. I tried all the guide script in the forum but none able to work. If its not an issue, can anyone gave their working 1.36 GS with loaded dll and their lua function to call for imp

Share this post


Link to post
Share on other sites

I see you found a prior help topic at 

and stated that you did not understand the advanced discussion. Which parts of the discussion specifically did you not understand?

 

Also, could you be more specific about what exactly you have tried so that we might help find where the process has gone wrong please? e.g.:

Are you getting "DLL Loaded" at the top of the GameServer console?

What GameServer version / specific GameServer are you trying to inject it to?

Are you using the original downloaded from the LuaSQL thread, or are you using the subsequent update that was posted?

And any other information about what you've tried that may be useful.

Share this post


Link to post
Share on other sites
8 hours ago, Jonathan said:

I see you found a prior help topic at 

and stated that you did not understand the advanced discussion. Which parts of the discussion specifically did you not understand?

 

Also, could you be more specific about what exactly you have tried so that we might help find where the process has gone wrong please? e.g.:

Are you getting "DLL Loaded" at the top of the GameServer console?

What GameServer version / specific GameServer are you trying to inject it to?

Are you using the original downloaded from the LuaSQL thread, or are you using the subsequent update that was posted?

And any other information about what you've tried that may be useful.

1.  Yes I got a loaded prompt in GS console.

 

2. I'm using the later version with 1.36 and 1.38 in the zip files. I use 1.36 since my server files is 1.36.

 

3. Using all the LuaSQL.lua script found especially shared by Angelix, and few other posting and every and each time it return a nil value.

 

 

Share this post


Link to post
Share on other sites
1 hour ago, kyleflow said:

1.  Yes I got a loaded prompt in GS console.

 

2. I'm using the later version with 1.36 and 1.38 in the zip files. I use 1.36 since my server files is 1.36.

 

3. Using all the LuaSQL.lua script found especially shared by Angelix, and few other posting and every and each time it return a nil value.

 

 

sqlua for 136 is bug. it doesnt work . the ones for 138 its okey.

  • Sad 1

Share this post


Link to post
Share on other sites
8 hours ago, squaller said:

sqlua for 136 is bug. it doesnt work . the ones for 138 its okey.

did try both luasql and did use the same script.. return the same problem

 

-- ***********************************
-- Sample Lua-SQL System
-- Requires: SQL Server 2005
-- By Sultan | V3ct0r
-- ***********************************
local PLUGIN_NAME = '[[LUA-SQL System]]'
local PLUGIN_VERSION = '0.2'
local PLUGIN_AUTHOR = 'Sultan | V3ct0r'

--[[
	******************
	** Version: 0.2 **
	******************
	[*] Slightly faster and less lag on execution
	[*] Edited LuaSQL.LG function to generate new files instead of editing Query.txt
	[*] Added LuaSQL.LG for every sample function to trace players inside new file Logs.txt
	[*] Removed/Edited few unneccessary stuffs from V0.1
	
	
	******************
	** Version: 0.1 **
	******************
	[*] Use SQL Query directly using your scripts!
	[*] Built in the extension, there are few sample SQL Queries: AddMallPoints, AddCreditsPoints, ChangePlayerName, and more!
	[*] Requires GetPlayerByName if used by &lua command
	[*] Built in the extension the GetPlayerByName function, if it isn't exists in your files it will add it
	[*] You can freely add any SQL Query Execute function you wish for
	[*] This system will only generate UPDATES to SQL, you cannot "GET" any data from SQL
	[*] Requires SQL 2005 and above to use
	[*] For more information & details: http://forum.maindev.ru/threads/npc-dlja-nadoedalok-skajpa.19514/#post-159439
]]--

-- --------------------------
-- Display loading message on startup
-- --------------------------
print(">> Loading extension: "..PLUGIN_NAME)
print("	[Version: "..PLUGIN_VERSION.."] from "..PLUGIN_AUTHOR)

-- ------------------------
-- LUA-SQL ::DO NOT TOUCH::
-- ------------------------
do
	LuaSQL = {}
	LuaSQL.Directory = GetResPath('script\\extension\\Lua-SQL\\');
	LuaSQL.Host = "(local)";
	LuaSQL.User = "sa";
	LuaSQL.Pass = "Y87dc#$98";

	LuaSQL.LG = function(file_name,text)
		local file = LuaSQL.Directory..file_name..'.txt'
		LogFile = io.open(file,'a')
		LogFile:write("["..os.date().."]\t"..text.."\n")
		LogFile:close()
	end

	LuaSQL.Execute = function(query)
		LuaSQL.LG('Query','Executed Query: ['..query..']');
		os.execute("sqlcmd -S "..LuaSQL.Host.." -U "..LuaSQL.User.." -P "..LuaSQL.Pass.." -Q \""..query.."\" 1>NUL 2>NUL");
	end
	
	-- if GetPlayerByName is nil, it will generate
	if(GetPlayerByName == nil)then
		Roles = {}
		
		Timer = cha_timer
		cha_timer = function(r,f,t)
			if(IsPlayer(r) == 1)then
				local characterName = GetChaDefaultName(r)
				if(Roles[characterName] == nil)then
					Roles[characterName] = r
				end
			end
			Timer(r,f,t)
		end
		
		GetPlayerByName = function(name)
			if(Roles[name] ~= nil)then
				return Roles[name]
			end
			return nil
		end
	end
end

-- ------------------------
-- LUA-SQL Functions
-- ------------------------

--[[
	*****************************
	** Sample Custom Functions **
	*****************************
	[*]: AddMallPoints(cha,points) => Requires Userdata to grant Mall Points
	[*]: AddCreditsPoints(cha,points) => Requires Userdata to grant Credits
	[*]: ChangePlayerName(cha,newName) => Requires Userdata to change players name
	[*]: ChangeGuildName(guildID,newName) => Requires Guild ID to change guild name
	[*]: Ban(cha) => Will ban character by Userdata
	[*]: UnBan(account Name) => Will unban character by account
	
	P/S: You can add yours, just use one of samples below and create your own.
	
	@FAQ [How To Use]:
	
	Example:
	&lua AddMallPoints("Player Name",1000)
	&lua ChangeGuildName(1,"New Guild Name")
	&lua Ban("Account Name")
]]--

function AddMallPoints(cha,points)
	if(type(cha) ~= 'userdata')then
		cha = GetPlayerByName(cha)
	end
	if(cha ~= nil)then
		local accountName = GetActName(cha)
		LuaSQL.Execute("UPDATE tradedb.dbo.AccountInfo SET Money = Money + "..points.." WHERE accName = '"..accountName.."'")
		LuaSQL.LG('Logs','[AddMallPoints] = Account name['..accountName..'] successfully added '..points..' mall points');
	end
end

function AddCreditsPoints(cha,points)
	if(type(cha) ~= 'userdata')then
		cha = GetPlayerByName(cha)
	end
	if(cha ~= nil)then
		local accountName = GetActName(cha)
		LuaSQL.Execute("UPDATE GameDB.dbo.account SET credits = credits + "..points.." WHERE act_name = '"..accountName.."'")
		LuaSQL.LG('Logs','[AddCreditsPoints] = Account name['..accountName..'] successfully added '..points..' credits');
	end
end

function ChangePlayerName(cha,newName)
	if(type(cha) ~= 'userdata')then
		cha = GetPlayerByName(cha)
	end
	if(cha ~= nil)then
		local characterName,characterID = GetChaDefaultName(cha),GetCharID(cha)
		LuaSQL.Execute("UPDATE GameDB.dbo.character SET cha_name = '"..newName.."' WHERE cha_id = '"..characterID.."'")
		LuaSQL.LG('Logs','[ChangePlayerName] = Character name['..characterName..'] with ID['..characterID..'] successfully changed name to ['..newName..']');
	end
end

function ChangeGuildName(guildID,newName)
	LuaSQL.Execute("UPDATE GameDB.dbo.guild SET guild_name = '"..newName.."' WHERE guild_id = '"..guildID.."'")
	LuaSQL.LG('Logs','[ChangeGuildName] = Guild Name['..GetGuildName(guildID)..'] with ID['..guildID..'] successfully changed name to ['..newName..']');
end
	
function Ban(cha)
	if(type(cha) ~= 'userdata')then
		cha = GetPlayerByName(cha)
	end
	if(cha ~= nil)then
		local accountName = GetActName(cha)
		LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'True' WHERE name = '"..accountName.."'")
		LuaSQL.LG('Logs','[Ban] = Account name['..accountName..'] was successfully banned');

		-- kick cha
		local pkt = GetPacket()
		WriteCmd(pkt,1505)
		SendPacket(cha,pkt)
	end
end

function UnBan(accountName)
	LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'False' WHERE name = '"..accountName.."'")
	LuaSQL.LG('Logs','[UnBan] = Account name['..accountName..'] was successfully banned');
end

This one is from vector and I change the database location and it able to connect with luasql.dll and i'm able to use the function to insert imp with GM account.

 

So the question now, how do i made a function based on above connection setting for IMP card or Killing mobs and get imps ? I tried cross reference it with existing script in forum but after few tries. still fail.

Edited by kyleflow
found a working script with minor change into database info

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...