- 20
- 2
- Версия MoonLoader
- .026-beta
Не могу разобраться с авто принятием админ формы, чет с регуляркой не то. хелп пж
Вот код
Строка из чатлога - [12:22:57] {00aaff}[A]{ffffff} Artemich_Calculator: /test
Вот код
Lua:
function samp.onServerMessage(text)
if active_forma then
if text:find('%[.*%] (%w+_?%w+): [Forma] +') then
printStyledString("Form skipped", 1000, 4)
active_forma = false
stop_forma = true
end
end
for k,v in ipairs(allForms) do
if text:match("%[.*%] "..getMyNick()..": /"..v.."%s") then
return true
else
if text:match("%[.*%] (%w+_?%w+): /"..v.."%s") then
admin_nick, admin_other = text:match("%[.*%] (%w+_?%w+): /"..v.."%s(.*)")
sampAddChatMessage('{FF0000}[Info] {FF8C00}Пришла форма, чтобы принять ее нажмите >> K << | Чтобы отклонить >> P <<', 0xFFFF0000)
active_forma = true
cmd = v
forma()
end
end
end
end
function forma()
if active_forma then
lua_thread.create(function()
lasttime = os.time()
lasttimes = 0
time_out = 10
while lasttimes < time_out do
lasttimes = os.time() - lasttime
wait(0)
printStyledString("ADMIN FORM " .. time_out - lasttimes .. " WAIT", 1000, 4)
if lasttimes == time_out then
active_forma = false
printStyledString("Forma skipped", 1000, 4)
end
if isKeyJustPressed(VK_K) and not sampIsChatInputActive() and not sampIsDialogActive() then
printStyledString("Admin form accepted", 1000, 4)
sampSendChat("/"..cmd.." "..admin_other.." || "..admin_nick)
wait(1000)
sampSendChat('/a [Forma] +')
lasttimes = 11
active_forma = false
elseif isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() then
printStyledString('You missed the form', 1000, 4)
lasttimes = 11
active_forma = false
end
if stop_forma then
lasttimes = 11
active_forma = false
break
end
end
end)
else
if isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() then
printStyledString('You can’t skip the form temporarily', 1000, 4)
end
end
end
function getMyNick()
local result, id = sampGetPlayerIdByCharHandle(playerPed)
if result then
local nick = sampGetPlayerNickname(id)
return nick
end
end
function getMyId()
local result, id = sampGetPlayerIdByCharHandle(playerPed)
if result then
return id
end
end
Строка из чатлога - [12:22:57] {00aaff}[A]{ffffff} Artemich_Calculator: /test