BarJuice
Zyloria Owner
I wont post the exact script i use for my server, but i figured a tutorial was in order for the same type of script that i needed.
Global values in global.lua are always resetted when server is started back up. I didnt know where i could store a value at so i decided to use sql lua scripting to access my data base and set and get values in it to make my script work.
First things first.
Create a table in your database called server_storage and give it to fields (key,value) both int, length is your choice.
Next.
To access the values using lua you would need to write this
To set new values:
Due to my scripting abilities i didnt know how to change an sql field but i did know how to delete and create, if anyone knows and can help out would they please let me know how to change the field. To set new values you need to write this:
Not a great tutorial, but im sure it will teach someone something
Global values in global.lua are always resetted when server is started back up. I didnt know where i could store a value at so i decided to use sql lua scripting to access my data base and set and get values in it to make my script work.
First things first.
Create a table in your database called server_storage and give it to fields (key,value) both int, length is your choice.
Next.
To access the values using lua you would need to write this
Code:
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
bla = 1000 --the storage key your looking up
local cur = assert(con:execute("SELECT `key`, `value` FROM `server_storage` WHERE `key` = '" .. bla .. "';"))
local row = cur:fetch({}, "a")
cur:close()
owner = row.value
To set new values:
Due to my scripting abilities i didnt know how to change an sql field but i did know how to delete and create, if anyone knows and can help out would they please let me know how to change the field. To set new values you need to write this:
Code:
value = 1000
assert(con:execute("DELETE FROM `server_storage` WHERE `key` = " .. bla .. ";"))
assert(con:execute("INSERT INTO `server_storage` (`key`, `value`) VALUES (" .. bla .. ", " .. value .. ");"))
Not a great tutorial, but im sure it will teach someone something
Last edited: