03-20-2012, 08:39
@pieter ty man, was working on some new plugins, didn't have any time.
TY for recompiling
TY for recompiling
|
Release InfectedRestarter V7 by pieter
|
|
03-20-2012, 08:39
@pieter ty man, was working on some new plugins, didn't have any time.
TY for recompiling
@Pieter
err, have i missed something? do you have to add anything to the ini? because this on its own didn't work.
How it should be:
Code: using System;
using Addon;
using System.Threading;
namespace Plugin
{
//"<class name> : CPlugin" is needed to inherit the functions
public class Plugin : CPlugin
{
public override void OnServerLoad()
{
ServerPrint("InfectedRestart by JariZ loaded");
}
public override void OnMapChange()
{
NumThreads++;
ThreadPool.QueueUserWorkItem(new WaitCallback(thaz));
}
public override void OnFastRestart()
{
OnMapChange();
}
int NumThreads = 0;
void thaz(object o)
{
try
{
Thread.Sleep(10000); //wait 10 seconds for enabling
if (NumThreads < 2)
{
ServerSay("^1InfectedRestart^7: InfectedRestart protection by JariZ activated!", true);
int axis = 0;
int allies = 0;
foreach (ServerClient client in GetClients())
{
if (client.Team == Teams.Allies) allies++;
else if (client.Team == Teams.Axis) axis++;
}
if (allies > 0 && axis == 0)
{
ServerSay("^1InfectedRestart^7: The server will fast restart in 5 seconds because there are no infected left.", true);
Thread.Sleep(5000);
ServerCommand("fast_restart");
}
}
}
catch (ThreadAbortException) { }
NumThreads--;
}
}
}Just fixed the code. Only checks one time after 10seconds. The best way would probably be to create a timer.
(03-20-2012, 11:51)zxz0O0 Wrote: How it should be:Thanks ALOT! i needed an example of threadpooling! here's what i made of it - extended the wait (on mapchange it kept looping fast restartd due to the 15 second wait) - removed the serversay (personally i found it a bit too much) - compiled and zipped ![]()
Compiled version is attached!
Had a life, Got a modem..
is this ok now guys? also will this still work if the infected actually leave after 2/3 min or so?
Also i thought you had to add something to the ini, in the original release but can't seem to find that bit, don't want to be a pain but please could you re-add that it actually says "server will fast_restart due to infected leaving etc please" p.s. thanks so much for putting the time in to this plugin.
03-20-2012, 12:28
i was updating my reply when you posted, please look above your reply and try it
Had a life, Got a modem..
03-20-2012, 12:36
how about you try it? i cant go play games during office hours
![]() i added it to the inf server in my sig if you dont want to use your own
Had a life, Got a modem..
03-20-2012, 12:47
(03-20-2012, 12:01)hillbilly Wrote: is this ok now guys? also will this still work if the infected actually leave after 2/3 min or so?The code is designed to check only one time after 10/20 seconds. So if Infected leave after 3minutes it doesn't work. @pieter @JariZ to fix this either use Timer or change Code: if (NumThreads < 2)Code: while(NumThreads < 2)
(03-20-2012, 12:36)pieter Wrote: how about you try it? i cant go play games during office hours i just tried it on mine but it keeps restarting with only a 5 sec delay? and yes i redown loaded it to make sure i had your updated one. @zxz000 that is what i'm really after sorry if i confused the issue but it's a restart if they leave after 2/3 min etc . thanks again. |
| Users browsing this thread: |
| 1 Guest(s) |