Замени это
string.find(text_1, "Добро пожаловать на Diamond Role Play")
на это
text_1:find("Добро пожаловать на Diamond Role Play")
два полностью идентичных варианта
Потому что может быть изначально ты переменную textTwo задаешь как строку...
local textTwo = 0
роли не играет здесь
Ошибочка, вот код нормальный, текст оно выводит, но qq нет, как исправить?:
табулируй код для своего же удобства, ты сам же не видишь, что последние три строки вышли за пределы onServerMessage, что работать и не должно
твой код:
script_name('Government Tools')
script_author('ABulkin')
local sampev = require 'lib.samp.events'
local textTwo = ''
function sampev.onServerMessage(color, text)
if text:find(" Объявление проверил ") then
sampAddChatMessage(text, -1)
textTwo = 2
end
end
if textTwo == 2 then
sampAddChatMessage('qq',-1)
end
я не знаю что именно ты хочешь сделать:
если только вывести qq в чат, то сойдет и такой код:
script_name("Government Tools")
script_author("ABulkin")
local sampev = require("lib.samp.events")
function sampev.onServerMessage(color, text)
if text:find(" Объявление проверил ") then
sampAddChatMessage("qq", -1)
end
end
если тебе нужно именно заставить тригернуть код в другом месте за пределами onServerMessage, то пробуй это:
script_name("Government Tools")
script_author("ABulkin")
local sampev = require("lib.samp.events")
local trigger
function sampev.onServerMessage(color, text)
if text:find(" Объявление проверил ") then
trigger = true
end
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
repeat wait(0) until isSampAvailable()
while true do
wait(0)
if trigger then
trigger = false
sampAddChatMessage("qq", -1)
end
end
end
то же самое, но без main:
script_name("Government Tools")
script_author("ABulkin")
local sampev = require("lib.samp.events")
local trigger
function sampev.onServerMessage(color, text)
if text:find(" Объявление проверил ") then
trigger = true
end
end
lua_thread.create(function()
repeat wait(0) until isSampAvailable()
while true do
wait(0)
if trigger then
trigger = false
sampAddChatMessage("qq", -1)
end
end
end)