imgui.button

Neil_

Известный
Автор темы
204
32
Версия MoonLoader
Другое
Сделал ради теста, ибо мне нечего делать такую штуку
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local sampev = require "lib.samp.events"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("test", function(arg)
        arg = tonumber(arg)
        if arg == nil or arg == '' then
            sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
        else
            if arg >= 101 then
                sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
        menu.v = not menu.v
        for i = 1,1003 do
       res, playerped = sampGetCharHandleBySampPlayerId(i)
        if res then
            x,y,z = getCharCoordinates(playerped)
            xq,yq,zq =  getCharCoordinates(PLAYER_PED)
            dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
            if dist <= arg then
                nick = sampGetPlayerNickname(i)
               end
            end
        end
    end
end
end)

while true do
    wait(0)
    imgui.Process = menu.v
    end
    end

function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
                        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
                        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
                        imgui.Begin('VKCoin', menu, imgui.WindowFlags.NoResize)
                        imgui.Button(nick)
                    imgui.End()
                end
            end
как сделать, чтобы в imgui.Button выводились все ники которые были получены, а не 1
 
Решение
Сделал ради теста, ибо мне нечего делать такую штуку
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local sampev = require "lib.samp.events"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("test", function(arg)
        arg = tonumber(arg)
        if arg == nil or arg == '' then
            sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
        else
            if arg >= 101 then
                sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
        menu.v = not menu.v
        for i = 1,1003 do...

qdIbp

Автор темы
Проверенный
1,450
1,191
Сделал ради теста, ибо мне нечего делать такую штуку
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local sampev = require "lib.samp.events"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("test", function(arg)
        arg = tonumber(arg)
        if arg == nil or arg == '' then
            sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
        else
            if arg >= 101 then
                sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
        menu.v = not menu.v
        for i = 1,1003 do
       res, playerped = sampGetCharHandleBySampPlayerId(i)
        if res then
            x,y,z = getCharCoordinates(playerped)
            xq,yq,zq =  getCharCoordinates(PLAYER_PED)
            dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
            if dist <= arg then
                nick = sampGetPlayerNickname(i)
               end
            end
        end
    end
end
end)

while true do
    wait(0)
    imgui.Process = menu.v
    end
    end

function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
                        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
                        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
                        imgui.Begin('VKCoin', menu, imgui.WindowFlags.NoResize)
                        imgui.Button(nick)
                    imgui.End()
                end
            end
как сделать, чтобы в imgui.Button выводились все ники которые были получены, а не 1
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local on = require "lib.samp.events"

local names = {}

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand('na', function() print(unpack(names))end)
        sampRegisterChatCommand("test", function(arg)
            arg = tonumber(arg)
            if arg == nil or arg == '' then sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
            elseif arg >= 101 then sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
                menu.v = not menu.v
                for i = 1,1003 do
                    res, playerped = sampGetCharHandleBySampPlayerId(i)
                    if res then
                        x,y,z = getCharCoordinates(playerped)
                        xq,yq,zq = getCharCoordinates(PLAYER_PED)
                        dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
                        if dist <= arg then
                            nick = sampGetPlayerNickname(i)
                            --print(nick)
                            table.insert(names,nick--[[..'\n']])
                        end
                    end
                end
            end
        end)

    while true do wait(0)
        imgui.Process = menu.v
    end
end


function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окошко', menu, imgui.WindowFlags.NoResize)
    
        for i = 1, 10 do imgui.Spacing(imgui.Text(names[i])) end
        imgui.Button('ok')
        imgui.End()
    end
end
лучше так

потому что это крашит
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local on = require "lib.samp.events"

local names = {}

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand('na', function() print(unpack(names))end)
        sampRegisterChatCommand("test", function(arg)
            arg = tonumber(arg)
            if arg == nil or arg == '' then sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
            elseif arg >= 101 then sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
                menu.v = not menu.v
                for i = 1,1003 do
                    res, playerped = sampGetCharHandleBySampPlayerId(i)
                    if res then
                        x,y,z = getCharCoordinates(playerped)
                        xq,yq,zq = getCharCoordinates(PLAYER_PED)
                        dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
                        if dist <= arg then
                            nick = sampGetPlayerNickname(i)
                            --print(nick)
                            table.insert(names,nick--[[..'\n']])
                        end
                    end
                end
            end
        end)

    while true do wait(0)
        imgui.Process = menu.v
    end
end


function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окошко', menu, imgui.WindowFlags.NoResize)
    
        for i = 1, 10 do imgui.Spacing(imgui.Button(names[i])) end
        --imgui.Button('ok')
        imgui.End()
    end
end
Но выбирать тебе
 

qdIbp

Автор темы
Проверенный
1,450
1,191
Сделал ради теста, ибо мне нечего делать такую штуку
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local sampev = require "lib.samp.events"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("test", function(arg)
        arg = tonumber(arg)
        if arg == nil or arg == '' then
            sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
        else
            if arg >= 101 then
                sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
        menu.v = not menu.v
        for i = 1,1003 do
       res, playerped = sampGetCharHandleBySampPlayerId(i)
        if res then
            x,y,z = getCharCoordinates(playerped)
            xq,yq,zq =  getCharCoordinates(PLAYER_PED)
            dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
            if dist <= arg then
                nick = sampGetPlayerNickname(i)
               end
            end
        end
    end
end
end)

while true do
    wait(0)
    imgui.Process = menu.v
    end
    end

function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
                        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
                        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
                        imgui.Begin('VKCoin', menu, imgui.WindowFlags.NoResize)
                        imgui.Button(nick)
                    imgui.End()
                end
            end
как сделать, чтобы в imgui.Button выводились все ники которые были получены, а не 1
Немного доработал код

Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local menu = imgui.ImBool(false)
local on = require "lib.samp.events"

local names = {}
niks = ''

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand('na', function() print(unpack(names))end)
        sampRegisterChatCommand("test", function(arg)
            arg = tonumber(arg)
            if arg == nil or arg == '' then sampAddChatMessage('Введите дистанцию от 1 до 100!', -1)
            elseif arg >= 101 then sampAddChatMessage('Используйте от 1 до 100.', -1)
            else
                menu.v = not menu.v
                for i = 1,1003 do
                    res, playerped = sampGetCharHandleBySampPlayerId(i)
                    if res then
                        x,y,z = getCharCoordinates(playerped)
                        xq,yq,zq = getCharCoordinates(PLAYER_PED)
                        dist = getDistanceBetweenCoords3d(xq,yq,zq,x,y,z)
                        if dist <= arg then
                            nick = sampGetPlayerNickname(i)
                            niks = niks..' '..nick
                            nn = string.gsub(niks,'%P', '')
                            table.insert(names,nick--[[..'\n']])
                         
                        end
                    end
                end
            end
        end)
 
    while true do wait(0)
        imgui.Process = menu.v
    end
end


function imgui.OnDrawFrame()
    if menu.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(250, 240), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окошко', menu, imgui.WindowFlags.NoResize)
        for i = 1,nn:len() do imgui.Spacing()
            if imgui.Button(names[i]) then
                print(names[i])
           
            end
        end
        imgui.End()
    end
end
Он выведет дофига ников в виде кнопок пока for не лопнет
 

Вложения

  • sa-mp-008.png
    sa-mp-008.png
    65.1 KB · Просмотры: 11
Последнее редактирование: