А где проверки на: Отыкрытый чат, открытый диалог, открытую консоль сампфункса, и вообще на включенный курсор?kod:function main() repeat wait(0) until isSampAvailable() wait(0) while true do wait(0) if wasKeyPressed(0x5A) then -- 0x5A это Z клавиша, подберай себе тругой sampSendChat("/lock") end end end
Ну да, но каждый раз когда ты будешь к примеру писать в чат букву "Z" или в Диалог, или в консоль сампфункса, то скрипт будет отправлять "/lock" в чатмогу проверку на мозги сделать 😂
тут просто при нажатии Z - он вводит в чат /lock и нажимает enter
require "lib.moonloader"
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do
wait(0)
if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() then
sampSendChat("/lock")
end
if isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) then
sampSendChat("/key")
end
end
end
require 'lib.moonloader'
function main()
repeat wait(0) until isSampAvailable()
wait(0)
while true do
wait(0)
if isKeyJustPressed(0x4C) then -- L
sampSendChat("/lock")
end
if isKeyJustPressed(0x4B) then -- K
sampSendChat("/key")
end
end
end
function main()
repeat wait(0) until isSampAvailable()
wait(0)
sampRegisterChatCommand("k", k)
sampRegisterChatCommand("l", k)
while true do
wait(0)
if isKeyJustPressed(0x4C) and l then -- L
sampSendChat("/lock")
end
if isKeyJustPressed(0x4B) and k then -- K
sampSendChat("/key")
end
end
end
function k()
if k then
k = false
sampAddChatMessage("OFF")
else
k = false
sampAddChatMessage("ON")
end
end
function l()
if l then
l = false
sampAddChatMessage("OFF")
else
l = false
sampAddChatMessage("ON")
end
end
Код хуйня, можно было сделать намного лучше)@Валерия
это рабочий код, я просто перепутал клавиши вот и не работало, когда будет открыт чат оно не напишит.cod:require 'lib.moonloader' function main() repeat wait(0) until isSampAvailable() wait(0) while true do wait(0) if isKeyJustPressed(0x4C) then -- L sampSendChat("/lock") end if isKeyJustPressed(0x4B) then -- K sampSendChat("/key") end end end
вот код с ON/OFF
cod:function main() repeat wait(0) until isSampAvailable() wait(0) sampRegisterChatCommand("k", k) sampRegisterChatCommand("l", k) while true do wait(0) if isKeyJustPressed(0x4C) and l then -- L sampSendChat("/lock") end if isKeyJustPressed(0x4B) and k then -- K sampSendChat("/key") end end end function k() if k then k = false sampAddChatMessage("OFF") else k = false sampAddChatMessage("ON") end end function l() if l then l = false sampAddChatMessage("OFF") else l = false sampAddChatMessage("ON") end end
чем?Код хуйня, можно было сделать намного лучше)
Ну да, целую одну букву...чем?
сократить одну букву?
require "lib.moonloader"
local enableK = true
local enableL = true
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("l", function()
enableL = not enableL
sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1)
end)
sampRegisterChatCommand("l", function()
enableK = not enableK
sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1)
end)
while true do
wait(0)
if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then
sampSendChat("/lock")
elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then
sampSendChat("/key")
end
end
end
ебля бесполезная.Ну да, целую одну букву...
Lua:require "lib.moonloader" local enableK = false local enableL = false function main() if not isSampfuncsLoaded() or not isSampLoaded() then return end while not isSampAvailable() do wait(100) end sampRegisterChatCommand("l", function() enableL = not enableL sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1) end) sampRegisterChatCommand("l", function() enableK = not enableK sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1) end) while true do wait(0) if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then sampSendChat("/lock") elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then sampSendChat("/key") end end end
Ну да, лучше делать проверку на то что l или k равны true или falseебля бесполезная.
Не работает.@Валерия
это рабочий код, я просто перепутал клавиши вот и не работало, когда будет открыт чат оно не напишит.cod:require 'lib.moonloader' function main() repeat wait(0) until isSampAvailable() wait(0) while true do wait(0) if isKeyJustPressed(0x4C) then -- L sampSendChat("/lock") end if isKeyJustPressed(0x4B) then -- K sampSendChat("/key") end end end
вот код с ON/OFF
cod:function main() repeat wait(0) until isSampAvailable() wait(0) sampRegisterChatCommand("k", k) sampRegisterChatCommand("l", k) while true do wait(0) if isKeyJustPressed(0x4C) and l then -- L sampSendChat("/lock") end if isKeyJustPressed(0x4B) and k then -- K sampSendChat("/key") end end end function k() if k then k = false sampAddChatMessage("OFF") else k = false sampAddChatMessage("ON") end end function l() if l then l = false sampAddChatMessage("OFF") else l = false sampAddChatMessage("ON") end end
Ну да, целую одну букву...
Lua:require "lib.moonloader" local enableK = true local enableL = true function main() if not isSampfuncsLoaded() or not isSampLoaded() then return end while not isSampAvailable() do wait(100) end sampRegisterChatCommand("l", function() enableL = not enableL sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1) end) sampRegisterChatCommand("l", function() enableK = not enableK sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1) end) while true do wait(0) if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then sampSendChat("/lock") elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then sampSendChat("/key") end end end
Этот код работает, другой не проверялТак хуйня или нет?