mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2025-04-16 13:51:59 +00:00
Database function naming consistency
This commit is contained in:
parent
815af34004
commit
2298864acf
17 changed files with 125 additions and 125 deletions
|
@ -36,11 +36,11 @@ function admin.kickPlayer(victimId, invokerId, reason)
|
|||
end
|
||||
|
||||
function admin.setPlayerLevel(clientId, level, invokerId)
|
||||
local playerId = db.getplayer(players.getGUID(clientId))["id"]
|
||||
local invokerPlayerId = db.getplayer(players.getGUID(invokerId))["id"]
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
db.updateplayerlevel(playerId, level)
|
||||
db.addsetlevel(playerId, level, invokerPlayerId, os.time())
|
||||
db.updatePlayerLevel(playerId, level)
|
||||
db.addSetLevel(playerId, level, invokerPlayerId, os.time())
|
||||
end
|
||||
|
||||
function admin.onClientConnectAttempt(clientId, firstTime, isBot)
|
||||
|
@ -51,7 +51,7 @@ function admin.onClientConnectAttempt(clientId, firstTime, isBot)
|
|||
return "\n\nIt appears you do not have a ^7GUID^9/^7etkey^9. In order to play on this server, enable ^7PunkBuster ^9(use ^7\\pb_cl_enable^9) ^9and/or create an ^7etkey^9.\n\nMore info: ^7www.etkey.org"
|
||||
end
|
||||
|
||||
local player = db.getplayer(guid)
|
||||
local player = db.getPlayer(guid)
|
||||
if player then
|
||||
local playerId = player["id"]
|
||||
local ban = db.getBanByPlayer(playerId)
|
||||
|
@ -67,7 +67,7 @@ events.handle("onClientConnectAttempt", admin.onClientConnectAttempt)
|
|||
|
||||
function admin.onClientConnect(clientId, firstTime, isBot)
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
local player = db.getplayer(guid)
|
||||
local player = db.getPlayer(guid)
|
||||
|
||||
if player then
|
||||
local playerId = player["id"]
|
||||
|
@ -116,14 +116,14 @@ function admin.onClientNameChange(clientId, oldName, newName)
|
|||
end
|
||||
|
||||
-- update database
|
||||
if db.isconnected() then
|
||||
local playerId = db.getplayer(players.getGUID(clientId))["id"]
|
||||
local alias = db.getaliasbyname(playerId, newName)
|
||||
if db.isConnected() then
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
local alias = db.getAliasByName(playerId, newName)
|
||||
|
||||
if alias then
|
||||
db.updatealias(alias["id"], os.time())
|
||||
db.updateAlias(alias["id"], os.time())
|
||||
else
|
||||
db.addalias(playerId, newName, os.time())
|
||||
db.addAlias(playerId, newName, os.time())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,8 +34,8 @@ function bans.getList(start, limit)
|
|||
end
|
||||
|
||||
function bans.add(victimId, invokerId, duration, reason)
|
||||
local victimPlayerId = db.getplayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getplayer(players.getGUID(invokerId))["id"]
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
local reason = reason and reason or "banned by admin"
|
||||
|
||||
|
|
|
@ -26,20 +26,20 @@ function history.get(clientId, historyId)
|
|||
end
|
||||
|
||||
function history.getCount(clientId)
|
||||
local playerId = db.getplayer(players.getGUID(clientId))["id"]
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
|
||||
return db.getHistoryCount(playerId)
|
||||
end
|
||||
|
||||
function history.getList(clientId, start, limit)
|
||||
local playerId = db.getplayer(players.getGUID(clientId))["id"]
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
|
||||
return db.getHistory(playerId, start, limit)
|
||||
end
|
||||
|
||||
function history.add(victimId, invokerId, type, reason)
|
||||
local victimPlayerId = db.getplayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getplayer(players.getGUID(invokerId))["id"]
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
db.addHistory(victimPlayerId, invokerPlayerId, type, os.time(), reason)
|
||||
end
|
||||
|
|
|
@ -39,8 +39,8 @@ function mutes.getList(start, limit)
|
|||
end
|
||||
|
||||
function mutes.add(victimId, invokerId, type, duration, reason)
|
||||
local victimPlayerId = db.getplayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getplayer(players.getGUID(invokerId))["id"]
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
local reason = reason and reason or "muted by admin"
|
||||
|
||||
|
@ -56,7 +56,7 @@ function mutes.removeByClient(clientId)
|
|||
players.setMuted(clientId, false)
|
||||
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
local playerId = db.getplayer(guid)["id"]
|
||||
local playerId = db.getPlayer(guid)["id"]
|
||||
local mute = db.getMuteByPlayer(playerId)
|
||||
|
||||
if mute then
|
||||
|
|
|
@ -115,7 +115,7 @@ function acl.removeLevelRoles(levelId)
|
|||
end
|
||||
|
||||
function acl.getPlayerLevel(clientId)
|
||||
local player = db.getplayer(players.getGUID(clientId))
|
||||
local player = db.getPlayer(players.getGUID(clientId))
|
||||
|
||||
return player["level_id"]
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ local util = require (wolfa_getLuaPath()..".util.util")
|
|||
function commandListAliases(clientId, command, victim, offset)
|
||||
local cmdClient
|
||||
|
||||
if not db.isconnected() then
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^9alias history is disabled.\";")
|
||||
|
||||
return true
|
||||
|
@ -63,11 +63,11 @@ function commandListAliases(clientId, command, victim, offset)
|
|||
return true
|
||||
end
|
||||
|
||||
local player = db.getplayer(players.getGUID(cmdClient))["id"]
|
||||
local player = db.getPlayer(players.getGUID(cmdClient))["id"]
|
||||
|
||||
local count = db.getaliasescount(player)
|
||||
local count = db.getAliasesCount(player)
|
||||
local limit, offset = pagination.calculate(count, 30, tonumber(offset))
|
||||
local aliases = db.getaliases(player, limit, offset)
|
||||
local aliases = db.getAliases(player, limit, offset)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dAliases for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, alias in pairs(aliases) do
|
||||
|
|
|
@ -65,7 +65,7 @@ function commandListLevels(clientId, command, victim, offset)
|
|||
|
||||
return true
|
||||
end
|
||||
elseif not db.isconnected() then
|
||||
elseif not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9level history is disabled.\";")
|
||||
|
||||
return true
|
||||
|
@ -85,18 +85,18 @@ function commandListLevels(clientId, command, victim, offset)
|
|||
return true
|
||||
end
|
||||
|
||||
local player = db.getplayer(players.getGUID(cmdClient))["id"]
|
||||
local player = db.getPlayer(players.getGUID(cmdClient))["id"]
|
||||
|
||||
local count = db.getlevelscount(player)
|
||||
local count = db.getLevelsCount(player)
|
||||
local limit, offset = pagination.calculate(count, 30, tonumber(offset))
|
||||
local levels = db.getlevels(player, limit, offset)
|
||||
local levels = db.getLevels(player, limit, offset)
|
||||
|
||||
if not (levels and #levels > 0) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9there are no recorded levels for player ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dLevels for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, level in pairs(levels) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", level["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(level["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", level["datetime"]).." ^7"..level["level_id"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", level["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(level["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", level["datetime"]).." ^7"..level["level_id"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
|
@ -105,4 +105,4 @@ function commandListLevels(clientId, command, victim, offset)
|
|||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("listlevels", commandListLevels, auth.PERM_LISTLEVELS, "display all levels on the server", (not db.isconnected() and nil or "^9(^3name|slot#^9) ^9(^hoffset^9)"))
|
||||
commands.addadmin("listlevels", commandListLevels, auth.PERM_LISTLEVELS, "display all levels on the server", (not db.isConnected() and nil or "^9(^3name|slot#^9) ^9(^hoffset^9)"))
|
||||
|
|
|
@ -27,7 +27,7 @@ local sprees = require (wolfa_getLuaPath()..".game.sprees")
|
|||
local settings = require (wolfa_getLuaPath()..".util.settings")
|
||||
|
||||
function commandResetSprees(clientId, command, map)
|
||||
if not db.isconnected() then
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsprees: ^9spree records are disabled.\";")
|
||||
|
||||
return true
|
||||
|
|
|
@ -28,7 +28,7 @@ local settings = require (wolfa_getLuaPath()..".util.settings")
|
|||
local util = require (wolfa_getLuaPath()..".util.util")
|
||||
|
||||
function commandShowBans(clientId, offset)
|
||||
if not db.isconnected() then
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowbans: ^9bans are disabled.\";")
|
||||
|
||||
return true
|
||||
|
@ -43,7 +43,7 @@ function commandShowBans(clientId, offset)
|
|||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^d"..count.." bans:\";")
|
||||
for _, ban in pairs(bans) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", ban["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(ban["victim_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["issued"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(ban["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["expires"]).." ^7"..ban["reason"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", ban["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(ban["victim_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["issued"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(ban["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["expires"]).." ^7"..ban["reason"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
|
|
|
@ -30,7 +30,7 @@ local settings = require (wolfa_getLuaPath()..".util.settings")
|
|||
function commandListHistory(clientId, command, victim, offset)
|
||||
local cmdClient
|
||||
|
||||
if not db.isconnected() or settings.get("g_playerHistory") == 0 then
|
||||
if not db.isConnected() or settings.get("g_playerHistory") == 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory: ^9player history is disabled.\";")
|
||||
|
||||
return true
|
||||
|
@ -63,7 +63,7 @@ function commandListHistory(clientId, command, victim, offset)
|
|||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHistory for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, history in pairs(playerHistory) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", history["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(history["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", history["datetime"]).." ^7"..string.format("%-8s", history["type"]..":").." "..history["reason"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", history["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(history["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", history["datetime"]).." ^7"..string.format("%-8s", history["type"]..":").." "..history["reason"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
|
|
|
@ -24,7 +24,7 @@ local db = require (wolfa_getLuaPath()..".db.db")
|
|||
local sprees = require (wolfa_getLuaPath()..".game.sprees")
|
||||
|
||||
function commandShowSprees(clientId, command)
|
||||
if not db.isconnected() then
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsprees: ^9spree records are disabled.\";")
|
||||
|
||||
return true
|
||||
|
@ -37,7 +37,7 @@ function commandShowSprees(clientId, command)
|
|||
else
|
||||
for i = 0, sprees.RECORD_NUM - 1 do
|
||||
if records[i] and records[i]["record"] > 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsprees: ^9longest "..sprees.getRecordNameByType(i).." spree (^7"..records[i]["record"].."^9) by ^7"..db.getlastalias(records[i]["player"])["alias"].."^9.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsprees: ^9longest "..sprees.getRecordNameByType(i).." spree (^7"..records[i]["record"].."^9) by ^7"..db.getLastAlias(records[i]["player"])["alias"].."^9.\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ local db = require (wolfa_getLuaPath()..".db.db")
|
|||
local settings = require (wolfa_getLuaPath()..".util.settings")
|
||||
|
||||
function commandRemoveBan(clientId, command, ban)
|
||||
if settings.get("g_standalone") == 0 or not db.isconnected() then
|
||||
if settings.get("g_standalone") == 0 or not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunban: ^9bans are disabled.\";")
|
||||
|
||||
return true
|
||||
|
|
|
@ -30,7 +30,7 @@ local settings = require (wolfa_getLuaPath()..".util.settings")
|
|||
function commandWarn(clientId, command, victim, ...)
|
||||
local cmdClient
|
||||
|
||||
if not db.isconnected() or settings.get("g_playerHistory") == 0 then
|
||||
if not db.isConnected() or settings.get("g_playerHistory") == 0 then
|
||||
return false
|
||||
elseif not victim or not ... then
|
||||
return false
|
||||
|
|
|
@ -30,23 +30,23 @@ local con
|
|||
local cur
|
||||
|
||||
-- players
|
||||
function mysql.addplayer(guid, ip)
|
||||
function mysql.addPlayer(guid, ip)
|
||||
cur = assert(con:execute("INSERT INTO `player` (`guid`, `ip`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."')"))
|
||||
end
|
||||
|
||||
function mysql.updateplayerip(guid, ip)
|
||||
function mysql.updatePlayerIp(guid, ip)
|
||||
cur = assert(con:execute("UPDATE `player` SET `ip`='"..util.escape(ip).."' WHERE `guid`='"..util.escape(guid).."'"))
|
||||
end
|
||||
|
||||
function mysql.updateplayerlevel(id, level)
|
||||
function mysql.updatePlayerLevel(id, level)
|
||||
cur = assert(con:execute("UPDATE `player` SET `level_id`='"..tonumber(level).."' WHERE `id`='"..tonumber(id).."'"))
|
||||
end
|
||||
|
||||
function mysql.getplayerid(clientId)
|
||||
return mysql.getplayer(players.getGUID(clientId))["id"]
|
||||
function mysql.getPlayerId(clientId)
|
||||
return mysql.getPlayer(players.getGUID(clientId))["id"]
|
||||
end
|
||||
|
||||
function mysql.getplayer(guid)
|
||||
function mysql.getPlayer(guid)
|
||||
cur = assert(con:execute("SELECT * FROM `player` WHERE `guid`='"..util.escape(guid).."'"))
|
||||
|
||||
local player = cur:fetch({}, "a")
|
||||
|
@ -56,15 +56,15 @@ function mysql.getplayer(guid)
|
|||
end
|
||||
|
||||
-- levels
|
||||
function mysql.addlevel(id, name)
|
||||
function mysql.addLevel(id, name)
|
||||
cur = assert(con:execute("INSERT INTO `level` (`id`, `name`) VALUES ('"..tonumber(id).."', '"..util.escape(name).."')"))
|
||||
end
|
||||
|
||||
function mysql.updatelevel(id, name)
|
||||
function mysql.updateLevel(id, name)
|
||||
cur = assert(con:execute("UPDATE `level` SET `name`='"..util.escape(name).."' WHERE `id`='"..tonumber(id).."'"))
|
||||
end
|
||||
|
||||
function mysql.getlevel(id)
|
||||
function mysql.getLevel(id)
|
||||
cur = assert(con:execute("SELECT * FROM `level` WHERE `id`='"..tonumber(id).."'"))
|
||||
|
||||
local level = cur:fetch({}, "a")
|
||||
|
@ -74,15 +74,15 @@ function mysql.getlevel(id)
|
|||
end
|
||||
|
||||
-- aliases
|
||||
function mysql.addalias(playerid, alias, lastused)
|
||||
function mysql.addAlias(playerid, alias, lastused)
|
||||
cur = assert(con:execute("INSERT INTO `alias` (`player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES ("..tonumber(playerid)..", '"..util.escape(alias).."', '"..util.escape(util.removeColors(alias)).."', "..tonumber(lastused)..", 1)"))
|
||||
end
|
||||
|
||||
function mysql.updatealias(aliasid, lastused)
|
||||
function mysql.updateAlias(aliasid, lastused)
|
||||
cur = assert(con:execute("UPDATE `alias` SET `lastused`="..tonumber(lastused)..", `used`=`used`+1 WHERE `id`='"..util.escape(aliasid).."'"))
|
||||
end
|
||||
|
||||
function mysql.getaliasescount(playerid)
|
||||
function mysql.getAliasesCount(playerid)
|
||||
cur = assert(con:execute("SELECT COUNT(`id`) AS `count` FROM `alias` WHERE `player_id`="..tonumber(playerid)..""))
|
||||
|
||||
local count = tonumber(cur:fetch({}, "a")["count"])
|
||||
|
@ -91,7 +91,7 @@ function mysql.getaliasescount(playerid)
|
|||
return count
|
||||
end
|
||||
|
||||
function mysql.getaliases(playerid, limit, offset)
|
||||
function mysql.getAliases(playerid, limit, offset)
|
||||
limit = limit or 30
|
||||
offset = offset or 0
|
||||
|
||||
|
@ -110,7 +110,7 @@ function mysql.getaliases(playerid, limit, offset)
|
|||
return aliases
|
||||
end
|
||||
|
||||
function mysql.getaliasbyid(aliasid)
|
||||
function mysql.getAliasById(aliasid)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `id`="..tonumber(aliasid)..""))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -119,7 +119,7 @@ function mysql.getaliasbyid(aliasid)
|
|||
return alias
|
||||
end
|
||||
|
||||
function mysql.getaliasbyname(playerid, aliasname)
|
||||
function mysql.getAliasByName(playerid, aliasname)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." AND `alias`='"..util.escape(aliasname).."'"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -128,7 +128,7 @@ function mysql.getaliasbyname(playerid, aliasname)
|
|||
return alias
|
||||
end
|
||||
|
||||
function mysql.getlastalias(playerid)
|
||||
function mysql.getLastAlias(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -138,11 +138,11 @@ function mysql.getlastalias(playerid)
|
|||
end
|
||||
|
||||
-- level history
|
||||
function mysql.addsetlevel(playerid, level, adminid, datetime)
|
||||
function mysql.addSetLevel(playerid, level, adminid, datetime)
|
||||
cur = assert(con:execute("INSERT INTO `player_level` (`player_id`, `level`, `admin_id`, `datetime`) VALUES ("..tonumber(playerid)..", "..tonumber(level)..", "..tonumber(adminid)..", "..tonumber(datetime)..")"))
|
||||
end
|
||||
|
||||
function mysql.getlevelscount(playerid)
|
||||
function mysql.getLevelsCount(playerid)
|
||||
cur = assert(con:execute("SELECT COUNT(`id`) AS `count` FROM `player_level` WHERE `player_id`="..tonumber(playerid)..""))
|
||||
|
||||
local count = tonumber(cur:fetch({}, "a")["count"])
|
||||
|
@ -151,7 +151,7 @@ function mysql.getlevelscount(playerid)
|
|||
return count
|
||||
end
|
||||
|
||||
function mysql.getlevels(playerid, limit, offset)
|
||||
function mysql.getLevels(playerid, limit, offset)
|
||||
limit = limit or 30
|
||||
offset = offset or 0
|
||||
|
||||
|
@ -171,15 +171,15 @@ function mysql.getlevels(playerid, limit, offset)
|
|||
end
|
||||
|
||||
-- warns
|
||||
function mysql.addwarn(playerid, reason, adminid, datetime)
|
||||
function mysql.addWarn(playerid, reason, adminid, datetime)
|
||||
cur = assert(con:execute("INSERT INTO `warn` (`player_id`, `reason`, `admin_id`, `datetime`) VALUES ("..tonumber(playerid)..", '"..util.escape(reason).."', "..tonumber(adminid)..", "..tonumber(datetime)..")"))
|
||||
end
|
||||
|
||||
function mysql.removewarn(warnid)
|
||||
function mysql.removeWarn(warnid)
|
||||
cur = assert(con:execute("DELETE FROM `warn` WHERE `id`="..tonumber(warnid)..""))
|
||||
end
|
||||
|
||||
function mysql.getwarnscount(playerid)
|
||||
function mysql.getWarnsCount(playerid)
|
||||
cur = assert(con:execute("SELECT COUNT(`id`) AS `count` FROM `warn` WHERE `player_id`="..tonumber(playerid)..""))
|
||||
|
||||
local count = tonumber(cur:fetch({}, "a")["count"])
|
||||
|
@ -188,7 +188,7 @@ function mysql.getwarnscount(playerid)
|
|||
return count
|
||||
end
|
||||
|
||||
function mysql.getwarns(playerid, limit, offset)
|
||||
function mysql.getWarns(playerid, limit, offset)
|
||||
limit = limit or 30
|
||||
offset = offset or 0
|
||||
|
||||
|
@ -207,7 +207,7 @@ function mysql.getwarns(playerid, limit, offset)
|
|||
return warns
|
||||
end
|
||||
|
||||
function mysql.getwarn(warnid)
|
||||
function mysql.getWarn(warnid)
|
||||
cur = assert(con:execute("SELECT * FROM `warn` WHERE `id`="..tonumber(warnid)..""))
|
||||
|
||||
local warn = cur:fetch({}, "a")
|
||||
|
@ -217,15 +217,15 @@ function mysql.getwarn(warnid)
|
|||
end
|
||||
|
||||
-- maps
|
||||
function mysql.addmap(mapname, lastplayed)
|
||||
function mysql.addMap(mapname, lastplayed)
|
||||
cur = assert(con:execute("INSERT INTO `map` (`name`, `lastplayed`) VALUES ('"..util.escape(mapname).."', "..tonumber(lastplayed)..")"))
|
||||
end
|
||||
|
||||
function mysql.updatemap(mapid, lastplayed)
|
||||
function mysql.updateMap(mapid, lastplayed)
|
||||
cur = assert(con:execute("UPDATE `map` SET `lastplayed`="..tonumber(lastplayed).." WHERE `id`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function mysql.getmap(mapname)
|
||||
function mysql.getMap(mapname)
|
||||
cur = assert(con:execute("SELECT * FROM `map` WHERE `name`='"..util.escape(mapname).."'"))
|
||||
|
||||
local map = cur:fetch({}, "a")
|
||||
|
@ -235,23 +235,23 @@ function mysql.getmap(mapname)
|
|||
end
|
||||
|
||||
-- records
|
||||
function mysql.addrecord(mapid, recorddate, recordtype, record, playerid)
|
||||
function mysql.addRecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("INSERT INTO `record` (`map_id`, `date`, `type`, `record`, `player_id`) VALUES ("..tonumber(mapid)..", "..tonumber(recorddate)..", "..tonumber(recordtype)..", "..tonumber(record)..", "..tonumber(playerid)..")"))
|
||||
end
|
||||
|
||||
function mysql.updaterecord(mapid, recorddate, recordtype, record, playerid)
|
||||
function mysql.updateRecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("UPDATE `record` SET `date`="..tonumber(recorddate)..", `record`="..tonumber(record)..", `player_id`="..tonumber(playerid).." WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
end
|
||||
|
||||
function mysql.removeallrecords()
|
||||
function mysql.removeAllRecords()
|
||||
cur = assert(con:execute("TRUNCATE `record`"))
|
||||
end
|
||||
|
||||
function mysql.removerecords(mapid)
|
||||
function mysql.removeRecords(mapid)
|
||||
cur = assert(con:execute("DELETE FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function mysql.getrecords(mapid)
|
||||
function mysql.getRecords(mapid)
|
||||
cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
|
||||
local records = {}
|
||||
|
@ -267,7 +267,7 @@ function mysql.getrecords(mapid)
|
|||
return records
|
||||
end
|
||||
|
||||
function mysql.getrecordscount(mapid)
|
||||
function mysql.getRecordsCount(mapid)
|
||||
cur = assert(con:execute("SELECT COUNT(*) AS `count` FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
|
||||
local count = cur:fetch({}, "a")
|
||||
|
@ -276,7 +276,7 @@ function mysql.getrecordscount(mapid)
|
|||
return count["count"]
|
||||
end
|
||||
|
||||
function mysql.getrecord(mapid, recordtype)
|
||||
function mysql.getRecord(mapid, recordtype)
|
||||
cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
|
||||
local record = cur:fetch({}, "a")
|
||||
|
@ -285,7 +285,7 @@ function mysql.getrecord(mapid, recordtype)
|
|||
return record
|
||||
end
|
||||
|
||||
function mysql.isconnected()
|
||||
function mysql.isConnected()
|
||||
return (con ~= nil)
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ local con
|
|||
local cur
|
||||
|
||||
-- players
|
||||
function sqlite3.addplayer(guid, ip, lastSeen, seen)
|
||||
function sqlite3.addPlayer(guid, ip, lastSeen, seen)
|
||||
cur = assert(con:execute("INSERT INTO `player` (`guid`, `ip`, `level_id`, `lastseen`, `seen`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."', 0, "..tonumber(lastSeen)..", "..tonumber(seen)..")"))
|
||||
end
|
||||
|
||||
|
@ -39,12 +39,12 @@ function sqlite3.updateplayer(guid, ip, lastSeen)
|
|||
cur = assert(con:execute("UPDATE `player` SET `ip`='"..util.escape(ip).."', `lastseen`="..lastSeen..", `seen`=`seen`+1 WHERE `guid`='"..util.escape(guid).."'"))
|
||||
end
|
||||
|
||||
function sqlite3.updateplayerlevel(id, level)
|
||||
function sqlite3.updatePlayerLevel(id, level)
|
||||
cur = assert(con:execute("UPDATE `player` SET `level_id`='"..tonumber(level).."' WHERE `id`='"..tonumber(id).."'"))
|
||||
end
|
||||
|
||||
function sqlite3.getplayerid(clientId)
|
||||
return sqlite3.getplayer(players.getGUID(clientId))["id"]
|
||||
function sqlite3.getPlayerId(clientId)
|
||||
return sqlite3.getPlayer(players.getGUID(clientId))["id"]
|
||||
end
|
||||
|
||||
function sqlite3.getPlayersCount()
|
||||
|
@ -75,7 +75,7 @@ function sqlite3.getPlayers(limit, offset)
|
|||
return players
|
||||
end
|
||||
|
||||
function sqlite3.getplayer(guid)
|
||||
function sqlite3.getPlayer(guid)
|
||||
cur = assert(con:execute("SELECT * FROM `player` WHERE `guid`='"..util.escape(guid).."'"))
|
||||
|
||||
local player = cur:fetch({}, "a")
|
||||
|
@ -176,15 +176,15 @@ function sqlite3.removeLevelRoles(levelId)
|
|||
end
|
||||
|
||||
-- aliases
|
||||
function sqlite3.addalias(playerid, alias, lastused)
|
||||
function sqlite3.addAlias(playerid, alias, lastused)
|
||||
cur = assert(con:execute("INSERT INTO `alias` (`player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES ("..tonumber(playerid)..", '"..util.escape(alias).."', '"..util.escape(util.removeColors(alias)).."', "..tonumber(lastused)..", 1)"))
|
||||
end
|
||||
|
||||
function sqlite3.updatealias(aliasid, lastused)
|
||||
function sqlite3.updateAlias(aliasid, lastused)
|
||||
cur = assert(con:execute("UPDATE `alias` SET `lastused`="..tonumber(lastused)..", `used`=`used`+1 WHERE `id`='"..util.escape(aliasid).."'"))
|
||||
end
|
||||
|
||||
function sqlite3.getaliasescount(playerid)
|
||||
function sqlite3.getAliasesCount(playerid)
|
||||
cur = assert(con:execute("SELECT COUNT(`id`) AS `count` FROM `alias` WHERE `player_id`="..tonumber(playerid)..""))
|
||||
|
||||
local count = tonumber(cur:fetch({}, "a")["count"])
|
||||
|
@ -193,7 +193,7 @@ function sqlite3.getaliasescount(playerid)
|
|||
return count
|
||||
end
|
||||
|
||||
function sqlite3.getaliases(playerid, limit, offset)
|
||||
function sqlite3.getAliases(playerid, limit, offset)
|
||||
limit = limit or 30
|
||||
offset = offset or 0
|
||||
|
||||
|
@ -212,7 +212,7 @@ function sqlite3.getaliases(playerid, limit, offset)
|
|||
return aliases
|
||||
end
|
||||
|
||||
function sqlite3.getaliasbyid(aliasid)
|
||||
function sqlite3.getAliasById(aliasid)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `id`="..tonumber(aliasid)..""))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -221,7 +221,7 @@ function sqlite3.getaliasbyid(aliasid)
|
|||
return alias
|
||||
end
|
||||
|
||||
function sqlite3.getaliasbyname(playerid, aliasname)
|
||||
function sqlite3.getAliasByName(playerid, aliasname)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." AND `alias`='"..util.escape(aliasname).."'"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -230,7 +230,7 @@ function sqlite3.getaliasbyname(playerid, aliasname)
|
|||
return alias
|
||||
end
|
||||
|
||||
function sqlite3.getlastalias(playerid)
|
||||
function sqlite3.getLastAlias(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
|
@ -240,11 +240,11 @@ function sqlite3.getlastalias(playerid)
|
|||
end
|
||||
|
||||
-- level history
|
||||
function sqlite3.addsetlevel(playerid, level, invokerid, datetime)
|
||||
function sqlite3.addSetLevel(playerid, level, invokerid, datetime)
|
||||
cur = assert(con:execute("INSERT INTO `player_level` (`player_id`, `level_id`, `invoker_id`, `datetime`) VALUES ("..tonumber(playerid)..", "..tonumber(level)..", "..tonumber(invokerid)..", "..tonumber(datetime)..")"))
|
||||
end
|
||||
|
||||
function sqlite3.getlevelscount(playerid)
|
||||
function sqlite3.getLevelsCount(playerid)
|
||||
cur = assert(con:execute("SELECT COUNT(`id`) AS `count` FROM `player_level` WHERE `player_id`="..tonumber(playerid)..""))
|
||||
|
||||
local count = tonumber(cur:fetch({}, "a")["count"])
|
||||
|
@ -253,7 +253,7 @@ function sqlite3.getlevelscount(playerid)
|
|||
return count
|
||||
end
|
||||
|
||||
function sqlite3.getlevels(playerid, limit, offset)
|
||||
function sqlite3.getLevels(playerid, limit, offset)
|
||||
limit = limit or 30
|
||||
offset = offset or 0
|
||||
|
||||
|
@ -429,15 +429,15 @@ function sqlite3.getBanByPlayer(playerId)
|
|||
end
|
||||
|
||||
-- maps
|
||||
function sqlite3.addmap(mapname, lastplayed)
|
||||
function sqlite3.addMap(mapname, lastplayed)
|
||||
cur = assert(con:execute("INSERT INTO `map` (`name`, `lastplayed`) VALUES ('"..util.escape(mapname).."', "..tonumber(lastplayed)..")"))
|
||||
end
|
||||
|
||||
function sqlite3.updatemap(mapid, lastplayed)
|
||||
function sqlite3.updateMap(mapid, lastplayed)
|
||||
cur = assert(con:execute("UPDATE `map` SET `lastplayed`="..tonumber(lastplayed).." WHERE `id`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function sqlite3.getmap(mapname)
|
||||
function sqlite3.getMap(mapname)
|
||||
cur = assert(con:execute("SELECT * FROM `map` WHERE `name`='"..util.escape(mapname).."'"))
|
||||
|
||||
local map = cur:fetch({}, "a")
|
||||
|
@ -447,23 +447,23 @@ function sqlite3.getmap(mapname)
|
|||
end
|
||||
|
||||
-- records
|
||||
function sqlite3.addrecord(mapid, recorddate, recordtype, record, playerid)
|
||||
function sqlite3.addRecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("INSERT INTO `record` (`map_id`, `date`, `type`, `record`, `player_id`) VALUES ("..tonumber(mapid)..", "..tonumber(recorddate)..", "..tonumber(recordtype)..", "..tonumber(record)..", "..tonumber(playerid)..")"))
|
||||
end
|
||||
|
||||
function sqlite3.updaterecord(mapid, recorddate, recordtype, record, playerid)
|
||||
function sqlite3.updateRecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("UPDATE `record` SET `date`="..tonumber(recorddate)..", `record`="..tonumber(record)..", `player_id`="..tonumber(playerid).." WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
end
|
||||
|
||||
function sqlite3.removeallrecords()
|
||||
function sqlite3.removeAllRecords()
|
||||
cur = assert(con:execute("TRUNCATE `record`"))
|
||||
end
|
||||
|
||||
function sqlite3.removerecords(mapid)
|
||||
function sqlite3.removeRecords(mapid)
|
||||
cur = assert(con:execute("DELETE FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function sqlite3.getrecords(mapid)
|
||||
function sqlite3.getRecords(mapid)
|
||||
cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
|
||||
local records = {}
|
||||
|
@ -479,7 +479,7 @@ function sqlite3.getrecords(mapid)
|
|||
return records
|
||||
end
|
||||
|
||||
function sqlite3.getrecordscount(mapid)
|
||||
function sqlite3.getRecordsCount(mapid)
|
||||
cur = assert(con:execute("SELECT COUNT(*) AS `count` FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
|
||||
|
||||
local count = cur:fetch({}, "a")
|
||||
|
@ -488,7 +488,7 @@ function sqlite3.getrecordscount(mapid)
|
|||
return count["count"]
|
||||
end
|
||||
|
||||
function sqlite3.getrecord(mapid, recordtype)
|
||||
function sqlite3.getRecord(mapid, recordtype)
|
||||
cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
|
||||
local record = cur:fetch({}, "a")
|
||||
|
@ -497,7 +497,7 @@ function sqlite3.getrecord(mapid, recordtype)
|
|||
return record
|
||||
end
|
||||
|
||||
function sqlite3.isconnected()
|
||||
function sqlite3.isConnected()
|
||||
return (con ~= nil)
|
||||
end
|
||||
|
||||
|
|
|
@ -73,27 +73,27 @@ end
|
|||
|
||||
function sprees.reset(truncate)
|
||||
if truncate then
|
||||
db.removeallrecords()
|
||||
db.removeAllRecords()
|
||||
else
|
||||
db.removerecords(currentMapId)
|
||||
db.removeRecords(currentMapId)
|
||||
end
|
||||
|
||||
currentRecords = {}
|
||||
end
|
||||
|
||||
function sprees.load()
|
||||
if db.isconnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
local map = db.getmap(game.getMap())
|
||||
if db.isConnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
local map = db.getMap(game.getMap())
|
||||
|
||||
if map then
|
||||
currentMapId = map["id"]
|
||||
db.updatemap(currentMapId, os.time())
|
||||
db.updateMap(currentMapId, os.time())
|
||||
else
|
||||
db.addmap(game.getMap(), os.time())
|
||||
currentMapId = db.getmap(game.getMap())["id"]
|
||||
db.addMap(game.getMap(), os.time())
|
||||
currentMapId = db.getMap(game.getMap())["id"]
|
||||
end
|
||||
|
||||
local records = db.getrecords(currentMapId)
|
||||
local records = db.getRecords(currentMapId)
|
||||
|
||||
for _, record in ipairs(records) do
|
||||
currentRecords[record["type"]] = {
|
||||
|
@ -163,13 +163,13 @@ function sprees.load()
|
|||
end
|
||||
|
||||
function sprees.save()
|
||||
if db.isconnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
if db.isConnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
for i = 0, sprees.RECORD_NUM - 1 do
|
||||
if currentRecords[i] and currentRecords[i]["record"] > 0 then
|
||||
if db.getrecord(currentMapId, i) then
|
||||
db.updaterecord(currentMapId, os.time(), i, currentRecords[i]["record"], currentRecords[i]["player"])
|
||||
if db.getRecord(currentMapId, i) then
|
||||
db.updateRecord(currentMapId, os.time(), i, currentRecords[i]["record"], currentRecords[i]["player"])
|
||||
else
|
||||
db.addrecord(currentMapId, os.time(), i, currentRecords[i]["record"], currentRecords[i]["player"])
|
||||
db.addRecord(currentMapId, os.time(), i, currentRecords[i]["record"], currentRecords[i]["player"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -177,10 +177,10 @@ function sprees.save()
|
|||
end
|
||||
|
||||
function sprees.printRecords()
|
||||
if db.isconnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
if db.isConnected() and settings.get("g_spreeRecords") ~= 0 then
|
||||
for i = 0, sprees.RECORD_NUM - 1 do
|
||||
if currentRecords[i] and currentRecords[i]["record"] > 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsprees: ^9longest "..sprees.getRecordNameByType(i).." spree (^7"..currentRecords[i]["record"].."^9) by ^7"..db.getlastalias(currentRecords[i]["player"])["alias"].."^9.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsprees: ^9longest "..sprees.getRecordNameByType(i).." spree (^7"..currentRecords[i]["record"].."^9) by ^7"..db.getLastAlias(currentRecords[i]["player"])["alias"].."^9.\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -229,11 +229,11 @@ function sprees.onPlayerSpree(clientId, type, sourceId)
|
|||
|
||||
local currentSpree = playerSprees[clientId][type]
|
||||
|
||||
if db.isconnected() and settings.get("g_spreeRecords") ~= 0 and
|
||||
if db.isConnected() and settings.get("g_spreeRecords") ~= 0 and
|
||||
(settings.get("g_botRecords") == 1 or not players.isBot(clientId)) and
|
||||
(not currentRecords[type] or currentSpree > currentRecords[type]["record"]) then
|
||||
currentRecords[type] = {
|
||||
["player"] = db.getplayerid(clientId),
|
||||
["player"] = db.getPlayerId(clientId),
|
||||
["record"] = currentSpree
|
||||
}
|
||||
end
|
||||
|
|
|
@ -129,24 +129,24 @@ function players.onClientConnect(clientId, firstTime, isBot)
|
|||
if firstTime then
|
||||
data[clientId]["new"] = true
|
||||
|
||||
if db.isconnected() then
|
||||
local player = db.getplayer(data[clientId]["guid"])
|
||||
if db.isConnected() then
|
||||
local player = db.getPlayer(data[clientId]["guid"])
|
||||
|
||||
if player then
|
||||
db.updateplayer(data[clientId]["guid"], data[clientId]["ip"], os.time())
|
||||
|
||||
local alias = db.getaliasbyname(player["id"], data[clientId]["name"])
|
||||
local alias = db.getAliasByName(player["id"], data[clientId]["name"])
|
||||
|
||||
if alias then
|
||||
db.updatealias(alias["id"], os.time())
|
||||
db.updateAlias(alias["id"], os.time())
|
||||
else
|
||||
db.addalias(player["id"], data[clientId]["name"], os.time())
|
||||
db.addAlias(player["id"], data[clientId]["name"], os.time())
|
||||
end
|
||||
else
|
||||
db.addplayer(data[clientId]["guid"], data[clientId]["ip"], os.time(), 1)
|
||||
db.addPlayer(data[clientId]["guid"], data[clientId]["ip"], os.time(), 1)
|
||||
|
||||
local player = db.getplayer(data[clientId]["guid"])
|
||||
db.addalias(player["id"], data[clientId]["name"], os.time())
|
||||
local player = db.getPlayer(data[clientId]["guid"])
|
||||
db.addAlias(player["id"], data[clientId]["name"], os.time())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue