- 327
- 78
- Версия SA-MP
-
- 0.3.7-R3
Делал я значит новый фаст ган через меню /gun скрипт в целом находит все нужные оружки но почему-то на отрез не может найти Тек 9 пробуя разные вариации пришел к абсолютно никакому результату
Lua:
script_name("FastGun")
script_author("MR.Kaneki")
local se = require "samp.events"
local info = nil
-- Команды / названия
local Weapon = {
["fgc"] = "COLT",
["fgd"] = "DESERT EAGLE",
["fgs"] = "Дробовик",
["fgu"] = "Micro Tec-9",
["fgmp"] = "MP5",
["fgak"] = "AK47",
["fgm"] = "M4",
["fgr"] = "Винтовка"
}
function se.onSendCommand(cmd)
local name, args = cmd:match("^/([^%s]+)%s*(.*)")
if Weapon[name] then
if info then
sampAddChatMessage("Подожди...", -1)
return false
end
local count = tonumber(args) or 50
info = {
step = 0,
weapon = Weapon[name],
count = count
}
return {"/gun"}
end
end
function se.onShowDialog(id, style, title, btn1, btn2, text)
if not info then return end
-- Меню оружия
if info.step == 0 and title:find("Меню оружия") then
local lines = {}
for line in text:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
local foundIndex = nil
for i, line in ipairs(lines) do
local upper = line:upper()
if upper:find(info.weapon) then
foundIndex = i - 1 -- SAMP index
break
end
end
if foundIndex then
sampSendDialogResponse(id, 1, foundIndex, nil)
info.step = 1
else
sampAddChatMessage("Оружие не найдено!", -1)
info = nil
end
return false
end
-- Ввод количества
if info.step == 1 and text:find("Введите количество") then
sampSendDialogResponse(id, 1, nil, tostring(info.count))
info = nil
return false
end
end