lfnetwork.com mark read register faq members calendar

Thread: TFFA Team Locking through Rcon
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 12-01-2010, 04:37 PM   #1
Return
Lurker
 
Join Date: Nov 2010
Posts: 3
TFFA Team Locking through Rcon

Hey Guys,

Was wondering if anyone could help me out on this one,
Me and my clan mates were trying to lock teams on baseJKA
and couldn't find out how till i looked through rcon commands in sdk
and found there was none.
So wondering if anyones mastered the art of locking and unlocking
teams R and B (Maybe F and S as well for additional).

Thanks,
Return.
Return is offline   you may: quote & reply,
Old 12-02-2010, 01:44 AM   #2
acdcfanbill
..the wonders I have seen
 
acdcfanbill's Avatar
 
Status: Super Moderator
Join Date: Jun 2001
Location: Random Hell Wholes around the
Posts: 5,696
Imperialist Meatbags Guild Member The Walking Carpets Guild Member LFN Staff Member 10 year veteran! 
which is team f ?

acdcfanbill is offline   you may: quote & reply,
Old 12-02-2010, 04:08 AM   #3
Return
Lurker
 
Join Date: Nov 2010
Posts: 3
Quote:
Originally Posted by acdcfanbill View Post
which is team f ?
That will be ffa.
Return is offline   you may: quote & reply,
Old 12-08-2010, 10:51 PM   #4
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Swapping teams is handled via a command ("team x")
You will see other examples of players not being able to join certain teams in Game -> g_cmds.c -> Cmd_Team_f (Which will then call SetTeam, but I suggest keeping your changes on a higher level)

I'd create a variable inside the level_locals_t struct (or even make use of cvars) and control it via an RCon command, or an ingame admin system if you have one set up (I may write a tutorial on setting up a decent admin system some day)

I haven't tested this, but it should work.
I adjusted the end of Cmd_Team_f to look like this:
Code:
	trap_Argv( 1, s, sizeof( s ) );

	//[LockedTeams]
	if ( level.lockedTeams[TEAM_FREE] )
	{//Free
		if ( !Q_stricmp( s, "f" ) )
		{
			trap_SendServerCommand( ent-g_entities, "print \"^3Free ^7team is locked\n\"" );
			return;
		}
	}
	if ( level.lockedTeams[TEAM_RED] )
	{//Red
		if ( !Q_stricmp( s, "red" ) || !Q_stricmp( s, "r" ) )
		{
			trap_SendServerCommand( ent-g_entities, "print \"^1Red ^7team is locked\n\"" );
			return;
		}
	}
	if ( level.lockedTeams[TEAM_BLUE] )
	{//Blue
		if ( !Q_stricmp( s, "blue" ) || !Q_stricmp( s, "b" ) )
		{
			trap_SendServerCommand( ent-g_entities, "print \"^5Blue ^7team is locked\n\"" );
			return;
		}
	}
	if ( level.lockedTeams[TEAM_SPECTATOR] )
	{//Spectator
		if ( !Q_stricmpn( s, "score", 5 ) || !Q_stricmpn( s, "follow", 6 ) || !Q_stricmp( s, "spectator" ) || !Q_stricmp( s, "s" ) )
		{
			trap_SendServerCommand( ent-g_entities, "print \"^3Spectator ^7team is locked\n\"" );
			return;
		}
	}
	//[/LockedTeams]

	SetTeam( ent, s );

	ent->client->switchTeamTime = level.time + 5000;
}
I recommend using cvars which would save these settings across rounds. I'll leave the RCon/admin command up to you (RCon commands are handled in g_svcmds.c -> ConsoleCommand)
There may be logic errors involving gametypes, or unhandled teams, but I hope not =p

EDIT: Oh whatever, I got bored.

The end of g_svcmds.c -> ConsoleCommand will look like:
Code:
	if (Q_stricmp (cmd, "listip") == 0) {
		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
		return qtrue;
	}

	//[LockedTeams]
	if ( !Q_stricmp( cmd, "lockteam" ) )
	{
		Svcmd_LockTeam_f();
		return qtrue;
	}
	if ( !Q_stricmp( cmd, "unlockteam" ) )
	{
		Svcmd_UnlockTeam_f();
		return qtrue;
	}
	if ( !Q_stricmp( cmd, "lockedteams" ) )
	{
		G_Printf( "- Free team is %s\n", level.lockedTeams[TEAM_FREE] ? "LOCKED" : "Unlocked" );
		G_Printf( "- Red team is %s\n", level.lockedTeams[TEAM_RED] ? "LOCKED" : "Unlocked" );
		G_Printf( "- Blue team is %s\n", level.lockedTeams[TEAM_BLUE] ? "LOCKED" : "Unlocked" );
		G_Printf( "- Spectator team is %s\n\n", level.lockedTeams[TEAM_SPECTATOR] ? "LOCKED" : "Unlocked" );
		return qtrue;
	}
	//[/LockedTeams]

	if (g_dedicated.integer) {
		if (Q_stricmp (cmd, "say") == 0) {
			trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(1) ) );
			return qtrue;
		}
		// everything else will also be printed as a say command
		trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(0) ) );
		return qtrue;
	}

	return qfalse;
}
Above that function, I have this:
Code:
//[LockedTeams]
static void Svcmd_LockTeam_f( void )
{
	char str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 2 )
	{
		G_Printf( "Usage: lockteam <team>\n" );
		return;
	}

	trap_Argv( 1, str, sizeof( str ) );

		 if ( str[0] == 'f' )	level.lockedTeams[TEAM_FREE] = qtrue;
	else if ( str[0] == 'r' )	level.lockedTeams[TEAM_RED] = qtrue;
	else if ( str[0] == 'b' )	level.lockedTeams[TEAM_BLUE] = qtrue;
	else if ( str[0] == 's' )	level.lockedTeams[TEAM_SPECTATOR] = qtrue;
	else						G_Printf( "Invalid team '%s'\n", str );
}

static void Svcmd_UnlockTeam_f( void )
{
	char str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 2 )
	{
		G_Printf( "Usage: unlockteam <team>\n" );
		return;
	}

	trap_Argv( 1, str, sizeof( str ) );

		 if ( str[0] == 'f' )	level.lockedTeams[TEAM_FREE] = qfalse;
	else if ( str[0] == 'r' )	level.lockedTeams[TEAM_RED] = qfalse;
	else if ( str[0] == 'b' )	level.lockedTeams[TEAM_BLUE] = qfalse;
	else if ( str[0] == 's' )	level.lockedTeams[TEAM_SPECTATOR] = qfalse;
	else						G_Printf( "Invalid team '%s'\n", str );
}
//[/LockedTeams]
This part is tested =p


EDIT2: Ok, after a bit of testing, I found some issues
  • "team r" in an FFA game will let you in, even if free team is locked <-- Fix this by checking if gametype < GT_TEAM and testing for "r", "red", etc
  • "team asdf" in an FFA game will let you in even if free team is locked <-- Might want to deny any invalid team names to fix this
I'll probably end up using entirely different code paths based on gametype.
Anyway, this should be enough to get you started =p..

Last edited by -=*Raz0r*=-; 12-10-2010 at 12:47 AM.
-=*Raz0r*=- is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > TFFA Team Locking through Rcon

Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:57 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.