ladm: fixed include paths

This commit is contained in:
Radegast 2014-02-12 20:22:31 +00:00
parent 70048556a2
commit 479790af13
2 changed files with 14 additions and 8 deletions

View file

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

View file

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