Отображение фамы в радиусе

Winstаl

Известный
Автор темы
678
233
Кто знает, что это за скриптик?
Снимок экрана (77).png
 

Liquit

Активный
277
91
Всё поломал, пытаюсь починить, скоро доделаю

хотя мне сейчас лень, да ещё и ошибка тупая, не знаю как пофиксить, вот код:
скрипт:
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
ломается из-за потоков, не знаю где их надо создавать, чтобы нормально было
пытался сделать, чтобы считало, сколько человек без фамы(команда там /getfams есть)
идея в том, что каждую секунду оно проходит по всем 3дтекстам, коим и является этот текст фамы, и если видит символ этот, то добавляет
 
Последнее редактирование: