Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Custom Logging
- -- SAPP Compatability: 9.8+
- -- Script by: Skylace aka Devieth
- -- Discord: https://discord.gg/Mxmuxgm
- api_version = "1.10.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_JOIN'], "OnEventJoin")
- register_callback(cb['EVENT_LEAVE'], "OnEventLeave")
- register_callback(cb['EVENT_CHAT'], "OnEventChat")
- register_callback(cb['EVENT_COMMAND'], "OnCommand")
- end
- function OnScriptUnload() end
- function OnEventJoin(PlayerIndex)
- ChatCommand(PlayerIndex, nil, "Join", 1)
- end
- function OnEventLeave(PlayerIndex)
- ChatCommand(PlayerIndex, nil, "Join", 0)
- end
- function OnEventChat(PlayerIndex, Message)
- ChatCommand(PlayerIndex, Message, "Chat")
- end
- function OnCommand(PlayerIndex, Command, Enviroment, Password)
- ChatCommand(PlayerIndex, Command, "Cmd")
- end
- function ChatCommand(PlayerIndex, Message, Enviroment, Extra)
- log_message = nil
- if tonumber(PlayerIndex) ~= 0 then
- if player_present(PlayerIndex) then
- local name = get_var(PlayerIndex, "$name")
- local hash = get_var(PlayerIndex, "$hash")
- local ip = get_var(PlayerIndex, "$ip")
- if Enviroment == "Chat" then
- log_message = string.format("%s: %s", name, Message)
- elseif Enviroment == "Cmd" then
- log_message = string.format("Admin: %s\tName: %s\tCommand: %s\tIP: %s\tHash: %s", isadmin(PlayerIndex), name, Message, ip, hash)
- elseif Enviroment == "Join" then
- if Extra == 1 then
- log_message = string.format("%s joined the server.\tIP: %s\tHash: %s", name, ip, hash)
- else
- log_message = string.format("%s left the server.", name)
- end
- end
- end
- end
- if log_message ~= nil then
- Writelog(Enviroment.."Log.txt",log_message)
- end
- end
- function Writelog(filename, value)
- local path = read_string(0x5B9610) .. "\\logs\\"
- if not folder(path) then os.execute("mkdir "..path) end
- local file = io.open(path .. (os.date("%Y-%m-%d_")) .. filename, "a")
- if file then
- local line = string.format("%s\t%s\n", os.date("%H:%M:%S"), tostring(value))
- file:write(line)
- file:close()
- end
- end
- function isadmin(PlayerIndex)
- local lvl = get_var(PlayerIndex, "$lvl")
- if lvl ~= "-1" then
- return true
- end
- return false
- end
- function folder(path)
- local f = os.execute("cd " .. path)
- if f ~= 1 then
- return true
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement