disconnect

Vespan

loneliness
Автор темы
Проверенный
2,105
1,633
Версия MoonLoader
.026-beta
накидайте сюда функций для реконекта шоб отключится от сервера
 

Hideme Flow

Известный
555
193
Lua:
--Подключится
sampDisconnectWithReason(0)
sampSetGamestate(GAMESTATE_WAIT_CONNECT)

--Отключится
sampSetGamestate(GAMESTATE_DISCONNECTED)
sampDisconnectWithReason(0)

--Закрыть соединение
CloseConnect()

function CloseConnect()
    raknetEmulPacketReceiveBitStream(PACKET_DISCONNECTION_NOTIFICATION, raknetNewBitStream())
    raknetDeleteBitStream(raknetNewBitStream())
end
 

Vespan

loneliness
Автор темы
Проверенный
2,105
1,633
Lua:
--Подключится
sampDisconnectWithReason(0)
sampSetGamestate(GAMESTATE_WAIT_CONNECT)

--Отключится
sampSetGamestate(GAMESTATE_DISCONNECTED)
sampDisconnectWithReason(0)

--Закрыть соединение
CloseConnect()

function CloseConnect()
    raknetEmulPacketReceiveBitStream(PACKET_DISCONNECTION_NOTIFICATION, raknetNewBitStream())
    raknetDeleteBitStream(raknetNewBitStream())
end
Lua:
disconnected = false
require 'moonloader'

rec_sec = 60

function main()
    while not isSampAvailable() do wait(0) end wait(1)



    while true do wait(0)

        if not sampIsLocalPlayerSpawned() then
            if isKeyJustPressed(VK_D) and isKeyCheckAvailable() then sampDisconnectWithReason(quit) end
            if isKeyJustPressed(VK_C) and isKeyCheckAvailable() then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
        end



        if isKeyDown(VK_LMENU) and isKeyDown(VK_LSHIFT)
            then

            if isKeyJustPressed(VK_R) then
                sampDisconnectWithReason(0)
                sampDisconnectWithReason(0)
                for i = 1,15 do
                    printStringNow('~w~reconnect > ~y~ '..i..'~w~!',850)
                    wait(1050)
                    if i == 15 then sampSetGamestate(1) sampDisconnectWithReason(0) end
                end
            end

            -- if isKeyJustPressed(VK_D) then sampDisconnectWithReason(quit) end
            -- if isKeyJustPressed(VK_C) then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
        end

        if disconnected then
            if sampIsLocalPlayerSpawned() then
                disconnected = false
            end
            if isKeyJustPressed(VK_F) then
                disconnected = false
                printStringNow('~w~ auto-reconnect ~r~OFF~w~!',5000)
                print('{FFFFFF}auto-reconnect {FF0000}OFF{FFFFFF}!')
            end
        end

    end
end

function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 32 or id == 33 or id == 36 or id == 37 and disconnected == false --[[шоб не флудило~]]
         then
            disconnected = true
            -- sampDisconnectWithReason(quit)
            for i = 1,rec_sec+1 do
                -- if disconnected then
                    if i == rec_sec and disconnected then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
                    addOneOffSound(0.0, 0.0, 0.0, 1085)
                    printStringNow('~w~recconect!wait - ~y~'..i..'~w~.. to~g~' ..rec_sec..'.',900)
                    print('recconect!wait - '..i..'.. to' ..rec_sec..'.')
                    wait(1000)
                -- end
            end
        end
    end)
end

function onSendRpc(id, bitStream, priority, reliability, orderingChannel, shiftTs)
    if id == 25 and disconnected then -- RPC_CLIENTJOIN
        disconnected = false

    end
end 

function isKeyCheckAvailable()
    if not isSampLoaded() then
        return true
    end
    if not isSampfuncsLoaded() then
        return not sampIsChatInputActive() and not sampIsDialogActive()
    end
    return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end
делал для себя,после первого реконнекта всё норм,после второго краш
 

ARMOR

kjor32 is legend
Модератор
4,852
6,084
Lua:
disconnected = false
require 'moonloader'

rec_sec = 60

