ServerWatch Server-Side Mod

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

ServerWatch Server-Side Mod

Post by sdlall »

Most of you guys know already that serverwatch has a server-side mod which is suppose to fix the auto select team so that it can see what team your on for the spawn protection and spawn killing. I finally found the mod couple days ago but not sure about the settings and there was no readme and the guy that made website does not exist anymore. Wondering if you guys could take a look at the script and the settings below and help me figure out what the settings should be.

sets sw_version "1.0Beta"
seta sw_goaxis "999"
seta sw_goallies "999"
seta sw_rejoin "999"

Code: Select all

//  Serverwatch server side mod    \\
//---------------------------------\\                     
// Made by [CRC]Checksum           \\
// Website: www.crc-clan.dk        \\
// Mail: crc-clan@hotmail.com      \\
//=================================\\

main:
//***********************************************
// initialization thread... 
//***********************************************
iprintln ("Serverwatch mod initializing!")
	level waittill spawn
	thread codeautoexe
end
	

codeautoexe:
//***********************************************
// Code: Automatic Excute these commands after spawn 
//***********************************************
setcvar "sw_active" "0"
wait 1.0 

// Initialize Threads
thread code_init
thread code_Instantcmds

end

code_init:
//***********************************************
// Code: Instant Commands
//***********************************************
if (getcvar (sw_active) != "1") {
	setcvar "sw_active" "1"
	setcvar "sw_present" "1"

// Message to all players about ServerWatch mod is active
	if ($player != NULL) { 
		$player stufftext ("echo Serverwatch mod activated ...")
	}
// Announcement
	iprintln ("Serverwatch mod version " + getcvar (sw_version))
	wait 3.0
	iprintln ("www.crc-clan.dk")
}
wait 5.0
goto code_init
end


code_Instantcmds:
//***********************************************
// Code: Team Commands
//***********************************************
wait 2.0
level.maxplayers=int(getcvar (sv_maxclients))
level.playerid = 999

// Rejoin function
local.i = int(getcvar(sw_rejoin))
if (local.i != 999) {
	local.axis = 0
	local.allies = 0
	local.spectator = 0
	for(local.p = 1; local.p<=$player.size;local.p++) {
		if($player[local.p].dmteam == "axis")
			local.axis++
		if($player[local.p].dmteam == "allies")
			local.allies++
		if($player[local.p].dmteam == "spectator")
			local.spectator++	
	}
	// Join the team with least players, passes entityID	
	if(local.axis < local.allies) {				
		setcvar "sw_goaxis" (local.i)
	} 
	if(local.axis >= local.allies) {				
		setcvar "sw_goallies" (local.i)
	} 
setcvar "sw_rejoin" "999"
}

// Force player to allies		
if (int(getcvar (sw_goallies))!=999) {
  	//Resolve playerID from EntityID
	thread returnplayer (int(getcvar(sw_goallies)))
	if(level.playerid != 999) {
		//Playerid was found and valid
		if($player[level.playerid ].dmteam=="allies") {
			$player[level.playerid ] stufftext ("spectator")
		}
		$player[level.playerid ] stufftext ("join_team allies")
	   	$player[level.playerid ] iprint ("You have been moved to allies side by serverwatch")
		setcvar "sw_goallies" "999"
	}
}

// Force player to axis		
if (int(getcvar (sw_goaxis))!=999) {
  	//Resolve playerID from EntityID
	thread returnplayer (int(getcvar(sw_goaxis)))
	if(level.playerid != 999) {
		//Playerid was found and valid
		if($player[level.playerid ].dmteam=="axis") {
			$player[level.playerid ] stufftext ("spectator")
		}
		$player[level.playerid ] stufftext ("join_team axis")
	   	$player[level.playerid ] iprint ("You have been moved to axis side by serverwatch")
		setcvar "sw_goaxis" "999"
	}
}

goto code_Instantcmds
end

//***********************************************
// Code: Sub Function
//***********************************************
//
// Find clientID from entity ID//
//
returnplayer local.clientid:
for (local.p=1;local.p<=level.maxplayers && level.playerid == 999;local.p++) {
	thread checkpidcid local.p local.clientid
}
end

checkpidcid local.p local.clientid:
if (local.p>$player.size)
	end
if ($player[local.p]==NULL)
	end

local.player = $player[local.p]
if(local.player.entnum == local.clientid) {
	level.playerid = local.p
	end
}
level.playerid = 999
end
// ---------- [E] *** Find ClientID *** [E] ---------- \\
p.s. If I can not get this to work is there a way to disable auto team select. If memory serves me right I have seen a server with auto team select diabled. Just said please pick a team.
Post Reply