local sampev = require('samp.events')
local sf = string.format
local Streams = {}
-- ex: Streams[id] == 'nickname_player'
local EReasonQuit = {
[0] = 'Quit',
[1] = 'Kick/Ban',
[2] = 'Timeout'
}
-- ex: EReasonQuit[1] == 'Kick/Ban'
function sampev.onPlayerQuit(playerId, reason)
if Streams[playerId] then
local fmt = sf(
'[KICK CHECKER] Player %s[%d] left the server. Reason: %s',
Streams[playerId], playerId, EReasonQuit[reason] or reason
)
print(fmt)
-- ex: [KICK CHECKER] Player Admin_Bot[0] left the server. Reason: Quit
table.remove(Streams, playerId)
end
end
function sampev.onPlayerStreamIn(playerId)
if not Streams[playerId] then
local nickname = sampGetPlayerNickname(playerId) or ('unknown_'..playerId)
Streams[playerId] = nickname
end
end
function sampev.onPlayerStreamOut(playerId)
if Streams[playerId] then
table.remove(Streams, playerId)
end
end