Jump to content
Xeon

LuaSQL (DLL)

Recommended Posts

 

Hi @Wrexor :smile:

I can work whit this sytax?

 

LuaSQL("UPDATE NathDB.dbo.account SET i_m_p_s = i_m_p_s + "..crystal.." WHERE act_name = '"..accountName.."'")
Edited by Ximboliex

xbx3.png

Share this post


Link to post
Share on other sites
On 1/19/2017 at 2:30 AM, Angelix said:

@Wrexor that helped a lot! I didn't quite understand KONG's explanation and I though the functions only returned one value, that's where I was wrong since I didn't quite get the return of two values. Now with that and your help, I was able to get my account name. :P

 


function GetAccountName()
	print("--------------------------------------------------")
	local String = "SELECT act_name FROM GameDB.dbo.account WHERE act_id IN (SELECT act_id FROM GameDB.dbo.character WHERE cha_name = 'Angelix')"
	local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		print("Successful connection.")
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			print("Successful query.")
			local Data = LuaSQL("fetch", ConnectID, Query)
			print("Account Name = "..Data["act_name"])
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
			return
		end
	end
	print("--------------------------------------------------")
end
GetAccountName()

Which for testing purposes resulted this on GS console. :P

Capture.PNG

 

Thanks a lot on both of you for the explanations and Vector since I got the query command from him on another thread since I have zero knowledge of SQL, hahah.

@Ximboliex check this

 

  • Like 1

Share this post


Link to post
Share on other sites
On 10/12/2016 at 10:08 PM, Wrexor said:

In link below there is an updated version of LuaSQL which should include all required files and its also registering lua functions automatically so after you compile or just copy already compiled dll just follow attaching guide in the first post on this topic.

If you want to compile yourself be sure to select correct configuration depending on your server version, currently only 1.36 and 1.38 are supported.

If someone wants a different version send me a pm.

https://www.dropbox.com/s/3byhodvw2z26ef8/LuaSQL2.rar?dl=0

1.36 DLL is bug, it wont register lua functions, it only loads the dll on top of gameserver.. ( tried it in clean and custom gameservers 1.36 )
1.38 works fine and registers lua functions..

could you check the 1.36 one?

Share this post


Link to post
Share on other sites
On 7/15/2016 at 9:14 AM, GustavoHMA said:

1) If you do not use the MSSQL 2000 when inserting the host using double backslashes.

 

Example:


local host = 'PCNAME-PC\\SQLEXPRESS'

 

2) The paths of LuaSQL and ExecuteQueryAsync functions are not sufficient to add the functions to be performed on Lua files.


PushPatch(&LuaSql, (PBYTE)0x5A5FD2);
PushPatch(&ExecuteQueryAsync, (PBYTE)0x5A5EFE);

 

does the second statement should be use in the LuaSQL ? from my undestanding, I should connect first and prompt the second command so that i can query my function afterward? is that the correct step or its not ?

Share this post


Link to post
Share on other sites
On 1/19/2017 at 9:30 AM, Angelix said:

@Wrexor that helped a lot! I didn't quite understand KONG's explanation and I though the functions only returned one value, that's where I was wrong since I didn't quite get the return of two values. Now with that and your help, I was able to get my account name. :P

 


function GetAccountName()
	print("--------------------------------------------------")
	local String = "SELECT act_name FROM GameDB.dbo.account WHERE act_id IN (SELECT act_id FROM GameDB.dbo.character WHERE cha_name = 'Angelix')"
	local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		print("Successful connection.")
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			print("Successful query.")
			local Data = LuaSQL("fetch", ConnectID, Query)
			print("Account Name = "..Data["act_name"])
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
			return
		end
	end
	print("--------------------------------------------------")
end
GetAccountName()

Which for testing purposes resulted this on GS console. :P

Capture.PNG

 

Thanks a lot on both of you for the explanations and Vector since I got the query command from him on another thread since I have zero knowledge of SQL, hahah.

Forgot to ask, where do u put this function to get a print out in GS console?

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.


×
×
  • Create New...