function main()
    while not isSampAvailable() do wait(0) end wait(1)



    while true do wait(0)

        if not sampIsLocalPlayerSpawned() then
            if isKeyJustPressed(VK_D) and isKeyCheckAvailable() then sampDisconnectWithReason(quit) end
            if isKeyJustPressed(VK_C) and isKeyCheckAvailable() then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
        end



        if isKeyDown(VK_LMENU) and isKeyDown(VK_LSHIFT)
            then

            if isKeyJustPressed(VK_R) then
                sampDisconnectWithReason(0)
                sampDisconnectWithReason(0)
                for i = 1,15 do
                    printStringNow('~w~reconnect > ~y~ '..i..'~w~!',850)
                    wait(1050)
                    if i == 15 then sampSetGamestate(1) sampDisconnectWithReason(0) end
                end
            end

            -- if isKeyJustPressed(VK_D) then sampDisconnectWithReason(quit) end
            -- if isKeyJustPressed(VK_C) then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
        end

        if disconnected then
            if sampIsLocalPlayerSpawned() then
                disconnected = false
            end
            if isKeyJustPressed(VK_F) then
                disconnected = false
                printStringNow('~w~ auto-reconnect ~r~OFF~w~!',5000)
                print('{FFFFFF}auto-reconnect {FF0000}OFF{FFFFFF}!')
            end
        end

    end
end

function onReceivePacket(id, bs)
    lua_thread.create(function()
        if id == 32 or id == 33 or id == 36 or id == 37 and disconnected == false --[[шоб не флудило~]]
         then
            disconnected = true
            -- sampDisconnectWithReason(quit)
            for i = 1,rec_sec+1 do
                -- if disconnected then
                    if i == rec_sec and disconnected then sampConnectToServer(select(1,sampGetCurrentServerAddress()), select(2,sampGetCurrentServerAddress())) end
                    addOneOffSound(0.0, 0.0, 0.0, 1085)
                    printStringNow('~w~recconect!wait - ~y~'..i..'~w~.. to~g~' ..rec_sec..'.',900)
                    print('recconect!wait - '..i..'.. to' ..rec_sec..'.')
                    wait(1000)
                -- end
            end
        end
    end)
end

function onSendRpc(id, bitStream, priority, reliability, orderingChannel, shiftTs)
    if id == 25 and disconnected then -- RPC_CLIENTJOIN
        disconnected = false

    end
end

function isKeyCheckAvailable()
    if not isSampLoaded() then
        return true
    end
    if not isSampfuncsLoaded() then
        return not sampIsChatInputActive() and not sampIsDialogActive()
    end
    return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end
делал для себя,после первого реконнекта всё норм,после второго краш
В начало кода:
Lua:
local ev = require 'lib.samp.events'

joinCount = 0

function ev.onRemoveBuilding()
 if joinCount > 1 then return false end
end

function ev.onSendClientJoin()
 joinCount = joinCount + 1
end
 

Vespan

loneliness
Автор темы
Проверенный
2,105
1,633
function CloseConnect() raknetEmulPacketReceiveBitStream(PACKET_DISCONNECTION_NOTIFICATION, raknetNewBitStream()) raknetDeleteBitStream(raknetNewBitStream()) end
использую вот это,но после рекконекта когда уже зашел на сервер,на радаре где я реконнектился те игроки,которые были в зоне стрима во время реконнекта.
Тоже самое с транспортом,как исправить?
 

smklmn

Известный
80
3
использую вот это,но после рекконекта когда уже зашел на сервер,на радаре где я реконнектился те игроки,которые были в зоне стрима во время реконнекта.
Тоже самое с транспортом,как исправить?
фиксанул краш после второга коннекта ? если да то как ?
 
  • Грустно
Реакции: Vespan

Tema05

Известный
1,442
401
фиксанул краш после второга коннекта ? если да то как ?
Я думаю проще взять уже готовый, популярный скрипт и разбирать его. В реконекте 90% кода это фиксы всего что вызывает реконект)
 

smklmn

Известный
80
3
Я думаю проще взять уже готовый, популярный скрипт и разбирать его. В реконекте 90% кода это фиксы всего что вызывает реконект)
да не, дело в том что после второго реконнекта стабильно крашит
без разницы какой реконннект