General > Developers Corner

can we make clients reconect if the server crashes ?

(1/2) > >>

nathan736:

--- Code: ---if ( CLIENT ) then
function didwecrash()
if (not wedidcrashdamit) then
timer.stop( "didwecrash" )
timer.Destroy( "didwecrash" )
end
if (not timer.IsTimer("didwecrash")) then
wedidcrashdamit = true
timer.Create("didwecrash", 20, 1,function()
if (not wedidcrashdamit == nil) and wedidcrashdamit then
RunConsoleCommand("connect 50.31.65.166:27015")
end


end)
end
end
hook.Add("Think",didwecrash,wecrashed)

local function RecvMyUmsg( data )
wedidcrashdamit = data:ReadBool()

end
usermessage.Hook( "didwecrash", RecvMyUmsg );
end





if ( SERVER ) then
function sdidwecrash()
if (not timer.IsTimer("sendcrashinfop")) then
timer.Create("sendcrashinfop", 5, 0,function()




umsg.Start( "didwecrash" );
umsg.Bool( false );
umsg.End();
end)
end

end
hook.Add("Think",sdidwecrash,swecrashed)
end
--- End code ---

my objective here is to make the client rejoin the server if the server crashes or lags big time

MrPresident:
I might be wrong here.. but I think that clientside scriptings stop when the client disconnects.

I don't think this is possible.

nathan736:
so the client disconnects if the server lags hard core... dam it  did garry change something i saw  a server do it in gmod 12 or something

Stickly Man!:
It might be possible, I'm not sure how you'd go about doing it, but it would have to be entirely client-side code. If the server crashes or gets severely lagged, it's not going to have any time to politely inform the clients that it crashed.

nathan736:

--- Code: ---if ( CLIENT ) then
print("||retry system loaded!||")
function didwecrash() -- client  auto ran crash checker

if (not timer.IsTimer("didwecrash")) then
wedidcrashdamit = true
timer.Create("didwecrash", 20, 1,function()
if (not wedidcrashdamit == nil) and wedidcrashdamit then
print("we should be rejoing now")
RunConsoleCommand("connect 50.31.65.166:27015")
end


end)
timer.start("didwecrash")
end

if (not wedidcrashdamit) then
timer.stop( "didwecrash" )
timer.Destroy( "didwecrash" )
timer.Create("didwecrash",20,1,function() -- creates a timer that restarts if true
print("we should be rejoing now")
RunConsoleCommand("connect 50.31.65.166:27015")
end)
timer.start("didwecrash")
end
end
hook.Add("Think",didwecrash,wecrashed)

local function RecvMyUmsg( data )
wedidcrashdamit = data:ReadBool()

end
usermessage.Hook( "didwecrash", RecvMyUmsg );
end





if ( SERVER ) then
function sdidwecrash()
if (not timer.IsTimer("sendcrashinfop")) then
timer.simple("sendcrashinfop", 10, 0,function()




umsg.Start( "didwecrash" )
umsg.Bool( false )
umsg.End()
end)
end
timer.start("sendcrashinfop")
end
end
hook.Add("Think",sdidwecrash,swecrashed)
--- End code ---
this clearly does not work i think timers are synced with the server :/

Navigation

[0] Message Index

[#] Next page

Go to full version