Help HELP reconnect.lua

Halfastrc24

Active member
Joined
Jun 4, 2021
Messages
45
Solutions
1
Reaction score
6
Location
Greenland
Is there any way to make reconnect.lua on moonloader without sf?

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
 

Joskenzas_

Member
Joined
Dec 7, 2018
Messages
7
Reaction score
0
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
for some reason its not working for me, maybe i need libs?
 

Halfastrc24

Active member
Joined
Jun 4, 2021
Messages
45
Solutions
1
Reaction score
6
Location
Greenland
for some reason its not working for me, maybe i need libs?
Check the MoonLoader log for any errors, and try adding this library; it's already included by default in MoonLoader: local vkeys = require("vkeys")."


U can try this version below too:
just type /r in the chat

Code:
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
 

Tuzas

Active member
Joined
Nov 1, 2019
Messages
142
Reaction score
80
Location
null
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
 

Joskenzas_

Member
Joined
Dec 7, 2018
Messages
7
Reaction score
0
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
zd tuzai nupirk batona sutrau, kada osrs?
 

Joskenzas_

Member
Joined
Dec 7, 2018
Messages
7
Reaction score
0
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?
 

maldivass

Member
Joined
Dec 25, 2022
Messages
12
Reaction score
1
evrything is working sir



Code:
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
 

maldivass

Member
Joined
Dec 25, 2022
Messages
12
Reaction score
1
LSHIFT+0


Code:
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
 
Top