Не могу запросить модель ПЕРСОНАЖЕЙ

Ninthmoon

Известный
Автор темы
464
130
Версия MoonLoader
.026-beta
Апд 09.06.2022
Не могу запросить модель скинов Персонажей, например cj, truth, cesar, big bear, ogloc, woozie
Lua:
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)
local key = require 'vkeys'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local skin_id = imgui.ImBuffer(256)

function main()
    while true do wait(0)
        if wasKeyPressed(key.VK_Z) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        showCursor(true, true)
        imgui.SetNextWindowSize(imgui.ImVec2(500, 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos( imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окно', main_window_state)
        imgui.InputText(u8'Введите ID скина', skin_id)
        if imgui.Button(u8'Применить') then
            requestModel(skin_id.v)
            loadAllModelsNow()
            if hasModelLoaded(skin_id.v) and isModelAvailable(skin_id.v) and tonumber(skin_id.v) >= 5 and tonumber(skin_id.v) <= 311 then
                setPlayerModel(PLAYER_HANDLE, skin_id.v)
            end
        end
        imgui.End()
    end
end
Код:
opcode '09C7' call caused an unhandled exception
 
Последнее редактирование:

Ninthmoon

Известный
Автор темы
464
130
PLAYER_HANDLE вместо PLAYER_PED + делай проверку на загруженость модели и загружай её
не на все скины работает, в чём может быть проблема?
Lua:
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)
local key = require 'vkeys'
local skin = 4
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    while true do wait(0)
        if wasKeyPressed(key.VK_Z) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        showCursor(true, true)
        imgui.Begin(u8'Окно', main_window_state)
        imgui.Text(string.format(u8'Установить скин: %s', skin))
        if imgui.Button(u8'Применить') then
            requestModel(skin)
            loadAllModelsNow()
            if hasModelLoaded(skin) and isModelAvailable(skin) then
                setPlayerModel(PLAYER_HANDLE, skin)
            elseif hasModelLoaded(skin) == false or isModelAvailable(skin) == false then
                imgui.Text('Error')
            end
        end
        imgui.End()
    end
end
конкретно на модели 2, 3, 4 возможно и т.д.:
opcode '0247' call caused an unhandled exception
 
Последнее редактирование:

qdIbp

Автор темы
Проверенный
1,450
1,191
Попробуй может что выйдет

Lua:
local key = require 'vkeys'
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8


local main_window_state = imgui.ImBool(false)
local skin = imgui.ImBuffer(256)


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        
    while true do wait(0)
        if wasKeyPressed(key.VK_Z) then main_window_state.v = not main_window_state.v end
        imgui.Process = main_window_state.v
        imgui.ShowCursor = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos( imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окно', main_window_state)
            if imgui.Button(u8'Применить') then
                if #skin.v ~= 0 then
                    requestModel(skin.v)
                    loadAllModelsNow()
                    if hasModelLoaded(skin.v) and isModelAvailable(skin.v) and tonumber(skin.v) >= 0 and tonumber(skin.v) <= 311 then
                        setPlayerModel(PLAYER_HANDLE, skin.v)
                    else
                        sampAddChatMessage('Error',-1)
                    end
                else
                    sampAddChatMessage('Error введите ид скина',-1)
                end
            end imgui.SameLine()
            imgui.InputText(u8'id skin', skin)
        imgui.End()
    end
end
 

Ninthmoon

Известный
Автор темы
464
130
Попробуй может что выйдет

Lua:
local key = require 'vkeys'
local imgui = require 'imgui'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8


local main_window_state = imgui.ImBool(false)
local skin = imgui.ImBuffer(256)


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
      
    while true do wait(0)
        if wasKeyPressed(key.VK_Z) then main_window_state.v = not main_window_state.v end
        imgui.Process = main_window_state.v
        imgui.ShowCursor = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(500, 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos( imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окно', main_window_state)
            if imgui.Button(u8'Применить') then
                if #skin.v ~= 0 then
                    requestModel(skin.v)
                    loadAllModelsNow()
                    if hasModelLoaded(skin.v) and isModelAvailable(skin.v) and tonumber(skin.v) >= 0 and tonumber(skin.v) <= 311 then
                        setPlayerModel(PLAYER_HANDLE, skin.v)
                    else
                        sampAddChatMessage('Error',-1)
                    end
                else
                    sampAddChatMessage('Error введите ид скина',-1)
                end
            end imgui.SameLine()
            imgui.InputText(u8'id skin', skin)
        imgui.End()
    end
end
делаю для одиночной игры, если убрать всё лишнее ничего не измениться, не могу запросить модель скинов персонажей, а не рандомных нпц

Lua:
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)
local key = require 'vkeys'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local skin_id = imgui.ImBuffer(256)

function main()
    while true do wait(0)
        if wasKeyPressed(key.VK_Z) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        showCursor(true, true)
        imgui.SetNextWindowSize(imgui.ImVec2(500, 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos( imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Окно', main_window_state)
        imgui.InputText(u8'Введите ID скина', skin_id)
        if imgui.Button(u8'Применить') then
            requestModel(skin_id.v)
            loadAllModelsNow()
            if hasModelLoaded(skin_id.v) and isModelAvailable(skin_id.v) then
                setPlayerModel(PLAYER_HANDLE, skin_id.v)
            end
        end
        imgui.End()
    end
end
 
Последнее редактирование: