Ник игрока

Slava Stetem

Участник
Автор темы
106
5
Версия MoonLoader
.027.0-preview
Помогите пожалуста мне нужно при навидение на игрока в команду писался ник
Например я ввожу команду "/test" Мне скрипт пишет наведись на игрока и нажми кнопку 1 и после в чат будет писать команду /id nick
 

|| NN - NoName ||

Известный
1,049
630
Lua:
local on = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', function() lua_thread.create(test) end)
    wait(-1)
end
function test()
    on = not on
    sampAddChatMessage('Наведитесь на игрока и нажминет цифру 1', -1)
    while on do wait(0)
        local res, ped = getCharPlayerIsTargeting(PLAYER_PED)
        if isKeyJustPressed(49) and res then
            local res, id = sampGetPlayerIdByCharHandle(ped)
            if res then 
                local nick = sampGetPlayerNickname(id)
                sampSendChat('/id '..nick)
                on = false
            end
        end
    end
end

Проверяй
 

Slava Stetem

Участник
Автор темы
106
5
Lua:
local on = false
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', function() lua_thread.create(test) end)
    wait(-1)
end
function test()
    on = not on
    sampAddChatMessage('Наведитесь на игрока и нажминет цифру 1', -1)
    while on do wait(0)
        local res, ped = getCharPlayerIsTargeting(PLAYER_PED)
        if isKeyJustPressed(49) and res then
            local res, id = sampGetPlayerIdByCharHandle(ped)
            if res then
                local nick = sampGetPlayerNickname(id)
                sampSendChat('/id '..nick)
                on = false
            end
        end
    end
end

Проверяй
Не работает
 

wulfandr

Известный
637
260
Lua:
local activate = false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', function()
        activate = not activate if activate then sampAddChatMessage('Нацельтесь на игрока и нажмите цифру 1.', -1) else sampAddChatMessage('Выключен.', -1) end
    end)
    while true do wait(0)
        if activate then
            local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
            if valid then
                local _, id = sampGetPlayerIdByCharHandle(ped)
                if wasKeyPressed(0x31) then
                    local nick = sampGetPlayerNickname(id)
                    sampSendChat('/id '..nick)
                    activate = false
                end
            end
        end
    end
end
 

Slava Stetem

Участник
Автор темы
106
5
Lua:
local activate = false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', function()
        activate = not activate if activate then sampAddChatMessage('Нацельтесь на игрока и нажмите цифру 1.', -1) else sampAddChatMessage('Выключен.', -1) end
    end)
    while true do wait(0)
        if activate then
            local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
            if valid then
                local _, id = sampGetPlayerIdByCharHandle(ped)
                if wasKeyPressed(0x31) then
                    local nick = sampGetPlayerNickname(id)
                    sampSendChat('/id '..nick)
                    activate = false
                end
            end
        end
    end
end
Супер а не подскажеш как в кнопку ImGUI добавить?