• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Commands logs

Metal Mouth

Developer
Joined
Oct 7, 2015
Messages
55
Reaction score
7
Hello, I want to control my staff on OTS so I'm looking for a way to save in logs or something every command that was used by players with it 2/3/4/5. Does someone know the way to do it?
 
Solution
Lua:
function logCommand(player, words, param)
    local file = io.open("data/logs/"..player:getName()..".log", "a+")
    file:write(("[ %s ] %s%s\n"):format(os.date(), words, (param ~= "" and " " or "") .. param))
    file:close()
    return true
end

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")...
Hey metal. What are you curious on exactly? Maybe I can give some assistance.

Are you asking how to make a GMs commands appear as a log in the log files?
 
Uh well, i created test char in OTS hosted on my pc, gave him gamemaster, used /b command and nothing really happened. Will it work only while OTS is hosted on linux?
 
Search
Code:
logsDirectory = "data/logs/"
in your config.lua

Look for logs config too...
 
Well, looks your .exe doesn't have this config...
In your config.lua, there's no log settings?

Maybe your server isn't programmed to do it.
You can tell where you download it?
 
Go to talkactions.xml and do log="true" or something on the talkactions you want to log?

Might not work in 1.1 not sure, idk anything about TFS1.1 but good luck anyway :)
 
here dont Work :(

My Logs only save "/raids - /reload " :(
you can log talkactions in lua
put this somewhere in your lib
Code:
function logCommand(player, words, param)
    local file = io.open("data/logs/"..player:getName()".log", "a+")
    file:write(("[ %s ] %s%s\n"):format(os.date(), words, (param ~= "" and " " or "") .. param))
    file:flush()
    file:close()
    return true
end
then call it in your talkaction scripts with:
logCommand(player, words, param)

it should automatically write to the log for ou
 
Dont work bro.. :(

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/create_item.lua:eek:nSay
data/global.lua:88: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/global.lua:88: in function 'logCommand'
data/talkactions/scripts/create_item.lua:2: in function
 
Dont work bro.. :(

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/create_item.lua:eek:nSay
data/global.lua:88: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/global.lua:88: in function 'logCommand'
data/talkactions/scripts/create_item.lua:2: in function
are you using tfs 1.1?
 
post the full script
i dont know if otx 1.3 uses cid for onSay arguments or player

player is nil in his code, so he seems to have sent it blank.

@Mr Erimyth
You should use the same parameters as the function as they have the same names as the onSay parameters. In your talkaction script add this without modifications:
Code:
logCommand(player, words, param)

I believe you currently did:
Code:
function logCommand()
Which is wrong!
 
Last edited:
Back
Top