Ulysses

General => Developers Corner => Topic started by: nathan736 on January 28, 2013, 09:07:30 PM

Title: can we make clients reconect if the server crashes ?
Post by: nathan736 on January 28, 2013, 09:07:30 PM
Code: [Select]
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

my objective here is to make the client rejoin the server if the server crashes or lags big time
Title: Re: can we make clients reconect if the server crashes ?
Post by: MrPresident on January 28, 2013, 09:33:27 PM
I might be wrong here.. but I think that clientside scriptings stop when the client disconnects.

I don't think this is possible.
Title: Re: can we make clients reconect if the server crashes ?
Post by: nathan736 on January 29, 2013, 08:30:09 AM
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
Title: Re: can we make clients reconect if the server crashes ?
Post by: Stickly Man! on January 29, 2013, 09:09:38 AM
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.
Title: Re: can we make clients reconect if the server crashes ?
Post by: nathan736 on January 29, 2013, 10:57:00 AM
Code: [Select]
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)
this clearly does not work i think timers are synced with the server :/
Title: Re: can we make clients reconect if the server crashes ?
Post by: JamminR on January 29, 2013, 04:47:37 PM
this clearly does not work i think timers are synced with the server :/

99% sure of this;
clientside scriptings stop when the client disconnects.

Can you imagine the horrors of some not-so-nice server host causing you to do things once you connected to another server?
I can. *shiver*
Title: Re: can we make clients reconect if the server crashes ?
Post by: nathan736 on January 29, 2013, 08:03:24 PM
EDIT : wowowo back up  the client disconnects if the server lags ? im confuzled


is think hook synced as well ?
Title: Re: can we make clients reconect if the server crashes ?
Post by: JamminR on January 30, 2013, 02:54:02 PM
If a server lags for long enough, and the client's frame "keep alive" packets never get acknowledged from the server, yes, the client will disconnect.
I've not played GM13 enough to have seen it, but in GM<12 it was a little red text at top right of screen with something like 'connection issue: <and ip I think>'.

As for the think hook, i don't know if it's synced or not, but I would imagine some hooks are.
Title: Re: can we make clients reconect if the server crashes ?
Post by: MrPresident on January 30, 2013, 07:18:31 PM
I've not played GM13 enough to have seen it, but in GM<12 it was a little red text at top right of screen with something like 'connection issue: <and ip I think>'.

It's the same in GM13.