target и нажатие кнопки

KenDDD

Участник
Автор темы
15
3
Версия MoonLoader
.026-beta
Привет, можете подсказать как сделать таргет с нажатием кнопки для и получения айди, тоесть ты целишься(используешь target) и нажимаешь кнопку затем идет получение айди и вывод в чат, подскажите как это сделать?
 

qdIbp

Автор темы
Проверенный
1,383
1,139
Lua:
require "lib.moonloader"
require 'lib.vkeys'
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
sms = sampAddChatMessage
local Player_ID = -1

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowPos(imgui.ImVec2(50,350)) --местополож
        imgui.SetNextWindowSize(imgui.ImVec2(150, 100), imgui.Cond.FirstUseEver)--размер
        imgui.ShowCursor = false
        imgui.Begin('My window', main_window_state)
        if imgui.Button(u8('Цель '..Player_ID..'?')) then
            sms('id '..Player_ID,-1)
        end
        imgui.End()
    end
end

function main()
    sampRegisterChatCommand('cdd', function()main_window_state.v = not main_window_state.v end)
    while true do wait(0)
        if isKeyDown(VK_RBUTTON) then
            local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
            if result and doesCharExist(ped) then
                local success, id = sampGetPlayerIdByCharHandle(ped)
                if success then
                    local pname = sampGetPlayerNickname(id)
                    local pscore = sampGetPlayerScore(id)
                    Player_ID = id
                    main_window_state.v = true
                end
            end
        end
        imgui.Process = main_window_state.v
    end
end
Если нажата ПКМ
то выводит окно с кнопкой imgui
 
Последнее редактирование:
  • Bug
Реакции: Musaigen