Evolve доделать луа скрипт френдлист

ametkal_best

Новичок
Автор темы
1
1
Ниже есть код нужно добавить имгуи где можно настроить цвет клиста друга настроить рендер отображения друзей в сети и выбрать где это будет находиться на экране выбор кастом шрифта спасибо!







Код:
local inicfg = require("inicfg")
local sampEvents = require("samp.events")

local FRIEND_COLOR = 0xffbdf7FF

local HELP = [[{ffffff}/frd [ид или никнейм игрока] - добавление человека в друзья.
/frdel [ид или никнейм игрока] - удаление человека из друзей.
/frsp - просмотр списка друзей.
/frinfo - как ты открыл это меню?]]

do
    function chat(...)
        sampAddChatMessageEx(FRIEND_COLOR, {
            { "{HEX}", "{483d8b}" },
            { "{}", "{CECECE}" }
        }, "|{}", ...)
    end

    function sampAddChatMessageEx(color, patterns, ...)
        local output
        for key, value in pairs({...}) do
            if output then
                output = string.format("%s %s", output, tostring(value))
            else
                output = tostring(value)
            end
        end
        for key, value in ipairs(patterns) do
            if string.match(output, value[1]) then
                output = string.gsub(output, value[1], value[2])
            end
        end
        sampAddChatMessage(output, color)
    end
end

local friends = (function()
    local ini = inicfg.load({
        friends = {}
    })

    local this = {
        index = ini.friends,
        color = FRIEND_COLOR,
        hash = {}
    }

    function this:rehash()
        self.hash = {}
        for i, v in ipairs(self.index) do
            self.hash[v] = i
        end
    end

    function this:exist(nickname)
        return self.hash[nickname]
    end

    function this:insert(nickname)
        if self:exist(nickname) then
            return false
        else
            table.insert(self.index, nickname)
            self.hash[nickname] = #self.index
            inicfg.save(ini)
            return true
        end
    end

    function this:remove(nickname)
        local i = self:exist(nickname)
        if i then
            table.remove(self.index, i)
            self:rehash()
            inicfg.save(ini)
            return true
        else
            return false
        end
    end

    this:rehash()

    return this
end)()

function sampEvents.onSendCommand(arguments)
    local command, parameters = arguments:match("/(%S+) ?(.*)")
    if command == "frd" then
        local id, nickname = tonumber(parameters)

        if id then
            if sampIsPlayerConnected(id) then
                nickname = sampGetPlayerNickname(id)
            else
                chat("Игрок не подключен к серверу.")
                return false
            end
        else
            nickname = parameters
        end

        local result = friends:insert(nickname)

        if result then
            chat(("Игрок {HEX}%s{} был добавлен в список друзей."):format(nickname))
        else
            chat("Не удалось добавить игрока в список друзей.")
        end

        return false
    elseif command == "frdel" then
        local id, nickname = tonumber(parameters)

        if id then
            if sampIsPlayerConnected(id) then
                nickname = sampGetPlayerNickname(id)
            else
                chat("Игрок не подключен к серверу.")
                return false
            end
        else
            nickname = parameters
        end

        local result = friends:remove(nickname)

        if result then
            chat(("Игрок {HEX}%s{} был удален из списка друзей."):format(nickname))
        else
            chat("Не удалось удалить игрока из списка друзей.")
        end

        return false
    elseif command == "frsp" then
        local output = "{FFFFFF}"

        for index, value in ipairs(friends.index) do
            output = ("%s\n%s"):format(output, value)
        end

        sampShowDialog(0, "Friends", output, "Close", "", 0)
        return false
    elseif command == "frinfo" then
        sampShowDialog(0, "Friends", HELP, "Close", "", 0)
        return false
    end
end

function sampEvents.onSendGiveDamage(id)
    if sampIsPlayerConnected(id) and friends:exist(sampGetPlayerNickname(id)) then
        printStyledString("~y~FRIENDLY ~r~FIRE", 1000, 7)
    end
end

function sampEvents.onPlayerStreamIn(id, team, model, position, rotation, color, fightingStyle)
    if sampIsPlayerConnected(id) and friends:exist(sampGetPlayerNickname(id)) then
        return { id, team, model, position, rotation, friends.color, fightingStyle }
    end
end

function sampEvents.onSetPlayerColor(id, color)
    if sampIsPlayerConnected(id) and friends:exist(sampGetPlayerNickname(id)) then
        return { id, friends.color }
    end
end

function sampEvents.onPlayerJoin(id, color, isNpc, nickname)
    if friends:exist(nickname) then
        return { id, friends.color, isNpc, nickname }
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: Wasta