local mem = require "memory"
local imgui = require 'imgui'
local windowState = {
visible = false,
nameTagEnabled = false
}
local NTdist, NTwalls, NTshow
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("nametag", function()
windowState.visible = not windowState.visible
end)
while true do
wait(0)
imgui.Process = windowState.visible
if isKeyJustPressed(116) then -- ALT+F3
windowState.nameTagEnabled = not windowState.nameTagEnabled
updateNameTagState()
end
end
end
function updateNameTagState()
if windowState.nameTagEnabled then
nameTagOn()
else
nameTagOff()
end
end
function nameTagOn()
local pStSet = sampGetServerSettingsPtr()
NTdist = mem.getfloat(pStSet + 39)
NTwalls = mem.getint8(pStSet + 47)
NTshow = mem.getint8(pStSet + 56)
mem.setfloat(pStSet + 39, 1488.0)
mem.setint8(pStSet + 47, 0)
mem.setint8(pStSet + 56, 1)
end
function nameTagOff()
if NTdist then
local pStSet = sampGetServerSettingsPtr()
mem.setfloat(pStSet + 39, NTdist)
mem.setint8(pStSet + 47, NTwalls)
mem.setint8(pStSet + 56, NTshow)
end
end
function imgui.OnDrawFrame()
if not windowState.visible then return end
windowState.visible = imgui.Begin("NameTag Settings", windowState.visible)
if windowState.visible then
local changed = imgui.Checkbox("Включить ники", imgui.ImBool(windowState.nameTagEnabled))
if changed then
windowState.nameTagEnabled = not windowState.nameTagEnabled
updateNameTagState()
end
if imgui.IsItemHovered() then
imgui.SetTooltip("Включает/выключает отображение ников\nГорячая клавиша: ALT+F3")
end
imgui.End()
end
end
function onExitScript()
nameTagOff()
end