From 479790af13718ad970f0a8da1657d105c5208ecc Mon Sep 17 00:00:00 2001 From: Radegast Date: Wed, 12 Feb 2014 20:22:31 +0000 Subject: [PATCH] ladm: fixed include paths --- ladm/core/db.lua | 12 ++++++++---- ladm/ladm.lua | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ladm/core/db.lua b/ladm/core/db.lua index 396efff..3d7e7b4 100644 --- a/ladm/core/db.lua +++ b/ladm/core/db.lua @@ -3,13 +3,13 @@ env = {} -- environment object con = {} -- database connection cur = {} -- cursor -dofile("legacy/ladm/ladm.cfg") +dofile("./" .. et.trap_Cvar_Get("fs_game") .. "/ladm/ladm.cfg") -- 1) load the chosen driver -- 2) create environement object -- 3) connect to database function db_init ( ) - print ( "Connecting to " .. dbdriver .. " database..." ) + et.G_Print ( "Connecting to " .. dbdriver .. " database..." ) if ( dbdriver == "mysql" ) then luasql = require "luasql.mysql" @@ -19,6 +19,10 @@ function db_init ( ) luasql = require "luasql.sqlite3" env = assert ( luasql.sqlite3() ) con = assert ( env:connect( dbdatabase .. ".sqlite" ) ) + --elseif ( dbdriver == "postgres") then + -- luasql = require "luasql.postgres" + -- env = assert ( luasql.postgres() ) + -- con = assert ( env:connect( dbdatabase, ... ) ) else print ( "Unsupported database driver. Please set either mysql or sqlite in the config file." ) return @@ -27,10 +31,10 @@ function db_init ( ) if not installed then db_create() end cur = assert ( con:execute ( string.format ( "SELECT COUNT(*) FROM %susers", dbprefix ) ) ) - print("There are " .. tonumber(cur:fetch(row, 'a')) .. " users in the database.\n") + et.G_Print("There are " .. tonumber(cur:fetch(row, 'a')) .. " users in the database.\n") cur = assert ( con:execute ( string.format ( "SELECT COUNT(*) FROM %svariables", dbprefix ) ) ) - print("There are " .. tonumber(cur:fetch(row, 'a')) .. " variables in the database.\n") + et.G_Print("There are " .. tonumber(cur:fetch(row, 'a')) .. " variables in the database.\n") end -- database helper function diff --git a/ladm/ladm.lua b/ladm/ladm.lua index 8d1ecd8..faadbb3 100755 --- a/ladm/ladm.lua +++ b/ladm/ladm.lua @@ -9,12 +9,14 @@ Description: lightweight user administration suite ]]-- +package.path = "./" .. et.trap_Cvar_Get("fs_game") .. "/ladm/?.lua;" .. package.path + -- load the config file dofile "ladm.cfg" -require "ladm/core/db" -require "ladm/core/user" -require "ladm/core/commands" +require "core/db" +require "core/user" +require "core/commands" function et_InitGame(levelTime, randomSeed, restart) -- name of this module @@ -54,7 +56,7 @@ function et_ClientBegin(cno) if not player then -- First time we see this player et.trap_SendServerCommand (cno, "cpm \"" .. "Welcome, " .. name .. "^7! You are playing on an XP save server.\n\"") - cur = assert (con:execute(string.format("INSERT INTO %susers VALUES ('%s', '%s', '%s', 0, 0, 0, 0, 0, 0, 0)", dbprefix, guid, os.date("%Y-%m-%d %H:%M:%S"), os.date("%Y-%m-%d %H:%M:%S")))) + cur = assert (con:execute(string.format("INSERT INTO %susers VALUES ('%s', '%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0)", dbprefix, guid, os.date("%Y-%m-%d %H:%M:%S"), os.date("%Y-%m-%d %H:%M:%S")))) else et.trap_SendServerCommand (cno, "cpm \"" .. "Welcome back, " .. name .. "^7! Your last connection was on " .. player.last_seen .. "\n\"") -- in db: player.name