Что не так в коде ? getCharHealth

cort

Активный
Автор темы
275
79
Lua:
if isPlayerPlaying(playerHandle) then
            if getCharHealth(playerHandle) <= 30 then
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
                wait(3000)
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
            end
        end

Что не так ? Почему-то не работает\

Lua:
[ML] (error) MinerBot.lua: opcode '0226' call caused an unhandled exception
stack traceback:
    [C]: in function 'getCharHealth'
    D:\My Games\gtacr\moonloader\MinerBot.lua:17: in function <D:\My Games\gtacr\moonloader\MinerBot.lua:3>
[ML] (error) MinerBot.lua: Script died due to an error. (0E8C6B7C)
 

YarikVL

Известный
Проверенный
4,783
1,807
Lua:
if isPlayerPlaying(playerHandle) then
            if getCharHealth(playerHandle) <= 30 then
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
                wait(3000)
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
            end
        end

Что не так ? Почему-то не работает\

Lua:
[ML] (error) MinerBot.lua: opcode '0226' call caused an unhandled exception
stack traceback:
    [C]: in function 'getCharHealth'
    D:\My Games\gtacr\moonloader\MinerBot.lua:17: in function <D:\My Games\gtacr\moonloader\MinerBot.lua:3>
[ML] (error) MinerBot.lua: Script died due to an error. (0E8C6B7C)
Не пробовал получить хэндл по своему ид:
result, playerHandle = sampGetCharHandleBySampPlayerId(id)
 

krim

Известный
304
132
Lua:
if isPlayerPlaying(playerHandle) then
            if getCharHealth(playerHandle) <= 30 then
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
                wait(3000)
                EmulateKey(VK_4, true)
                wait(20)
                EmulateKey(VK_4, false)
            end
        end

Что не так ? Почему-то не работает\

Lua:
[ML] (error) MinerBot.lua: opcode '0226' call caused an unhandled exception
stack traceback:
    [C]: in function 'getCharHealth'
    D:\My Games\gtacr\moonloader\MinerBot.lua:17: in function <D:\My Games\gtacr\moonloader\MinerBot.lua:3>
[ML] (error) MinerBot.lua: Script died due to an error. (0E8C6B7C)
getCharHealth - надо юзать PLAYER_PED