Joskenzas_
Member
- Joined
- Dec 7, 2018
- Messages
- 7
- Reaction score
- 0
Is there any way to make reconnect.lua on moonloader without sf?
Is there any way to make reconnect.lua on moonloader without sf?
local require = 'lib.moonloader'
function main()
while not isSampAvailable() do wait(100) end
if not isSampLoaded() then return end
while true do wait(0)
if not sampIsChatInputActive() and not sampIsDialogActive() then
atalhoReconnect()
end
end
end
function atalhoReconnect()
if isKeyDown(0x30) and isKeyDown(0xA0) then -- SHIFT + 0
sampDisconnectWithReason(false)
wait(1000)
sampSetGamestate(1)
end
end
for some reason its not working for me, maybe i need libs?Code:local require = 'lib.moonloader' function main() while not isSampAvailable() do wait(100) end if not isSampLoaded() then return end while true do wait(0) if not sampIsChatInputActive() and not sampIsDialogActive() then atalhoReconnect() end end end function atalhoReconnect() if isKeyDown(0x30) and isKeyDown(0xA0) then -- SHIFT + 0 sampDisconnectWithReason(false) wait(1000) sampSetGamestate(1) end end
Check the MoonLoader log for any errors, and try adding this library; it's already included by default in MoonLoader: local vkeys = require("vkeys")."for some reason its not working for me, maybe i need libs?
local require = 'lib.moonloader'
function main()
while not isSampAvailable() do wait(100) end
if not isSampLoaded() then return end
sampRegisterChatCommand("r", function()
status = not status
sampAddChatMessage("{32cd32}| INFO |{ffffff} Reconnect "..(status and "actived!" or "deactived!"), 0x32cd32)
end)
while true do wait(0)
if status then
atalhoReconnect()
end
end
end
function atalhoReconnect()
sampDisconnectWithReason(false)
wait(1000)
sampSetGamestate(1)
status = false
end
pcall(require, 'sflua')
function main()
while not isSampAvailable() do
wait(100)
end
sampRegisterChatCommand("r", function()
sampAddChatMessage("{32cd32}| INFO |{ffffff} Reconnecting...", -1)
lua_thread.create(function()
sampDisconnectWithReason(false)
wait(1500)
ip, port = sampGetCurrentServerAddress()
sampConnectToServer(ip, port)
end)
end)
while true do
wait(0)
end
end
zd tuzai nupirk batona sutrau, kada osrs?You need samp-api and sfLua for this code to work, and also this code is kinda confusing.
You dont need either of these for this code -
local require = 'lib.moonloader'
local vkeys = require("vkeys")
JavaScript:pcall(require, 'sflua') function main() while not isSampAvailable() do wait(100) end sampRegisterChatCommand("r", function() sampAddChatMessage("{32cd32}| INFO |{ffffff} Reconnecting...", -1) lua_thread.create(function() sampDisconnectWithReason(false) wait(1500) ip, port = sampGetCurrentServerAddress() sampConnectToServer(ip, port) end) end) while true do wait(0) end end
its working, but it won't reconnect me back -> any ideas?You need samp-api and sfLua for this code to work, and also this code is kinda confusing.
You dont need either of these for this code -
local require = 'lib.moonloader'
local vkeys = require("vkeys")
JavaScript:pcall(require, 'sflua') function main() while not isSampAvailable() do wait(100) end sampRegisterChatCommand("r", function() sampAddChatMessage("{32cd32}| INFO |{ffffff} Reconnecting...", -1) lua_thread.create(function() sampDisconnectWithReason(false) wait(1500) ip, port = sampGetCurrentServerAddress() sampConnectToServer(ip, port) end) end) while true do wait(0) end end
The delay is too low, change it to 3000~its working, but it won't reconnect me back -> any ideas?
unfortunatly not working, i even did wait to (10000).The delay is too low, change it to 3000~
(Here)
wait(1500) -> wait(3000)
pcall(require, 'sflua')
function main()
while not isSampAvailable() do
wait(100)
end
sampRegisterChatCommand("r", function()
sampAddChatMessage("{32cd32}| INFO |{ffffff} lsg restartas pamoinekas", -1)
lua_thread.create(function()
sampDisconnectWithReason(false)
wait(5000)
ip, port = sampGetCurrentServerAddress()
sampConnectToServer(ip, port)
end)
end)
while true do
wait(0)
end
end
pcall(require, 'sflua')
function main()
while not isSampAvailable() do
wait(100)
end
function atalhoReconnect()
if isKeyDown(0x30) and isKeyDown(0xA0) then
sampDisconnectWithReason(false)
wait(3000)
ip, port = sampGetCurrentServerAddress()
sampConnectToServer(ip, port)
end
end
while true do
atalhoReconnect()
wait(0)
end
end