ULX

Author Topic: can we make clients reconect if the server crashes ?  (Read 2876 times)

0 Members and 1 Guest are viewing this topic.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
can we make clients reconect if the server crashes ?
« 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
« Last Edit: January 28, 2013, 09:17:08 PM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: can we make clients reconect if the server crashes ?
« Reply #1 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.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: can we make clients reconect if the server crashes ?
« Reply #2 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
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: can we make clients reconect if the server crashes ?
« Reply #3 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.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: can we make clients reconect if the server crashes ?
« Reply #4 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 :/
« Last Edit: January 29, 2013, 03:35:00 PM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: can we make clients reconect if the server crashes ?
« Reply #5 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*
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: can we make clients reconect if the server crashes ?
« Reply #6 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 ?
« Last Edit: January 30, 2013, 08:37:39 AM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: can we make clients reconect if the server crashes ?
« Reply #7 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: can we make clients reconect if the server crashes ?
« Reply #8 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.