Posts: 836
Threads: 48
Joined: Feb 2012
Reputation:
11
just to update about the new version of this plugin, apart from the occasional 2 restarts on a map(maybe waiting for all players) it works a treat, and has saved me so much time in having to restart due to inf leaving.
thankyou again pieter
Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
not a problem, i have some ideas to get rid of the restart when players leave during the start of the map, but have to optimize it first since it seems MW3 doesnt like too much hassle from the addon
for now im sticking to this version since it really isnt a mayor pain
maybe next week ill update it
Had a life, Got a modem..
Posts: 235
Threads: 23
Joined: Nov 2011
Reputation:
0
Yes, what hillbilly said...sometimes it restarts before the GAME even BEGINS...
Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
04-17-2012, 09:57
(This post was last modified: 04-17-2012, 10:02 by JoSchaap.)
Okay! so after testing I'll officially release V6 now
Fix:
during the first 30 seconds after mapchange and/or fast_restart, the plugin will NOT interfear
Infected Restarter v6
(New version, recoded to work on OnPlayerDisconnect, and wait for 30 seconds after mapchange/fastrestart, optimized code)
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 bool Magik = false;
public override void OnServerLoad()
{
ServerPrint("InfectedRestarter(V6) (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 OnFastRestart()
{
OnMapChange();
}
public override void OnMapChange()
{
ThreadPool.
QueueUserWorkItem(new WaitCallback
(teller
)); }
public override void OnPlayerDisconnect(ServerClient Client)
{
if (Magik == true)
{
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)
{
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;
}
void teller(object p)
{
Magik = false;
Thread.Sleep(30000); //wait 30 seconds for enabling (to avoid fast_restart looping)
Magik = true;
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: 235
Threads: 23
Joined: Nov 2011
Reputation:
0
This did not work for the XZombie Mod..?
Posts: 502
Threads: 13
Joined: Feb 2012
Reputation:
42
yes it does
just not in the first 30 seconds
Had a life, Got a modem..