Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 71 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Another .menu question
stealthcod2
General Member
Since: Dec 23, 2008
Posts: 108
Last: Jul 13, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, May. 25, 2009 11:47 pm
kk hey, I am wondering. Is it possible to have Spectate enabled for one game type and disabled for another. Like say I want spectate disabled for the gametype zom, but disabled ffor the gametype tdm.

ORRR is it possible to set it FOR BOTH GAMETYPES so u can only spectate axis players.


kk thanks for reading this

stealth [rocking][rocking][rocking]
Share |
stealthcod2
General Member
Since: Dec 23, 2008
Posts: 108
Last: Jul 13, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 01:59 am
I mean t enabled ffor the gametype tdm.
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 02:35 am
Spectate permissions is handled by _spectating.gsc, which is in:

iw_07.iwd/maps/mp/gametypes

To make this work the way you want, you need to convert the cvars over to Ravir's cvardef() method. This is basically a way of defining a cvar which can be set true or false for certain maps, gametypes, or both. It extends the flexibility of cvars by adding in a check on the cvars getcvar("mapname") and getcvar("g_gametype").

Here is the converted _spectating.gsc file. Just copy and paste it into a GSC file, and name it _spectating.gsc, and place it in your mod, in the folder structure:

maps/mp/gametypes/_spectating.gsc

Code:
init()
{

	level.spectatefree = cvardef( "scr_spectatefree", 1, 0, 1, "int" );

	level.spectateenemy = cvardef( "scr_spectateenemy", 1, 0, 1, "int" );
	
	level.no_spectating = cvardef( "scr_no_spectating", 0, 0, 1, "int" );

	for(;;)
	{
		updateSpectateSettings();
		wait 1;
	}
}

updateSpectateSettings()
{
	spectatefree = getCvarInt("scr_spectatefree");
	spectateenemy = getCvarInt("scr_spectateenemy");
	update = false;
	
	if(level.spectatefree != spectatefree)
	{
		level.spectatefree = spectatefree;
		update = true;
	}
	
	if(level.spectateenemy != spectateenemy)
	{
		level.spectateenemy = spectateenemy;
		update = true;
	}

	if(update)
		level thread updateSpectatePermissions();
}

updateSpectatePermissions()
{
	players = getentarray("player", "classname");

	for(i = 0; i < players.size; i++)
		players[i] thread setSpectatePermissions();
}

setSpectatePermissions()
{
	if(isdefined(self.killcam))
		return;
	
	if( !level.spectatefree || !level.spectateenemy || !level.no_spectating  )
		return;
	
	spectatefree = true;
	if( !level.spectatefree )
		spectatefree = false;
	
	spectateenemy = true;
	if( !level.spectateenemy )
		spectateenemy = false;
		
	if( !level.no_spectating )
	{
		spectateenemy = false;
		spectatefree = false;
	}
	
	switch(self.sessionteam)
	{
	case "allies":
		self allowSpectateTeam("allies", true);
		self allowSpectateTeam("axis", spectateenemy);
		self allowSpectateTeam("freelook", spectatefree);
		self allowSpectateTeam("none", false);
		break;
		
	case "axis":
		self allowSpectateTeam("allies", spectateenemy);
		self allowSpectateTeam("axis", true);
		self allowSpectateTeam("freelook", spectatefree);
		self allowSpectateTeam("none", false);
		break;
		
	default:
		self allowSpectateTeam("allies", true);
		self allowSpectateTeam("axis", true);
		self allowSpectateTeam("freelook", true);
		self allowSpectateTeam("none", true);
		break;
	}
}

cvardef (varname, vardefault, min, max, type)
{
	mapname = getcvar("mapname");		

	gametype = getcvar ("g_gametype");

	both = gametype + "_" + mapname;	

	tempvar = varname + "_" + gametype;	
	if (getcvar (tempvar) != "") 
		varname = tempvar; 			

	tempvar = varname + "_" + mapname;	
	if (getcvar (tempvar) != "")	
		varname = tempvar;		

	tempvar = varname + "_" + both;
	if (getcvar (tempvar) != "")	
		varname = tempvar;					

	
	switch(type)
	{
		case "int":
			if(getcvar(varname) == "")
				definition = vardefault;
			else
				definition = getcvarint(varname);
			break;
		case "float":
			if(getcvar(varname) == "")
				definition = vardefault;
			else
				definition = getcvarfloat(varname);
			break;
		case "string":
		default:
			if(getcvar(varname) == "")
				definition = vardefault;
			else
				definition = getcvar(varname);
			break;
	}

	
	if((type == "int" || type == "float") && definition < min)
		definition = min;

	
	if((type == "int" || type == "float") && definition > max)
		definition = max;

	return definition;
}


Now, to stop spectating for Zombies, but allow it for TDM, just do this:

set scr_no_spectating 0
set scr_no_spectating_tdm 1

That means spectating is off for all gametypes except TDM.

As the cvars scr_spectateenemy and scr_spectatefree are also defined using cvardef(), you can turn them on or off for gametypes as well:

set scr_spectatefree 0
set scr_spectatefree_tdm 1

set scr_spectateenemy 0
set scr_spectateenemy_tdm 1

All the big mods like AWE or Xtreme+ use the cvardef() method of defining cvars.
Share |
stealthcod2
General Member
Since: Dec 23, 2008
Posts: 108
Last: Jul 13, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 03:28 am
Thanks, that helped me alot!

So im guessing it just isnt possible for only spec a team eh

btw demon do u got xfire
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 07:09 am
stealthcod2 writes...
Quote:
Thanks, that helped me alot!

So im guessing it just isnt possible for only spec a team eh

btw demon do u got xfire


Yeah, its possible to only allow axis to spectate. In the code I posted above, there is a method named updateSpectatePermissions(). Just edit that to only allow players on axis team to get a chance to spectate enemy, and make sure scr_spectateenemy is set to 1:

Code:
updateSpectatePermissions()
{
	players = getentarray("player", "classname");

	for(i = 0; i < players.size; i++)
	{
		player = players[i];
		if( ( isdefined( player.pers["team"] ) && player.pers["team"] == "axis" ) )
			player thread setSpectatePermissions();
	}
}


And no, I dont use XFire.
Share |
stealthcod2
General Member
Since: Dec 23, 2008
Posts: 108
Last: Jul 13, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 09:04 pm
Demon, Im sorry, my explaining is not the greatest.

What I am asking is that for both gametypes I Do not want the allied players to be spectated, so umm like U load the map etc then get team menu, if u click the spectate u cycle throguh only axis players. And cant veiw allied.
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 09:13 pm
stealthcod2 writes...
Quote:
Demon, Im sorry, my explaining is not the greatest.

What I am asking is that for both gametypes I Do not want the allied players to be spectated, so umm like U load the map etc then get team menu, if u click the spectate u cycle throguh only axis players. And cant veiw allied.


Right, in that case you set this stock cvar:

set scr_spectateenemy 0

That means that each team can only spectate their own team - not the other.
Share |
stealthcod2
General Member
Since: Dec 23, 2008
Posts: 108
Last: Jul 13, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, May. 26, 2009 09:18 pm
ty demon[jumping]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»