script_name("Admincheck1337 v0.1")
script_author("L1ct0r")
local inicfg = require 'inicfg'
local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Arial', 8, font_flag.BOLD + font_flag.SHADOW)
local sampev = require 'lib.samp.events'
local showadmins = true
local showplayers = false
local mainIni = inicfg.load({
admins = {}
})
function sampev.onServerMessage(color,msg)
if msg:find("Администратор") and color == -10270721 then
local nick = string.match(msg,"%a+_%a+")
local found = false
for _,v in pairs(mainIni.admins) do
if v == nick and not found then
found = true
end
end
if found == false then
sampAddChatMessage("Новый админ! Это - "..nick,-255)
table.insert(mainIni.admins,nick)
inicfg.save(mainIni)
end
end
end
function admcheck(arg)
if #arg == 0 then
sampAddChatMessage("Неправильный синтаксис команды! Попробуйте /admcheck [int state]",-255)
elseif arg == "1" then
showadmins = true
else
showadmins = false
end
end
function plycheck(arg)
if #arg == 0 then
sampAddChatMessage("Неправильный синтаксис команды! Попробуйте /plycheck [int state]",-255)
elseif arg == "1" then
showplayers = true
else
showplayers = false
end
end
function main()
while not isSampAvailable() do wait(0) end
local resX, resY = getScreenResolution()
sampRegisterChatCommand("admcheck", admcheck)
sampRegisterChatCommand("plycheck", plycheck)
while true do
wait(0)
if showplayers then
local tbl = {}
for _,v in pairs(getAllChars()) do
local result, id = sampGetPlayerIdByCharHandle(v)
if result and v ~= PLAYER_PED then
local name = sampGetPlayerNickname(id)
table.insert(tbl,{name,id})
end
end
for _,v in pairs(tbl) do
local found = false
for _,vv in pairs(mainIni.admins) do
if vv == v[1] and not found then
found = true
end
end
if found == false then
renderFontDrawText(my_font, v[1].."["..v[2].."]", resX/27, (resY/4.25)+_*13, 0xFFFFFFFF)
else
renderFontDrawText(my_font, v[1].."["..v[2].."]", resX/27, (resY/4.25)+_*13, -255)
end
end
end
if showadmins then
local admtbl = {}
for id = 0, sampGetMaxPlayerId() do
if sampIsPlayerConnected(id) then
local name = sampGetPlayerNickname(id)
local found = false
for _,vv in pairs(mainIni.admins) do
if vv == name and not found then
found = true
end
end
if found == true then table.insert(admtbl,{name,id}) end
end
end
for _,v in pairs(admtbl) do
renderFontDrawText(my_font, v[1], resX-(resX/27*3), (resY/4.25)+_*13, -255)
end
end
end
end