zbizu
Legendary OT User
Not sure if it exists in TFS 1.0 or 0.2, I didn't saw anything in sources
I like to control moderators of my server(gamemasters) if they're not abusing their positions(and proving them how big their lies are if they do) so I wrote this simple script(may lagg a bit when file is large or commands are used too often).
global.lua:
any talkaction, line 2:
after using command with this code:
talkactions_log.txt:
- - - Updated - - -
Updated. Added IPv4 logging
I'll rep++ if anyone manage to shorten it efficiently (1.0 doesn't support bit operations)
I like to control moderators of my server(gamemasters) if they're not abusing their positions(and proving them how big their lies are if they do) so I wrote this simple script(may lagg a bit when file is large or commands are used too often).
global.lua:
LUA:
log_talkactions = true
-- googled functions used to convert ip
-- source: dialectronics.com/Lua/code/BinDecHex.shtml
local hex2bin = {
["0"] = "0000",
["1"] = "0001",
["2"] = "0010",
["3"] = "0011",
["4"] = "0100",
["5"] = "0101",
["6"] = "0110",
["7"] = "0111",
["8"] = "1000",
["9"] = "1001",
["a"] = "1010",
["b"] = "1011",
["c"] = "1100",
["d"] = "1101",
["e"] = "1110",
["f"] = "1111"
}
function Hex2Bin(s)
local ret = ""
local i = 0
for i in string.gfind(s, ".") do
i = string.lower(i)
ret = ret.." "..hex2bin[i]
end
return ret
end
function Bin2Dec(s)
local num = 0
local ex = string.len(s) - 1
local l = 0
l = ex + 1
for i = 1, l do
b = string.sub(s, i, i)
if b == "1" then
num = num + 2^ex
end
ex = ex - 1
end
return string.format("%u", num)
end
-- source: forums.evilmana.com/psp-lua-codebase/string-replace-string-insert/
function string.replace(value, insert, place)
if place == nil then
place = string.len(value)+1
end
return string.sub( value, 1, place-1) .. string.gsub(string.sub(value, place,place), string.sub(value, place,place), insert) .. string.sub( value, place+string.len(insert), string.len(value))
end
-- end of googled functions
function getPlayerIPv4(pid)
local ip_bin = Hex2Bin(string.format("%x",getPlayerIp(pid)))
local a = string.replace(ip_bin,".",-10)
local b = string.replace(a,".",-20)
local c = string.replace(b,".",-30)
local d = string.gsub(c, " ", "")
local e = string.sub(d, -8, -1)
local f = string.sub(d, -17, -10)
local g = string.sub(d, -26, -19)
local h = string.sub(d, -35, -28)
return Bin2Dec(e).."."..Bin2Dec(f).."."..Bin2Dec(g).."."..Bin2Dec(h)
end
any talkaction, line 2:
LUA:
if log_talkactions then
file = io.open("talkactions_log.txt", "a+") -- file directory, default - main ot folder
file:write(os.date("%a %b %d %X %Y", os.time()).." - " .. getPlayerIPv4(cid) .. " - (player id "..getPlayerGUID(cid)..") "..getPlayerName(cid)..": ".. words .." \"".. param .."\n")
file:close()
end
after using command with this code:
talkactions_log.txt:
Fri Aug 09 17:35:34 2013 - 127.0.0.1 - (player id 1) Faith: /anon "help, Test anonymous channel message
- - - Updated - - -
Updated. Added IPv4 logging
I'll rep++ if anyone manage to shorten it efficiently (1.0 doesn't support bit operations)
Last edited: