require 'lib.moonloader'
local sampev = require 'lib.samp.events'
local fams = {}
font_name = "Molot"
font_size = 12
font_flags = 12
local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Tahoma', 11, font_flag.BOLD + font_flag.SHADOW)
function main()
while not isSampAvailable() do wait(0) end
renderFont()
checkFams()
sampRegisterChatCommand('getfams', function()
local players = sampGetPlayerCount(true) - 1
local famcount = 0
for i = 1, table.getn(fams) do
famcount = famcount + fams[i].count
end
sampAddChatMessage('players in stream ' .. players, -1)
sampAddChatMessage('players with fam ' .. famcount, -1)
sampAddChatMessage('players without fam ' .. player - famcount, -1)
--[[ local fam = {
name = "No fam",
count = table
} ]]
end)
while true do
wait(1000)
--[[ fams = {}
for i = 0, 2000 do
local string, color, posX, posY, posZ, dist, ignorewalls, playerid, vehId = sampGet3dTextInfoById(i)
if string:find("©") then
--sampAddChatMessage(string, -1)
local cnt = 0
local exists = false
for i = 1, table.getn(fams) do
if fams[i].name == string then
fams[i].count = fams[i].count + 1
exists = true
end
end
if not exists then
local fam = {
name = string,
distance = dist,
color = color,
count = 0
}
table.insert(fams, fam)
end
end
end ]]
end
end
function renderFont()
lua_thread.create(function()
while true do
wait(10)
if table.getn(fams) ~= 0 then
printStringNow('text', 5000)
local len = table.getn(fams)
renderFontDrawText(my_font, "Всего фам в зоне: " .. len, 500, 485, 0x80CFFFFF)
for i = 1, len do
printStringNow('text', 5000)
renderFontDrawText(my_font, fams[i].name .. " - " .. fams[i].count, 500, 500 + i*15, 0x80CFFFFF)
end
end
end
end)
end
function checkFams()
lua_thread.create(function()
while true do
wait(1000)
fams = {}
--[[ lua_thread.create(function() ]]
for i = 0, 2000 do
--[[ lua_thread.create(function() ]]
if sampGet3dTextInfoById(i) then
local string, color, posX, posY, posZ, dist, ignorewalls, playerid, vehId = sampGet3dTextInfoById(i)
if string:find("©") then
--sampAddChatMessage(string, -1)
local cnt = 0
local exists = false
for i = 1, table.getn(fams) do
if fams[i].name == string then
fams[i].count = fams[i].count + 1
exists = true
end
end
if not exists then
local fam = {
name = string,
count = 1
}
table.insert(fams, fam)
end
end
end
--[[ end) ]]
end
--[[ end) ]]
end
end)
end