Взаимодействие с игроком

AngelMAILS228

Участник
Автор темы
79
7
Версия MoonLoader
.026-beta
Как сделать чтобы когда я целился на человека и над ним появился зеленый маркер, я нажал клавишу и у меня вылезло им гуи меню где я могу его повысить и тд.
sa-mp-192.png
 

Dmitriy Makarov

25.05.2021
Проверенный
2,478
1,113
Lua:
-- В самый верх, где local'ки
local playerid = -1

-- Бесконечный цикл
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
if valid and doesCharExist(ped) then
    local result, id = sampGetPlayerIdByCharHandle(ped)
    if result and isKeyJustPressed(VK_Q) then -- На ПКМ+Q
        main_window_state.v = not main_window_state.v
        playerid = id
    end
end


-- OnDrawFrame
-- if main_window_state.v then
imgui.Begin(u8"Взаимодействие с "..sampGetPlayerNickname(tostring(playerid)).."["..tostring(playerid).."]", main_window_state.v)
if imgui.Button(u8"Показать пасспорт") then
    sampSendChat("/pass "..tostring(playerid))
end
-- Если нужен NickName: sampGetPlayerNickname(tostring(playerid))
-- Если нужен NickName без _ : sampGetPlayerNickname(tostring(playerid)):gsub('_', ' ')
-- Если нужен ID: tostring(playerid)
 
  • Нравится
Реакции: Sakura San

andrey_hacker

Известный
274
88
Lua:
local keys = require "vkeys"
require "lib.moonloader"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sw, sh = getScreenResolution()
local m_w_s = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end   
    while true do
        wait (0)
        local res, tar = getCharPlayerIsTargeting(PLAYR_HANDLE)
        if res then res, tarId = sampGetPlayerIdByCharHandle(tar) end
        if res and isKeyJustPressed(VK_B) then
            wind()
        end
        if m_w_s.v == false then
            imgui.Process = false
        end       
    end
end
function imgui.OnDrawFrame()
    imgui.SetNextWindowSize(imgui.ImVec2(300,255), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw/2),(sh/2)), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.Begin(u8'Меню повышения', m_w_s)
    if imgui.Button(u8'Повысить')then
        sampSendChat('/повышение ' ..tarId)
    end
    if imgui.Button(u8'Понизить') then
        sampSendChat(u8'/повышение')
    end
    imgui.End()   
end
function wind()
m_w_s.v = not m_w_s.v
imgui.Process = m_w_s.v
end
Команды сам добавь, я не знаю как повысить/понизить