help_items = [[Статья 1
Статья 2
Статья 3
Статья 4]]
help_messages = {}
help_messages["Статья 1"] = [[Очень много текста. Ага!]]
help_messages["Статья 2"] = [[Тут тоже впринципе много текста1
23
45
67
8]]
help_messages["Статья 3"] = [[А вот здесь ничего:(]]
help_messages["Статья 4"] = [[Статейка №4]]
---------------------------------------------------------------------------------------------
require "lib.moonloader"
require "lib.sampfuncs"
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do
wait(400)
end
sampRegisterChatCommand("rphelp", cmd_showDialog)
isDialogVisible = false
local res, btn, list_item
while true do
if isDialogVisible then
res, btn, list_item = sampHasDialogRespond(450)
if res then
isDialogVisible = false
if btn == 1 then showHelp(sampGetListboxItemText(list_item)) end
end
--[[res, btn = sampHasDialogRespond(451)
if res then
isDialogVisible = false
if btn == 1 then cmd_showDialog() end
end]]
end
wait(0)
end
end
function cmd_showDialog()
_sampShowDialog(450, "УК", help_items, "Выбрать", "Закрыть", DIALOG_STYLE_LIST)
end
function _sampShowDialog(--[[int]] id, --[[string]] caption, --[[string]] text, --[[string]] button1, --[[string]] button2, --[[int]] style) -- 0B3B
isDialogVisible = true
sampShowDialog(id, caption, text, button1, button2, style)
end
function showHelp(name)
if name == nil then return end
local msg = help_messages[name]
if msg ~= nil then
--_sampShowDialog(451, name, msg, "В главное меню", "Закрыть", DIALOG_STYLE_MSGBOX)
sampAddChatMessage(name .. ":", 0xFFFF00)
for _,v in ipairs(msg:split("\n")) do
sampAddChatMessage(v, 0xFFFFFF)
end
end
end
function string:split(delimiter) -- jaredallard/string.split.lua
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end