Raised This Month: $32 Target: $400
 8% 

[PATCH] ns/idlekicker.sma


  
 
 
Thread Tools Display Modes
Author Message
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 01-16-2007 , 21:34   [PATCH] ns/idlekicker.sma
#1

Small update to make it work properly with 3.2 (the chance of it malfunctioning in 3.2 were small, but still there), and while I was at it I made it use pcvars instead.

Can't upload .diff (or .patch), so I'll just paste it

Code:
--- idlekicker.sma	2004-09-18 20:03:24.000000000 -0400
+++ idlekicker.sma	2007-01-16 21:47:36.000000000 -0500
@@ -44,22 +44,44 @@
 new bool:g_spawned[33] = {true, ...}
 new g_class[33]	// stored info from the "ScoreInfo" message
 
+new mp_tournamentmode;
+new amx_idle_time;
+new amx_idle_min_players;
+new amx_idle_ignore_immunity;
+
+new maxplayers;
+
 public plugin_init() {
 	register_plugin("Idle Player Remover",AMXX_VERSION_STR,"AMXX Dev Team") 
-	register_cvar("amx_idle_time", "120")				// Kick people idle longer than this time
-	register_cvar("amx_idle_min_players", "8")	// Only kick idle players when there is atleast this many players on the server
-	register_cvar("amx_idle_ignore_immunity", "1")	// Kick admins with immunity?
+	
+	amx_idle_time=register_cvar("amx_idle_time", "120")				// Kick people idle longer than this time
+	amx_idle_min_players=register_cvar("amx_idle_min_players", "8")	// Only kick idle players when there is atleast this many players on the server
+	amx_idle_ignore_immunity=register_cvar("amx_idle_ignore_immunity", "1")	// Kick admins with immunity?
+
+	mp_tournamentmode=get_cvar_pointer("mp_tournamentmode");
+	
 	set_task(float(CHECK_FREQ),"checkPlayers",_,_,_,"b")
 	register_event("ResetHUD", "playerSpawned", "be")
-	register_event("ScoreInfo","msgScoreInfo","a")
+	if (cvar_exists("sv_structurelimit"))
+	{
+		// need the NS 3.2 ScoreInfo parser
+		register_event("ScoreInfo","msgScoreInfo32","a")
+	}
+	else
+	{
+		register_event("ScoreInfo","msgScoreInfo","a")
+	}
+	
+	
+	maxplayers=get_maxplayers();
 }
 
 public checkPlayers() {
-	if (get_cvar_num("mp_tournamentmode")) return PLUGIN_HANDLED
+	if (get_pcvar_num(mp_tournamentmode)) return PLUGIN_HANDLED
 
-	for (new i = 1; i <= get_maxplayers(); i++) {
+	for (new i = 1; i <= maxplayers; i++) {
 		if (is_user_alive(i) && g_class[i]!=CLASS_GESTATE && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) {
-			if ( !get_cvar_num("amx_idle_ignore_immunity") ) {
+			if ( !get_pcvar_num(amx_idle_ignore_immunity) ) {
 				if ( access(i, ADMIN_IMMUNITY) ) continue
 			}
 			new newangle[3]
@@ -81,10 +103,9 @@
 
 check_idletime(id) {
 	new numplayers = get_playersnum()
-	new minplayers = get_cvar_num("amx_idle_min_players")
 					
-	if (numplayers >= minplayers) {
-		new maxidletime = get_cvar_num("amx_idle_time")
+	if (numplayers >= get_pcvar_num(amx_idle_min_players)) {
+		new maxidletime = get_pcvar_num(amx_idle_time)
 		if (maxidletime < MIN_IDLE_TIME) {
 			log_message("cvar amx_idle_time %d is too low. Minimum value is %d.", maxidletime, MIN_IDLE_TIME)
 			maxidletime = MIN_IDLE_TIME
@@ -139,3 +160,11 @@
   }
   g_class[id]=read_data(5);
 }
+public msgScoreInfo32() {
+  new id=read_data(1);
+  if (id>32||id<1) {
+    // just incase..
+    return;
+  }
+  g_class[id]=read_data(6);
+}
__________________
fyren sucks
sawce is offline
BAILOPAN
Join Date: Jan 2004
Old 01-17-2007 , 01:57   Re: [PATCH] ns/idlekicker.sma
#2

Thanks, whoever you are! This is patched as revision 3229.
__________________
egg
BAILOPAN is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode