script_name("Auto /heal")
script_version("1.0")
script_authors("xNokiaAngelx")
local sampev = require 'lib.samp.events'
local enable = true
local interiorCheck = false
local interiorCheck2 = false
local pzuCheck = true
local enter = false
-------------------------------------------------------------------------
function main()
repeat wait(0)
until isSampAvailable()
while true do
wait(0)
local cmdResult = sampIsChatCommandDefined("autoheal")
if not cmdResult then
local result = sampRegisterChatCommand("autoheal", toggleScript)
end
if interiorCheck and pzuCheck then sendCmd("/heal") interiorCheck = false end
end
end
-------------------------------------------------------------------------
function toggleScript()
enable = not enable
if enable then
sampAddChatMessage("[AUTO /gydytis] {34eb37}DISABLED. {b88d0f}DISABLE su /autoheal.", 0x1cd031)
else
sampAddChatMessage("[AUTO /heal] {eb3434}ENABLE. {b88d0f}ENABLE su /autoheal.", 0x1cd031)
end
end
-------------------------------------------------------------------------
function sampev.onSendInteriorChangeNotification(interior)
if not enable then return end
if interior ~= 0 then interiorCheck = true interiorCheck2 = true end
end
-------------------------------------------------------------------------
function sendCmd(cmd)
sampSendChat(cmd)
end
-------------------------------------------------------------------------
function sampev.onServerMessage(color, text)
if not enable then return end
if interiorCheck2 and pzuCheck and string.find(text, "Unknown command") then enter = true end
interiorCheck2 = false
if enter then
enter = false
sampAddChatMessage("[AUTO /heal] You don't have the key.", 0xff0000)
return false
end
end
-------------------------------------------------------------------------
function sampev.onTogglePlayerSpectating(state)
if state then pzuCheck = false else pzuCheck = true end
end