Okay I've gotten to the point I had to look at darkrp gamemode and try and figure out how to connect to MySQL and view/write query's.
So upon my digging I found this:
[lua]
CS_MySQLConfig = {}
CS_MySQLConfig.Host = "host" -- Hostname
CS_MySQLConfig.Username = "user" -- This is the username to log in on the MySQL
CS_MySQLConfig.Password = "pass" -- Password to MySQL
CS_MySQLConfig.Database_name = "database" -- Name of the DB file
CS_MySQLConfig.Database_port = 3306 -- Port
--Obviously changed the names
[/lua]
Now I also found this (which is basically making the query's if they dont exist and then setting things to them, which is want im trying to do)
[lua]
function CreditShop.initDatabase()
MySQLite.begin()
local AUTOINCREMENT = MySQLite.isMySQL() and "AUTO_INCREMENT" or "AUTOINCREMENT"
-- Player information
MySQLite.query([[
CREATE TABLE IF NOT EXISTS creditshop_player(
uid BIGINT NOT NULL PRIMARY KEY,
credamt INTEGER NOT NULL,
);
]])
if MySQLite.isMySQL() then
for k,v in pairs(player.GetAll()) do
CreditShop.offlinePlayerData(v:SteamID(), function(data)
if not data or not data[1] then return end
local Data = data[1]
v:setCreditShopVar("credits", Data.credamt)
end)
end
end
hook.Call("CreditShopDBInitialized")
end
[/lua]
Now I have no idea what I'm doing with this (MySQL) and I would like to know if this should work the way I want it to. (Use MySQL to create and read the tables). Also where I have
[lua]
v:setCreditShopVar("credits", Data.credamt)
[/lua]
Does that mean calling "credits" would be using your credamt set in the data base, and anything I do to "credits" will effect credamt?
Again I'm extremely lost. If you could help me out that would be mean alot. Tell me if its not going to work and explain why. If it will work, explain how it will.
Thanks in Advance :)
Sorry, you need to Log In to post a reply to this thread.