Подскажите почему не работает функция?

Diego_Sativa

Известный
Автор темы
578
59
Версия SA-MP
  1. 0.3.7-R2
Скажите что не так? Почему не работает function worm()?
и как это исправить?
Lua:
script_author('checkdasound')

local events = require ('samp.events')
require ('moonloader')
require('memory').fill(0x00531155, 0x90, 5, true)

local act = false

function main()
	while not isSampAvailable() do wait(100) end
	sampRegisterChatCommand('rblk', rblk)
	sampRegisterChatCommand('worm', worm)
	while true do wait(-1) end
end

function worm()
	while true do
	 wait(2000)
	 sampSendChat('/fish findworm')
	end
end

function rblk()
	act = not act
	if act then
		sampAddChatMessage('Бот рыбалки включен.', -1)
	else
		sampAddChatMessage('Бот рыбалки выключен.', -1)
	end
end

function events.onDisplayGameText(style, time, text)
	-- print('Style: '..style..' Time: '..time..' Text: '..text)
	if act then
		if style == 6 and text == '~n~~n~~y~!' or style == 6 and text == '~n~~n~~n~~r~!' then
			lua_thread.create(function()
				lockPlayerControl(true)
				setVirtualKeyDown(VK_LMENU, true)
				wait(50)
				setVirtualKeyDown(VK_LMENU, false)
				lockPlayerControl(false)
			end)
		end
	end
end

function events.onServerMessage(color, text)
	-- print('Color: '..color..' Text: '..text)
	if act then
		if color == -1342193921 then
			if text:find('Вы оснастили') or text:find('Вы наживили') or text:find('Вы поймали') then
				lua_thread.create(function()
					wait(3500)
					lockPlayerControl(true)
					setVirtualKeyDown(VK_LMENU, true)
					wait(50)
					setVirtualKeyDown(VK_LMENU, false)
					lockPlayerControl(false)
				end)
			elseif text:find('Рыба сорвалась') then
			
				test = math.random(1, 20)
				print(test)
				lua_thread.create(function()
					if test == 12 or test == 20 then
						wait(1000)
						setVirtualKeyDown(VK_D, true)
						wait(50)
						setVirtualKeyDown(VK_D, false)
						wait(2450)
						lockPlayerControl(true)
						setVirtualKeyDown(VK_LMENU, true)
						wait(50)
						setVirtualKeyDown(VK_LMENU, false)
						lockPlayerControl(false)
					else
						wait(3500)
						lockPlayerControl(true)
						setVirtualKeyDown(VK_LMENU, true)
						wait(50)
						setVirtualKeyDown(VK_LMENU, false)
						lockPlayerControl(false)
					end
				end)
			end
		end
	end
end