From a8330fd8a84078a0f9c5dcbae17e666d6b2010a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:25:40 -0300 Subject: [PATCH 01/16] Added whowas --- [admin]/admin2/conf/commands.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/[admin]/admin2/conf/commands.xml b/[admin]/admin2/conf/commands.xml index b5adeec6a..7aa9405d7 100644 --- a/[admin]/admin2/conf/commands.xml +++ b/[admin]/admin2/conf/commands.xml @@ -53,6 +53,7 @@ + From 7dae427e8b14084eb4645b21dd975a9844978b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:25:58 -0300 Subject: [PATCH 02/16] Added whowas --- [admin]/admin2/server/admin_functions.lua | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/[admin]/admin2/server/admin_functions.lua b/[admin]/admin2/server/admin_functions.lua index f2378e0cb..a745561b5 100644 --- a/[admin]/admin2/server/admin_functions.lua +++ b/[admin]/admin2/server/admin_functions.lua @@ -469,6 +469,44 @@ aFunctions = { end, ["shutdown"] = function(reason) shutdown(iif(reason, tostring(reason), nil)) + end, + ["whowas"] = function(nick) + if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end + local qh; + if nick:len() == 32 then + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") + elseif nick:len() <= 23 then + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") + else + outputChatBox("That nickname or serial is too long.", source, 255, 0, 0) + return false + end + local whowas = dbPoll(qh, 200) + if #whowas > 0 then + for item,row in ipairs(whowas) do + local realTime = getRealTime().timestamp + local sec = realTime-row.time + local last = "Unknown" + if sec > 86400 then + last = math.floor(sec/86400).." day(s)" + elseif sec > 3600 then + last = math.floor(sec/3600).." hour(s)" + elseif sec > 60 then + last = math.floor(sec/60).." minute(s)" + else + last = math.floor(sec).." second(s)" + end + outputChatBox("Info printed on console (F8).", source, 255, 141, 0) + outputConsole("Last nickname: "..row.name) + outputConsole("Last serial: "..row.serial) + outputConsole("Last ip: "..row.ip) + outputConsole("Last connection: "..last) + end + return true + else + outputChatBox("We couldn't collect any info about \""..nick.."\".", source, 255, 141, 0) + return false + end end }, admin = {}, From 8d9fd0ebcd39540a3e6ff0d1a12c653a8aebe520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:26:21 -0300 Subject: [PATCH 03/16] Added whowas --- [admin]/admin2/server/admin_storage.lua | 303 ++++++++++++------------ 1 file changed, 152 insertions(+), 151 deletions(-) diff --git a/[admin]/admin2/server/admin_storage.lua b/[admin]/admin2/server/admin_storage.lua index bcaa06455..fe3d25b17 100644 --- a/[admin]/admin2/server/admin_storage.lua +++ b/[admin]/admin2/server/admin_storage.lua @@ -6,154 +6,155 @@ * * Original File by lil_Toady * -**************************************]] -function aSetupStorage() - --local query = db.query ( "SELECT name FROM sqlite_master WHERE name='admin_alias'" ) - - db.exec("CREATE TABLE IF NOT EXISTS alias ( ip TEXT, serial TEXT, name TEXT, time INTEGER )") - db.exec("CREATE TABLE IF NOT EXISTS warnings ( ip TEXT, serial TEXT, name TEXT, time INTEGER )") - - local node = xmlLoadFile("conf\\interiors.xml") - if (node) then - local interiors = 0 - while (xmlFindChild(node, "interior", interiors)) do - local interior = xmlFindChild(node, "interior", interiors) - interiors = interiors + 1 - aInteriors[interiors] = { - world = tonumber(xmlNodeGetAttribute(interior, "world")), - id = xmlNodeGetAttribute(interior, "id"), - x = xmlNodeGetAttribute(interior, "posX"), - y = xmlNodeGetAttribute(interior, "posY"), - z = xmlNodeGetAttribute(interior, "posZ"), - r = xmlNodeGetAttribute(interior, "rot") - } - end - xmlUnloadFile(node) - end - local node = xmlLoadFile("conf\\stats.xml") - if (node) then - local stats = 0 - while (xmlFindChild(node, "stat", stats)) do - local stat = xmlFindChild(node, "stat", stats) - local id = tonumber(xmlNodeGetAttribute(stat, "id")) - local name = xmlNodeGetAttribute(stat, "name") - aStats[id] = name - stats = stats + 1 - end - xmlUnloadFile(node) - end - local node = xmlLoadFile("conf\\weathers.xml") - if (node) then - local weathers = 0 - while (xmlFindChild(node, "weather", weathers) ~= false) do - local weather = xmlFindChild(node, "weather", weathers) - local id = tonumber(xmlNodeGetAttribute(weather, "id")) - local name = xmlNodeGetAttribute(weather, "name") - aWeathers[id] = name - weathers = weathers + 1 - end - xmlUnloadFile(node) - end - local node = xmlLoadFile("conf\\reports.xml") - if (node) then - local messages = 0 - while (xmlFindChild(node, "message", messages)) do - subnode = xmlFindChild(node, "message", messages) - local author = xmlFindChild(subnode, "author", 0) - local subject = xmlFindChild(subnode, "subject", 0) - local category = xmlFindChild(subnode, "category", 0) - local text = xmlFindChild(subnode, "text", 0) - local time = xmlFindChild(subnode, "time", 0) - local read = (xmlFindChild(subnode, "read", 0) ~= false) - local id = #aReports + 1 - aReports[id] = {} - if (author) then - aReports[id].author = xmlNodeGetValue(author) - else - aReports[id].author = "" - end - if (category) then - aReports[id].category = xmlNodeGetValue(category) - else - aReports[id].category = "" - end - if (subject) then - aReports[id].subject = xmlNodeGetValue(subject) - else - aReports[id].subject = "" - end - if (text) then - aReports[id].text = xmlNodeGetValue(text) - else - aReports[id].text = "" - end - if (time) then - aReports[id].time = xmlNodeGetValue(time) - else - aReports[id].time = "" - end - aReports[id].read = read - messages = messages + 1 - end - xmlUnloadFile(node) - end - local node = xmlLoadFile("conf\\messages.xml") - if (node) then - for id, type in ipairs(_types) do - local subnode = xmlFindChild(node, type, 0) - if (subnode) then - aLogMessages[type] = {} - local groups = 0 - while (xmlFindChild(subnode, "group", groups)) do - local group = xmlFindChild(subnode, "group", groups) - local action = xmlNodeGetAttribute(group, "action") - local r = tonumber(xmlNodeGetAttribute(group, "r")) - local g = tonumber(xmlNodeGetAttribute(group, "g")) - local b = tonumber(xmlNodeGetAttribute(group, "b")) - aLogMessages[type][action] = {} - aLogMessages[type][action]["r"] = r or 0 - aLogMessages[type][action]["g"] = g or 255 - aLogMessages[type][action]["b"] = b or 0 - if (xmlFindChild(group, "all", 0)) then - aLogMessages[type][action]["all"] = xmlNodeGetValue(xmlFindChild(group, "all", 0)) - end - if (xmlFindChild(group, "admin", 0)) then - aLogMessages[type][action]["admin"] = xmlNodeGetValue(xmlFindChild(group, "admin", 0)) - end - if (xmlFindChild(group, "player", 0)) then - aLogMessages[type][action]["player"] = xmlNodeGetValue(xmlFindChild(group, "player", 0)) - end - if (xmlFindChild(group, "log", 0)) then - aLogMessages[type][action]["log"] = xmlNodeGetValue(xmlFindChild(group, "log", 0)) - end - groups = groups + 1 - end - end - end - xmlUnloadFile(node) - end -end - -function aReleaseStorage() - local node = xmlLoadFile("conf\\reports.xml") - if (node) then - local messages = 0 - while (xmlFindChild(node, "message", messages) ~= false) do - local subnode = xmlFindChild(node, "message", messages) - xmlDestroyNode(subnode) - messages = messages + 1 - end - else - node = xmlCreateFile("conf\\reports.xml", "messages") - end - for id, message in ipairs(aReports) do - local subnode = xmlCreateChild(node, "message") - for key, value in pairs(message) do - if (value) then - xmlNodeSetValue(xmlCreateChild(subnode, key), tostring(value)) - end - end - end - xmlSaveFile(node) - xmlUnloadFile(node) -end +**************************************]] +function aSetupStorage() + --local query = db.query ( "SELECT name FROM sqlite_master WHERE name='admin_alias'" ) + + db.exec("CREATE TABLE IF NOT EXISTS alias ( ip TEXT, serial TEXT, name TEXT, time INTEGER )") + db.exec("CREATE TABLE IF NOT EXISTS warnings ( ip TEXT, serial TEXT, name TEXT, time INTEGER )") + db.exec("CREATE TABLE IF NOT EXISTS whowas ( ip TEXT, serial TEXT, name TEXT, time INTEGER )") + + local node = xmlLoadFile("conf\\interiors.xml") + if (node) then + local interiors = 0 + while (xmlFindChild(node, "interior", interiors)) do + local interior = xmlFindChild(node, "interior", interiors) + interiors = interiors + 1 + aInteriors[interiors] = { + world = tonumber(xmlNodeGetAttribute(interior, "world")), + id = xmlNodeGetAttribute(interior, "id"), + x = xmlNodeGetAttribute(interior, "posX"), + y = xmlNodeGetAttribute(interior, "posY"), + z = xmlNodeGetAttribute(interior, "posZ"), + r = xmlNodeGetAttribute(interior, "rot") + } + end + xmlUnloadFile(node) + end + local node = xmlLoadFile("conf\\stats.xml") + if (node) then + local stats = 0 + while (xmlFindChild(node, "stat", stats)) do + local stat = xmlFindChild(node, "stat", stats) + local id = tonumber(xmlNodeGetAttribute(stat, "id")) + local name = xmlNodeGetAttribute(stat, "name") + aStats[id] = name + stats = stats + 1 + end + xmlUnloadFile(node) + end + local node = xmlLoadFile("conf\\weathers.xml") + if (node) then + local weathers = 0 + while (xmlFindChild(node, "weather", weathers) ~= false) do + local weather = xmlFindChild(node, "weather", weathers) + local id = tonumber(xmlNodeGetAttribute(weather, "id")) + local name = xmlNodeGetAttribute(weather, "name") + aWeathers[id] = name + weathers = weathers + 1 + end + xmlUnloadFile(node) + end + local node = xmlLoadFile("conf\\reports.xml") + if (node) then + local messages = 0 + while (xmlFindChild(node, "message", messages)) do + subnode = xmlFindChild(node, "message", messages) + local author = xmlFindChild(subnode, "author", 0) + local subject = xmlFindChild(subnode, "subject", 0) + local category = xmlFindChild(subnode, "category", 0) + local text = xmlFindChild(subnode, "text", 0) + local time = xmlFindChild(subnode, "time", 0) + local read = (xmlFindChild(subnode, "read", 0) ~= false) + local id = #aReports + 1 + aReports[id] = {} + if (author) then + aReports[id].author = xmlNodeGetValue(author) + else + aReports[id].author = "" + end + if (category) then + aReports[id].category = xmlNodeGetValue(category) + else + aReports[id].category = "" + end + if (subject) then + aReports[id].subject = xmlNodeGetValue(subject) + else + aReports[id].subject = "" + end + if (text) then + aReports[id].text = xmlNodeGetValue(text) + else + aReports[id].text = "" + end + if (time) then + aReports[id].time = xmlNodeGetValue(time) + else + aReports[id].time = "" + end + aReports[id].read = read + messages = messages + 1 + end + xmlUnloadFile(node) + end + local node = xmlLoadFile("conf\\messages.xml") + if (node) then + for id, type in ipairs(_types) do + local subnode = xmlFindChild(node, type, 0) + if (subnode) then + aLogMessages[type] = {} + local groups = 0 + while (xmlFindChild(subnode, "group", groups)) do + local group = xmlFindChild(subnode, "group", groups) + local action = xmlNodeGetAttribute(group, "action") + local r = tonumber(xmlNodeGetAttribute(group, "r")) + local g = tonumber(xmlNodeGetAttribute(group, "g")) + local b = tonumber(xmlNodeGetAttribute(group, "b")) + aLogMessages[type][action] = {} + aLogMessages[type][action]["r"] = r or 0 + aLogMessages[type][action]["g"] = g or 255 + aLogMessages[type][action]["b"] = b or 0 + if (xmlFindChild(group, "all", 0)) then + aLogMessages[type][action]["all"] = xmlNodeGetValue(xmlFindChild(group, "all", 0)) + end + if (xmlFindChild(group, "admin", 0)) then + aLogMessages[type][action]["admin"] = xmlNodeGetValue(xmlFindChild(group, "admin", 0)) + end + if (xmlFindChild(group, "player", 0)) then + aLogMessages[type][action]["player"] = xmlNodeGetValue(xmlFindChild(group, "player", 0)) + end + if (xmlFindChild(group, "log", 0)) then + aLogMessages[type][action]["log"] = xmlNodeGetValue(xmlFindChild(group, "log", 0)) + end + groups = groups + 1 + end + end + end + xmlUnloadFile(node) + end +end + +function aReleaseStorage() + local node = xmlLoadFile("conf\\reports.xml") + if (node) then + local messages = 0 + while (xmlFindChild(node, "message", messages) ~= false) do + local subnode = xmlFindChild(node, "message", messages) + xmlDestroyNode(subnode) + messages = messages + 1 + end + else + node = xmlCreateFile("conf\\reports.xml", "messages") + end + for id, message in ipairs(aReports) do + local subnode = xmlCreateChild(node, "message") + for key, value in pairs(message) do + if (value) then + xmlNodeSetValue(xmlCreateChild(subnode, key), tostring(value)) + end + end + end + xmlSaveFile(node) + xmlUnloadFile(node) +end From b6e246fcbf67c1f35002d6a865d5f52d4965206d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:26:37 -0300 Subject: [PATCH 04/16] Added whowas --- [admin]/admin2/server/admin_server.lua | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 0473793b9..5ad1d1ba4 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -27,6 +27,15 @@ addEventHandler( end end return + else + -- whowas stuff + for id, player in ipairs(getElementsByType("player")) do + local nick = getPlayerName(player) + local serial = getPlayerSerial(player) + local ip = getPlayerIP(player) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + end end aSetupACL() @@ -51,6 +60,14 @@ addEventHandler( end else aReleaseStorage() + -- whowas stuff + for id, player in ipairs(getElementsByType("player")) do + local nick = getPlayerName(player) + local serial = getPlayerSerial(player) + local ip = getPlayerIP(player) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + end end aclSave() end @@ -76,6 +93,13 @@ addEventHandler( end end setPedGravity(source, getGravity()) + + -- whowas stuff + local nick = getPlayerName(source) + local serial = getPlayerSerial(source) + local ip = getPlayerIP(source) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) @@ -84,6 +108,13 @@ addEventHandler( root, function() aPlayers[source] = nil + + -- whowas stuff + local nick = getPlayerName(source) + local serial = getPlayerSerial(source) + local ip = getPlayerIP(source) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) @@ -246,7 +277,7 @@ addEventHandler( "aServer", root, function(action, ...) - if (hasObjectPermissionTo(source, "command." .. action)) then + if (hasObjectPermissionTo(source, "command."..action)) then local func = aFunctions.server[action] if (func) then local result, mdata1, mdata2 = func(...) From a868ef3e359747b924693f1273918e03c39f8323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:28:47 -0300 Subject: [PATCH 05/16] Added whowas --- [admin]/admin2/server/admin_server.lua | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 5ad1d1ba4..6970e53d1 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -29,7 +29,7 @@ addEventHandler( return else -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do + for id, player in ipairs(getElementsByType("player")) do local nick = getPlayerName(player) local serial = getPlayerSerial(player) local ip = getPlayerIP(player) @@ -61,7 +61,7 @@ addEventHandler( else aReleaseStorage() -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do + for id, player in ipairs(getElementsByType("player")) do local nick = getPlayerName(player) local serial = getPlayerSerial(player) local ip = getPlayerIP(player) @@ -93,13 +93,13 @@ addEventHandler( end end setPedGravity(source, getGravity()) - - -- whowas stuff - local nick = getPlayerName(source) - local serial = getPlayerSerial(source) - local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + + -- whowas stuff + local nick = getPlayerName(source) + local serial = getPlayerSerial(source) + local ip = getPlayerIP(source) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) @@ -108,13 +108,13 @@ addEventHandler( root, function() aPlayers[source] = nil - - -- whowas stuff - local nick = getPlayerName(source) - local serial = getPlayerSerial(source) - local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + + -- whowas stuff + local nick = getPlayerName(source) + local serial = getPlayerSerial(source) + local ip = getPlayerIP(source) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) From d35cfaa10099d55d5cb0b11b4c835ce0786c92ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:34:43 -0300 Subject: [PATCH 06/16] Added whowas --- [admin]/admin2/server/admin_server.lua | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 6970e53d1..d9a926f1b 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -27,15 +27,15 @@ addEventHandler( end end return - else - -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do - local nick = getPlayerName(player) - local serial = getPlayerSerial(player) - local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") - end + else + -- whowas stuff + for id, player in ipairs(getElementsByType("player")) do + local nick = getPlayerName(player) + local serial = getPlayerSerial(player) + local ip = getPlayerIP(player) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + end end aSetupACL() @@ -60,14 +60,14 @@ addEventHandler( end else aReleaseStorage() - -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do - local nick = getPlayerName(player) - local serial = getPlayerSerial(player) - local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") - end + -- whowas stuff + for id, player in ipairs(getElementsByType("player")) do + local nick = getPlayerName(player) + local serial = getPlayerSerial(player) + local ip = getPlayerIP(player) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + end end aclSave() end @@ -98,7 +98,7 @@ addEventHandler( local nick = getPlayerName(source) local serial = getPlayerSerial(source) local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) @@ -108,12 +108,12 @@ addEventHandler( root, function() aPlayers[source] = nil - + -- whowas stuff local nick = getPlayerName(source) local serial = getPlayerSerial(source) local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."' AND ip='"..ip.."';") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) From a389f3d8e0e5229359ef04446127e836939643ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:38:09 -0300 Subject: [PATCH 07/16] Added whowas --- [admin]/admin2/server/admin_server.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index d9a926f1b..45ae5fc28 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -33,7 +33,7 @@ addEventHandler( local nick = getPlayerName(player) local serial = getPlayerSerial(player) local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end end @@ -65,7 +65,7 @@ addEventHandler( local nick = getPlayerName(player) local serial = getPlayerSerial(player) local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end end @@ -98,7 +98,7 @@ addEventHandler( local nick = getPlayerName(source) local serial = getPlayerSerial(source) local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) @@ -113,7 +113,7 @@ addEventHandler( local nick = getPlayerName(source) local serial = getPlayerSerial(source) local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial..";") + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") end ) From ba98c7b40e4370f05c6bde05db548c49a011adb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:40:45 -0300 Subject: [PATCH 08/16] Added whowas --- [admin]/admin2/server/admin_functions.lua | 72 +++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/[admin]/admin2/server/admin_functions.lua b/[admin]/admin2/server/admin_functions.lua index a745561b5..884bc8a1a 100644 --- a/[admin]/admin2/server/admin_functions.lua +++ b/[admin]/admin2/server/admin_functions.lua @@ -471,42 +471,42 @@ aFunctions = { shutdown(iif(reason, tostring(reason), nil)) end, ["whowas"] = function(nick) - if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end - local qh; - if nick:len() == 32 then - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") - elseif nick:len() <= 23 then - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") - else - outputChatBox("That nickname or serial is too long.", source, 255, 0, 0) - return false - end - local whowas = dbPoll(qh, 200) - if #whowas > 0 then - for item,row in ipairs(whowas) do - local realTime = getRealTime().timestamp - local sec = realTime-row.time - local last = "Unknown" - if sec > 86400 then - last = math.floor(sec/86400).." day(s)" - elseif sec > 3600 then - last = math.floor(sec/3600).." hour(s)" - elseif sec > 60 then - last = math.floor(sec/60).." minute(s)" - else - last = math.floor(sec).." second(s)" - end - outputChatBox("Info printed on console (F8).", source, 255, 141, 0) - outputConsole("Last nickname: "..row.name) - outputConsole("Last serial: "..row.serial) - outputConsole("Last ip: "..row.ip) - outputConsole("Last connection: "..last) - end - return true - else - outputChatBox("We couldn't collect any info about \""..nick.."\".", source, 255, 141, 0) - return false - end + if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end + local qh; + if nick:len() == 32 then + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") + elseif nick:len() <= 23 then + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") + else + outputChatBox("That nickname or serial is too long.", source, 255, 0, 0) + return false + end + local whowas = dbPoll(qh, 200) + if #whowas > 0 then + outputChatBox("Info printed on console (F8).", source, 255, 141, 0) + outputConsole("Last nickname: "..whowas[#whowas].name) + outputConsole("Last serial: "..whowas[#whowas].serial) + for item,row in ipairs(whowas) do + local realTime = getRealTime().timestamp + local sec = realTime-row.time + local last = "Unknown" + if sec > 86400 then + last = math.floor(sec/86400).." day(s)" + elseif sec > 3600 then + last = math.floor(sec/3600).." hour(s)" + elseif sec > 60 then + last = math.floor(sec/60).." minute(s)" + else + last = math.floor(sec).." second(s)" + end + outputConsole("Last ip: "..row.ip) + outputConsole("Last connection: "..last) + end + return true + else + outputChatBox("We couldn't collect any info about \""..nick.."\".", source, 255, 141, 0) + return false + end end }, admin = {}, From e1c45da5888a8248ad8a7b5eb3ba369ee83e0039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 02:44:08 -0300 Subject: [PATCH 09/16] Added whowas --- [admin]/admin2/server/admin_functions.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/[admin]/admin2/server/admin_functions.lua b/[admin]/admin2/server/admin_functions.lua index 884bc8a1a..f7a43757b 100644 --- a/[admin]/admin2/server/admin_functions.lua +++ b/[admin]/admin2/server/admin_functions.lua @@ -484,8 +484,7 @@ aFunctions = { local whowas = dbPoll(qh, 200) if #whowas > 0 then outputChatBox("Info printed on console (F8).", source, 255, 141, 0) - outputConsole("Last nickname: "..whowas[#whowas].name) - outputConsole("Last serial: "..whowas[#whowas].serial) + outputConsole("Last nickname: "..whowas[#whowas].name, source) for item,row in ipairs(whowas) do local realTime = getRealTime().timestamp local sec = realTime-row.time @@ -499,8 +498,9 @@ aFunctions = { else last = math.floor(sec).." second(s)" end - outputConsole("Last ip: "..row.ip) - outputConsole("Last connection: "..last) + outputConsole("Last serial #"..item..": "..row.serial, source) + outputConsole("Last ip #"..item..": "..row.ip, source) + outputConsole("Last connection #"..item..": "..last, source) end return true else From 167ac5fc381061e53efd10e9df657ca7e5de42f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 04:59:09 -0300 Subject: [PATCH 10/16] Added updateWhowas() --- [admin]/admin2/server/admin_server.lua | 47 +++++++++++--------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 45ae5fc28..164567189 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -16,6 +16,15 @@ aStats = {} aReports = {} aWeathers = {} +function updateWhowas(player) + if not player or not isElement(player) then return end + local nick = getPlayerName(player) + local serial = getPlayerSerial(player) + local ip = getPlayerIP(player) + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") +end + addEventHandler( "onResourceStart", root, @@ -27,15 +36,11 @@ addEventHandler( end end return - else - -- whowas stuff + else + -- whowas stuff for id, player in ipairs(getElementsByType("player")) do - local nick = getPlayerName(player) - local serial = getPlayerSerial(player) - local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") - end + updateWhowas(player) + end end aSetupACL() @@ -62,11 +67,7 @@ addEventHandler( aReleaseStorage() -- whowas stuff for id, player in ipairs(getElementsByType("player")) do - local nick = getPlayerName(player) - local serial = getPlayerSerial(player) - local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + updateWhowas(player) end end aclSave() @@ -93,13 +94,9 @@ addEventHandler( end end setPedGravity(source, getGravity()) - - -- whowas stuff - local nick = getPlayerName(source) - local serial = getPlayerSerial(source) - local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + + -- whowas stuff + updateWhowas(source) end ) @@ -108,13 +105,9 @@ addEventHandler( root, function() aPlayers[source] = nil - - -- whowas stuff - local nick = getPlayerName(source) - local serial = getPlayerSerial(source) - local ip = getPlayerIP(source) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + + -- whowas stuff + updateWhowas(source) end ) From 0bc6c59b61132a323d32e4cc5956c0214ba315e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 16:35:15 -0300 Subject: [PATCH 11/16] Now info can be saved into a table This adds: aWhowas = {} saveToDatabaseWhowas() clearRowsWhowas() insertIntoWhowas() And updates: updateWhowas() --- [admin]/admin2/server/admin_server.lua | 35 ++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 164567189..2083ca65d 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -15,14 +15,45 @@ aInteriors = {} aStats = {} aReports = {} aWeathers = {} +aWhowas = {} + +function saveToDatabaseWhowas(nick, serial, ip, timestamp) + if not nick or not serial or not ip then return end + if not timestamp then timestamp = getRealTime().timestamp end + db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..timestamp.."');") +end + +function clearRowsWhowas() + for k,data in ipairs(aWhowas) do + saveToDatabaseWhowas(data[1], data[2], data[3], data[4]) + end + aWhowas = {} +end + +function insertIntoWhowas(nick, serial, ip, timestamp) + if not nick or not serial or not ip then return end + if not timestamp then timestamp = getRealTime().timestamp end + table.insert(aWhowas, {nick, serial, ip, timestamp}) +end function updateWhowas(player) if not player or not isElement(player) then return end + local nick = getPlayerName(player) local serial = getPlayerSerial(player) local ip = getPlayerIP(player) - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..tostring(getRealTime().timestamp).."');") + local timestamp = getRealTime().timestamp + if get("whowassave") == "both" then + local rows = tonumber(get("whowasmax")) or 100 + if rows > 500 then rows = 500 elseif rows < 5 then rows = 5 end + if #aWhowas > rows then + clearRowsWhowas() + end + insertIntoWhowas(nick, serial, ip, timestamp) + else + saveToDatabaseWhowas(nick, serial, ip, timestamp) + end end addEventHandler( From 5cdde9d21e590f63fa5e9efe1ce18ff53df3409d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Fri, 19 Jul 2019 16:37:04 -0300 Subject: [PATCH 12/16] whowas function updated This adds the ability to choose where do you want to print the info and makes it work with the changes to admin_server.lua --- [admin]/admin2/server/admin_functions.lua | 142 ++++++++++++++++------ 1 file changed, 106 insertions(+), 36 deletions(-) diff --git a/[admin]/admin2/server/admin_functions.lua b/[admin]/admin2/server/admin_functions.lua index f7a43757b..954be5e9f 100644 --- a/[admin]/admin2/server/admin_functions.lua +++ b/[admin]/admin2/server/admin_functions.lua @@ -471,42 +471,112 @@ aFunctions = { shutdown(iif(reason, tostring(reason), nil)) end, ["whowas"] = function(nick) - if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end - local qh; - if nick:len() == 32 then - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") - elseif nick:len() <= 23 then - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") - else - outputChatBox("That nickname or serial is too long.", source, 255, 0, 0) - return false - end - local whowas = dbPoll(qh, 200) - if #whowas > 0 then - outputChatBox("Info printed on console (F8).", source, 255, 141, 0) - outputConsole("Last nickname: "..whowas[#whowas].name, source) - for item,row in ipairs(whowas) do - local realTime = getRealTime().timestamp - local sec = realTime-row.time - local last = "Unknown" - if sec > 86400 then - last = math.floor(sec/86400).." day(s)" - elseif sec > 3600 then - last = math.floor(sec/3600).." hour(s)" - elseif sec > 60 then - last = math.floor(sec/60).." minute(s)" - else - last = math.floor(sec).." second(s)" - end - outputConsole("Last serial #"..item..": "..row.serial, source) - outputConsole("Last ip #"..item..": "..row.ip, source) - outputConsole("Last connection #"..item..": "..last, source) - end - return true - else - outputChatBox("We couldn't collect any info about \""..nick.."\".", source, 255, 141, 0) - return false - end + if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end + local printF = get("whowasprint") + local serial = false + local qh; + + if printF == "chat" then + printF = outputChatBox + else + printF = outputConsole + end + + if nick:len() == 32 then + serial = true + elseif nick:len() > 22 then + outputChatBox("That nickname or serial is too long/short.", source, 255, 0, 0) + return false + end + + if #aWhowas > 0 then + local selected = {} + for k,data in ipairs(aWhowas) do + if (serial and data[2] == nick) or (data[1] == nick) then + table.insert(selected, data) + end + end + + if #selected > 0 then + if printF == outputConsole then + outputChatBox("Info printed on console (F8).", source, 255, 141, 0) + end + if serial then + printF("Last serial: "..selected[#selected][2], source, 255, 141, 0) + else + printF("Last nickname: "..selected[#selected][1], source, 255, 141, 0) + end + + local realTime = getRealTime().timestamp + for item,data in ipairs(selected) do + local sec = realTime-data[4] + local last = "Unknown" + if sec > 86400 then + last = math.floor(sec/86400).." day(s)" + elseif sec > 3600 then + last = math.floor(sec/3600).." hour(s)" + elseif sec > 60 then + last = math.floor(sec/60).." minute(s)" + else + last = math.floor(sec).." second(s)" + end + if serial then + printF("Last nickname #"..item..": "..data[1], source, 255, 141, 0) + else + printF("Last serial #"..item..": "..data[2], source, 255, 141, 0) + end + + printF("Last ip #"..item..": "..data[3], source, 255, 141, 0) + printF("Last connection #"..item..": "..last, source, 255, 141, 0) + end + return true + end + end + + if serial then + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") + else + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") + end + + local whowas = dbPoll(qh, 200) + if #whowas > 0 then + if printF == outputConsole then + outputChatBox("Info printed on console (F8).", source, 255, 141, 0) + end + if serial then + printF("Last serial: "..whowas[#whowas].serial, source, 255, 141, 0) + else + printF("Last nickname: "..whowas[#whowas].name, source, 255, 141, 0) + end + + local realTime = getRealTime().timestamp + for item,row in ipairs(whowas) do + local sec = realTime-row.time + local last = "Unknown" + if sec > 86400 then + last = math.floor(sec/86400).." day(s)" + elseif sec > 3600 then + last = math.floor(sec/3600).." hour(s)" + elseif sec > 60 then + last = math.floor(sec/60).." minute(s)" + else + last = math.floor(sec).." second(s)" + end + if serial then + printF("Last nickname #"..item..": "..row.name, source, 255, 141, 0) + else + printF("Last serial #"..item..": "..row.serial, source, 255, 141, 0) + end + + printF("Last ip #"..item..": "..row.ip, source, 255, 141, 0) + printF("Last connection #"..item..": "..last, source, 255, 141, 0) + end + return true + else + outputChatBox("We couldn't collect any info about \""..nick.."\".", source, 255, 141, 0) + return false + end end }, admin = {}, From 7e72cf3a07483992822a82aa9b404019c4ca3eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Tue, 6 Aug 2019 14:56:16 -0300 Subject: [PATCH 13/16] Updated whowas function Deleted single line code and changed the dbQuery's calls to prevent SQL Injections --- [admin]/admin2/server/admin_functions.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/[admin]/admin2/server/admin_functions.lua b/[admin]/admin2/server/admin_functions.lua index 954be5e9f..01a2b4b6e 100644 --- a/[admin]/admin2/server/admin_functions.lua +++ b/[admin]/admin2/server/admin_functions.lua @@ -471,7 +471,10 @@ aFunctions = { shutdown(iif(reason, tostring(reason), nil)) end, ["whowas"] = function(nick) - if not nick then outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) return false end + if not nick then + outputChatBox("A nickname or serial is needed.", source, 255, 0, 0) + return false + end local printF = get("whowasprint") local serial = false local qh; @@ -514,7 +517,7 @@ aFunctions = { if sec > 86400 then last = math.floor(sec/86400).." day(s)" elseif sec > 3600 then - last = math.floor(sec/3600).." hour(s)" + last = math.floor(sec/3600).." hour(s)" elseif sec > 60 then last = math.floor(sec/60).." minute(s)" else @@ -534,9 +537,9 @@ aFunctions = { end if serial then - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial='"..nick.."';") + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE serial=?;", nick) else - qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name='"..nick.."';") + qh = dbQuery(db.connection, "SELECT * FROM whowas WHERE name=?;", nick) end local whowas = dbPoll(qh, 200) @@ -557,7 +560,7 @@ aFunctions = { if sec > 86400 then last = math.floor(sec/86400).." day(s)" elseif sec > 3600 then - last = math.floor(sec/3600).." hour(s)" + last = math.floor(sec/3600).." hour(s)" elseif sec > 60 then last = math.floor(sec/60).." minute(s)" else From d175327ebc5c5472c0f959615462e0976b0842e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Tue, 6 Aug 2019 14:57:52 -0300 Subject: [PATCH 14/16] Updated whowas Deleted single line code, changed the dbQuery's calls to prevent SQL Injections, made it possible to use root on updateWhowas, changed updateWhowas() to persistPlayerWhowasInfo() and removed silly comments. --- [admin]/admin2/server/admin_server.lua | 48 +++++++++++++++----------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index 2083ca65d..ec277482f 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -18,10 +18,14 @@ aWeathers = {} aWhowas = {} function saveToDatabaseWhowas(nick, serial, ip, timestamp) - if not nick or not serial or not ip then return end - if not timestamp then timestamp = getRealTime().timestamp end - db.exec("DELETE FROM whowas WHERE name='"..nick.."' AND serial='"..serial.."';") - db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES('"..nick.."','"..serial.."','"..ip.."','"..timestamp.."');") + if not nick or not serial or not ip then + return + end + if not timestamp then + timestamp = getRealTime().timestamp + end + db.exec("DELETE FROM whowas WHERE name=? AND serial=?;", nick, serial) + db.exec("INSERT INTO whowas(name,serial,ip,time) VALUES(?,?,?,?);", nick, serial, ip, timestamp) end function clearRowsWhowas() @@ -32,13 +36,25 @@ function clearRowsWhowas() end function insertIntoWhowas(nick, serial, ip, timestamp) - if not nick or not serial or not ip then return end - if not timestamp then timestamp = getRealTime().timestamp end + if not nick or not serial or not ip then + return + end + if not timestamp then + timestamp = getRealTime().timestamp + end table.insert(aWhowas, {nick, serial, ip, timestamp}) end -function updateWhowas(player) - if not player or not isElement(player) then return end +function persistPlayerWhowasInfo(player) -- Ensures that the player's information is up to date, it also ensures the integrity of the database + if not player or not isElement(player) then + return + end + if player == root then + for _,plr in ipairs(getElementsByType("player")) do + persistPlayerWhowasInfo(plr) + end + return + end local nick = getPlayerName(player) local serial = getPlayerSerial(player) @@ -68,10 +84,7 @@ addEventHandler( end return else - -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do - updateWhowas(player) - end + persistPlayerWhowasInfo(root) end aSetupACL() @@ -96,10 +109,7 @@ addEventHandler( end else aReleaseStorage() - -- whowas stuff - for id, player in ipairs(getElementsByType("player")) do - updateWhowas(player) - end + persistPlayerWhowasInfo(root) end aclSave() end @@ -126,8 +136,7 @@ addEventHandler( end setPedGravity(source, getGravity()) - -- whowas stuff - updateWhowas(source) + persistPlayerWhowasInfo(source) end ) @@ -137,8 +146,7 @@ addEventHandler( function() aPlayers[source] = nil - -- whowas stuff - updateWhowas(source) + persistPlayerWhowasInfo(source) end ) From 65a438dddb92480e12c3b79f8f67f83ee99cec34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Tue, 6 Aug 2019 15:13:16 -0300 Subject: [PATCH 15/16] Updated whowas I forgot about the singleline on the "whowasmax" check inside persistPlayerWhowasInfo() --- [admin]/admin2/server/admin_server.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index ec277482f..b24c8cb2c 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -62,7 +62,11 @@ function persistPlayerWhowasInfo(player) -- Ensures that the player's informatio local timestamp = getRealTime().timestamp if get("whowassave") == "both" then local rows = tonumber(get("whowasmax")) or 100 - if rows > 500 then rows = 500 elseif rows < 5 then rows = 5 end + if rows > 500 then + rows = 500 + elseif rows < 5 then + rows = 5 + end if #aWhowas > rows then clearRowsWhowas() end From 176ad6df8e17c9d9e4b2b51364d35ba9a77a9016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Barrios?= Date: Tue, 6 Aug 2019 18:16:41 -0300 Subject: [PATCH 16/16] Update [admin]/admin2/server/admin_server.lua Co-Authored-By: Qais Patankar --- [admin]/admin2/server/admin_server.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/[admin]/admin2/server/admin_server.lua b/[admin]/admin2/server/admin_server.lua index b24c8cb2c..55f25ec88 100644 --- a/[admin]/admin2/server/admin_server.lua +++ b/[admin]/admin2/server/admin_server.lua @@ -45,7 +45,8 @@ function insertIntoWhowas(nick, serial, ip, timestamp) table.insert(aWhowas, {nick, serial, ip, timestamp}) end -function persistPlayerWhowasInfo(player) -- Ensures that the player's information is up to date, it also ensures the integrity of the database +-- Ensures that the player's information is up to date, it also ensures the integrity of the database +function persistPlayerWhowasInfo(player) if not player or not isElement(player) then return end