Release InfectedRestarter V7 by pieter
#21
@pieter ty man, was working on some new plugins, didn't have any time.
TY for recompiling

#22
@Pieter
err, have i missed something? do you have to add anything to the ini? because this on its own didn't work.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]


#23
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.
[Image: azuw.jpg]

#24
(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 Smile

Source (Minor changes only) (Click to View)
Compiled version is attached!


Attached Files
.zip   InfectedRestarterV2.zip (Size: 2.39 KB / Downloads: 44)
Had a life, Got a modem..

#25
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.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]


#26
i was updating my reply when you posted, please look above your reply and try it Smile
Had a life, Got a modem..

#27
i saw that, but you removed the server say that it's gonna restart still?
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]


#28
how about you try it? i cant go play games during office hours Tongue

i added it to the inf server in my sig if you dont want to use your own Smile
Had a life, Got a modem..

#29
(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?

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.
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)
to
Code:
while(NumThreads < 2)
and add a Thread.Sleep in the while codeblock.
[Image: azuw.jpg]

#30
(03-20-2012, 12:36)pieter Wrote: how about you try it? i cant go play games during office hours Tongue

i added it to the inf server in my sig if you dont want to use your own Smile

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.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]




Forum Jump:


Users browsing this thread:

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.