скрипт

Oki_Bern

Участник
Автор темы
169
6
Версия MoonLoader
Другое
Хотел сделать, что бы автоматом юзало healme в инте, но почему то не юзает его, в чем проблемка?
Lua:
local directIni = 'Healme.ini'
local inicfg = require 'inicfg'
local ini = inicfg.load({
    set = {
        healme = true,
    }}, directIni)
inicfg.save(ini, directIni)
local autohealme = true
local health = 0
local result, id = 0, 0
function Healme()
 while true do
    wait(100)
    if ini.set.healme then
      repeat
        wait(100)
        if autohealme then
           result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
           health = sampGetPlayerHealth(id)
          if health < 100 then
            wait(1000)
            result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            health = sampGetPlayerHealth(id)
            if health < 100 then
                sampSendChat("/healme")
            end
          else
            wait(2000)
            autohealme = false
          end
        end
      until not autohealme
    end
  end
end
 
  • Эм
Реакции: recxvery

recxvery

Участник
90
27
попробуй, вроде так
Lua:
local inicfg = require('inicfg')
local iniFilename = 'HealMe.ini'
local ini = inicfg.load({
    settings = {
        status = false
    }
}, iniFilename)
inicfg.save(ini, iniFilename)

local hp = getCharHealth(PLAYER_PED)

function main()
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('getinterior', function()
        interior = getActiveInterior()
        print(interior)
    end)
    sampRegisterChatCommand('autoheal', function()
        ini.settings.status = not ini.settings.status
        inicfg.save(ini, iniFilename)
        sampAddChatMessage('Автолечение ' .. (ini.settings.status and 'включено' or 'выключено'))
    end)
   
    wait(-1)
end

require('lib.samp.events').onSetInterior = function(id)
    if ini.settings.status then
        if id == --[[ID интерьера]] and hp < 100 then
            sampSendChat('/healme')
        end
    end
end
 
  • Bug
  • Грустно
Реакции: VanoKLR и MLycoris

VanoKLR

Известный
676
397
попробуй, вроде так
Lua:
local inicfg = require('inicfg')
local iniFilename = 'HealMe.ini'
local ini = inicfg.load({
    settings = {
        status = false
    }
}, iniFilename)
inicfg.save(ini, iniFilename)

local hp = getCharHealth(PLAYER_PED)

function main()
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('getinterior', function()
        interior = getActiveInterior()
        print(interior)
    end)
    sampRegisterChatCommand('autoheal', function()
        ini.settings.status = not ini.settings.status
        inicfg.save(ini, iniFilename)
        sampAddChatMessage('Автолечение ' .. (ini.settings.status and 'включено' or 'выключено'))
    end)
  
    wait(-1)
end

require('lib.samp.events').onSetInterior = function(id)
    if ini.settings.status then
        if id == --[[ID интерьера]] and hp < 100 then
            sampSendChat('/healme')
        end
    end
end
Нет, оно сработает только если зайти в инту. Тоесть надо выходить и входить постоянно что бы работало, тк это то просто событие
 

recxvery

Участник
90
27
Нет, оно сработает только если зайти в инту. Тоесть надо выходить и входить постоянно что бы работало, тк это то просто событие
ну я хз на каком проекте хилми есть и что там в этих интах, с аризоной легче бы было
 

VanoKLR

Известный
676
397
попробуй, вроде так
Lua:
local inicfg = require('inicfg')
local iniFilename = 'HealMe.ini'
local ini = inicfg.load({
    settings = {
        status = false
    }
}, iniFilename)
inicfg.save(ini, iniFilename)

local hp = getCharHealth(PLAYER_PED)

function main()
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('getinterior', function()
        interior = getActiveInterior()
        print(interior)
    end)
    sampRegisterChatCommand('autoheal', function()
        ini.settings.status = not ini.settings.status
        inicfg.save(ini, iniFilename)
        sampAddChatMessage('Автолечение ' .. (ini.settings.status and 'включено' or 'выключено'))
    end)
  
    wait(-1)
end

require('lib.samp.events').onSetInterior = function(id)
    if ini.settings.status then
        if id == --[[ID интерьера]] and hp < 100 then
            sampSendChat('/healme')
        end
    end
end
Тут половина кода - говно
1 - получает хп один раз при загрузке скрипт ( частая ошибка у новичков )
2 - получение интерьера через ивент ( данный способ работает 1 раз когда ты ВХОДИШ в интерьер

Критикуешь? предлагай. Вот я и предлагаю свою версию
Lua:
local inicfg = require('inicfg')
local iniFilename = 'HealMe.ini'
local ini = inicfg.load({
    settings = {
        status = false
    }
}, iniFilename)
inicfg.save(ini, iniFilename)

function main()
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('getinterior', function()
        interior = getActiveInterior()
        print(interior)
    end)
    sampRegisterChatCommand('autoheal', function()
        ini.settings.status = not ini.settings.status
        inicfg.save(ini, iniFilename)
        sampAddChatMessage('Автолечение ' .. (ini.settings.status and 'включено' or 'выключено'))
    end)
  
    while true do wait(0)
        if ini.settings.status and getActiveInterior() == "сюда твой айди интерьера" and getCharHealth(PLAYER_PED) < 50--[[тут значение меньше которого будет работать]] then
            sampSendChat("/healme")
        end
    end
end
 

Beluga111

Активный
257
57
Хотел сделать, что бы автоматом юзало healme в инте, но почему то не юзает его, в чем проблемка?
Lua:
local directIni = 'Healme.ini'
local inicfg = require 'inicfg'
local ini = inicfg.load({
    set = {
        healme = true,
    }}, directIni)
inicfg.save(ini, directIni)
local autohealme = true
local health = 0
local result, id = 0, 0
function Healme()
 while true do
    wait(100)
    if ini.set.healme then
      repeat
        wait(100)
        if autohealme then
           result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
           health = sampGetPlayerHealth(id)
          if health < 100 then
            wait(1000)
            result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            health = sampGetPlayerHealth(id)
            if health < 100 then
                sampSendChat("/healme")
            end
          else
            wait(2000)
            autohealme = false
          end
        end
      until not autohealme
    end
  end
end
Лучше установи уже готовое:
 

Oki_Bern

Участник
Автор темы
169
6
Лучше установи уже готовое:
мне для срп нужен, там в инте токо есть аптечки
 

Похожие темы

  1. Ответы
    2K
    Просмотры
    5M
  2. Ответы
    22
    Просмотры
    2M
  3. Ответы
    4K
    Просмотры
    1M
  4. Ответы
    0
    Просмотры
    553K