mirror of
https://github.com/etlegacy/etlegacy-lua-scripts.git
synced 2024-11-29 23:52:05 +00:00
ladm: fixed include paths
This commit is contained in:
parent
70048556a2
commit
479790af13
2 changed files with 14 additions and 8 deletions
|
@ -3,13 +3,13 @@ env = {} -- environment object
|
||||||
con = {} -- database connection
|
con = {} -- database connection
|
||||||
cur = {} -- cursor
|
cur = {} -- cursor
|
||||||
|
|
||||||
dofile("legacy/ladm/ladm.cfg")
|
dofile("./" .. et.trap_Cvar_Get("fs_game") .. "/ladm/ladm.cfg")
|
||||||
|
|
||||||
-- 1) load the chosen driver
|
-- 1) load the chosen driver
|
||||||
-- 2) create environement object
|
-- 2) create environement object
|
||||||
-- 3) connect to database
|
-- 3) connect to database
|
||||||
function db_init ( )
|
function db_init ( )
|
||||||
print ( "Connecting to " .. dbdriver .. " database..." )
|
et.G_Print ( "Connecting to " .. dbdriver .. " database..." )
|
||||||
|
|
||||||
if ( dbdriver == "mysql" ) then
|
if ( dbdriver == "mysql" ) then
|
||||||
luasql = require "luasql.mysql"
|
luasql = require "luasql.mysql"
|
||||||
|
@ -19,6 +19,10 @@ function db_init ( )
|
||||||
luasql = require "luasql.sqlite3"
|
luasql = require "luasql.sqlite3"
|
||||||
env = assert ( luasql.sqlite3() )
|
env = assert ( luasql.sqlite3() )
|
||||||
con = assert ( env:connect( dbdatabase .. ".sqlite" ) )
|
con = assert ( env:connect( dbdatabase .. ".sqlite" ) )
|
||||||
|
--elseif ( dbdriver == "postgres") then
|
||||||
|
-- luasql = require "luasql.postgres"
|
||||||
|
-- env = assert ( luasql.postgres() )
|
||||||
|
-- con = assert ( env:connect( dbdatabase, ... ) )
|
||||||
else
|
else
|
||||||
print ( "Unsupported database driver. Please set either mysql or sqlite in the config file." )
|
print ( "Unsupported database driver. Please set either mysql or sqlite in the config file." )
|
||||||
return
|
return
|
||||||
|
@ -27,10 +31,10 @@ function db_init ( )
|
||||||
if not installed then db_create() end
|
if not installed then db_create() end
|
||||||
|
|
||||||
cur = assert ( con:execute ( string.format ( "SELECT COUNT(*) FROM %susers", dbprefix ) ) )
|
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 ) ) )
|
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
|
end
|
||||||
|
|
||||||
-- database helper function
|
-- database helper function
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
Description: lightweight user administration suite
|
Description: lightweight user administration suite
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
package.path = "./" .. et.trap_Cvar_Get("fs_game") .. "/ladm/?.lua;" .. package.path
|
||||||
|
|
||||||
-- load the config file
|
-- load the config file
|
||||||
dofile "ladm.cfg"
|
dofile "ladm.cfg"
|
||||||
|
|
||||||
require "ladm/core/db"
|
require "core/db"
|
||||||
require "ladm/core/user"
|
require "core/user"
|
||||||
require "ladm/core/commands"
|
require "core/commands"
|
||||||
|
|
||||||
function et_InitGame(levelTime, randomSeed, restart)
|
function et_InitGame(levelTime, randomSeed, restart)
|
||||||
-- name of this module
|
-- name of this module
|
||||||
|
@ -54,7 +56,7 @@ function et_ClientBegin(cno)
|
||||||
if not player then
|
if not player then
|
||||||
-- First time we see this player
|
-- First time we see this player
|
||||||
et.trap_SendServerCommand (cno, "cpm \"" .. "Welcome, " .. name .. "^7! You are playing on an XP save server.\n\"")
|
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
|
else
|
||||||
et.trap_SendServerCommand (cno, "cpm \"" .. "Welcome back, " .. name .. "^7! Your last connection was on " .. player.last_seen .. "\n\"") -- in db: player.name
|
et.trap_SendServerCommand (cno, "cpm \"" .. "Welcome back, " .. name .. "^7! Your last connection was on " .. player.last_seen .. "\n\"") -- in db: player.name
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue