Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
04-12-2012, 23:01
(This post was last modified: 04-12-2012, 23:04 by JoSchaap.)
ok however
I've fixed it all!
Now that nukem implemented OnPlayerDisconnect today,it no longer has to run in a timed loop!
Infected Restarter v5 (New version, recoded to work on OnPlayerDisconnect )
CSHARP Code
using System;
using Addon;
using System.Threading;
namespace InfRestart
{
//"<class name> : CPlugin" is needed to inherit the functions
public class InfRestart : CPlugin
{
public override void OnServerLoad()
{
ServerPrint("InfectedRestarter(V5) (by: Pieter [idea/help:JariZ,zxz0O0] <a href="http://www.itsmods.com" target="_blank" rel="noopener" class="mycode_url">www.itsmods.com</a>)");
}
public override void OnPlayerDisconnect(ServerClient Client)
{
String DVg_gametype = GetDvar("g_gametype");
ServerPrint("[InfectedRestarter] Gametype = (" + DVg_gametype + ")");
String DCpname = Client.Name;
String DCpXUID = Client.XUID;
if (DVg_gametype == "infect")
{
ServerPrint("[InfectedRestarter] OnDisconnect triggerred by: (" + DCpname + ") XUID: (" + DCpXUID + ")");
ThreadPool.
QueueUserWorkItem(new WaitCallback
(irth
)); }
else
{
ServerPrint("[InfectedRestarter] OnDisconnect triggerred, but Gametype = (" + DVg_gametype + ") so restarter doesnt care :likeaboss:");
}
}
void irth(object o)
{
try
{
Thread.Sleep(5000); //wait 5 seconds for enabling (to avoid fast_restart looping)
int axis = 0;
int allies = 0;
foreach (ServerClient client in GetClients())
{
if (client.Team == Teams.Allies)
{
allies++;
}
else if (client.Team == Teams.Axis)
{
axis++;
}
else
{
ServerPrint("[InfectedRestarter-DEBUG] No teamcount raised, Team value found was: (" + client.Team + ")");
}
}
if (axis == 0)
{
ServerSay("[^1Infected-Restart^7] The last ^2INFECTED^7 has disconnected! Server will ^2fast_restart^7 in ^25 seconds!", true);
Thread.Sleep(5000);
ServerPrint("[InfectedRestarter] Fast_restart triggerred: (Allies:" + allies + " - Axis:" + axis + ")");
ServerCommand("fast_restart");
return;
}
ServerPrint("[InfectedRestarter-DEBUG] End of procedure. wait till next disconnect");
return;
}
catch (Exception e) { ServerPrint("[InfectedRestarterException] " + e.Message); }
return;
}
}
}
If you use, and enjoy this Plugin, please
+rep me!
If you use, and enjoy this Plugin, please
+rep me!
Had a life, Got a modem..
Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
if it doesnt work, 99% chance u didnot update addon ;-)
addon 1.3 required
Had a life, Got a modem..
Posts: 322
Threads: 43
Joined: Mar 2012
Reputation:
-4
Problem. If the players come from the server prior to infection. Map restarts.
Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
yes thats because most infected servers force respawn meaning the counter is always running if someone connected
just to prevent rounds without infection
Had a life, Got a modem..