Exemplo n.º 1
0
// *** Shuffle teams
int G_ShuffleNoRestart_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if(arg) {
		if(trap_Argc() > 2) {
			// CHRUKER: b047 - Removed unneeded linebreak
			G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			return(G_INVALID);
		} else if(!vote_allow_shufflenorestart.integer && ent && !ent->client->sess.referee) {
			G_voteDisableMessage(ent, arg);
			return(G_INVALID);
		}

	// Vote action (vote has passed)
	} else {
		G_shuffleTeams();
	}

	return(G_OK);
}
Exemplo n.º 2
0
// *** Shuffle teams
int G_ShuffleTeams_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if(arg) {
		if(trap_Argc() > 2) {
			G_refPrintf(ent, "Usage: ^3%s %s%s\n\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			return(G_INVALID);
		} else if(!vote_allow_shuffleteamsxp.integer && ent && !ent->client->sess.referee) {
			G_voteDisableMessage(ent, arg);
			return(G_INVALID);
		}

	// Vote action (vote has passed)
	} else {
		// Swap the teams!
		Svcmd_ShuffleTeams_f();
	}

	return(G_OK);
}
Exemplo n.º 3
0
/*
===================
Svcmd_ForceTeam_f

forceTeam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	int			playerNum;
	char		str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 3 ) {
		G_Printf("Usage: forceTeam <player> <team>\n");
		return;
	}

	// find the player
	trap_Argv( 1, str, sizeof( str ) );
	playerNum = PlayerForString( str );
	if ( playerNum == -1 ) {
		return;
	}

	// set the team
	trap_Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[playerNum], str );
}
Exemplo n.º 4
0
/*
==================
Cmd_Say_f
==================
*/
static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
	char		*p;

	if ( trap_Argc () < 2 && !arg0 ) {
		return;
	}

	if (arg0)
	{
		p = ConcatArgs( 0 );
	}
	else
	{
		p = ConcatArgs( 1 );
	}

	SanitizeChatText( p );

	G_Say( ent, NULL, mode, p );
}
Exemplo n.º 5
0
/*
===================
Svcmd_ForceTeam_f

forceTeam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gplayer_t	*player;
	char		str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 3 ) {
		G_Printf("Usage: forceTeam <player> <team>\n");
		return;
	}

	// find the player
	trap_Argv( 1, str, sizeof( str ) );
	player = PlayerForString( str );
	if ( !player ) {
		return;
	}

	// set the team
	trap_Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[player - level.players], str );
}
Exemplo n.º 6
0
// *** Load public settings for current mode ***
int G_Pub_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) {
	// Vote request (vote is being initiated)
	if ( arg ) {
		if ( trap_Argc() > 2 ) {
			G_refPrintf( ent, "Usage: ^3%s %s%s\n", ( ( fRefereeCmd ) ? "\\ref" : "\\callvote" ), arg, aVoteInfo[dwVoteIndex].pszVoteHelp );
			return( G_INVALID );
		} else if ( vote_allow_pub.integer <= 0 && ent && !ent->client->sess.referee ) {
			G_voteDisableMessage( ent, arg );
			return( G_INVALID );
		}

		// Vote action (vote has passed)
	} else {
		// Load in pub settings for current gametype
		G_configSet( g_gametype.integer, qfalse );
		AP( "cp \"Public Settings Loaded!\n\"" );
	}

	return( G_OK );
}
Exemplo n.º 7
0
// Explicit server command to add a view to the client's snapshot
void CG_mvNew_f(void)
{
	if (cg.demoPlayback || trap_Argc() < 2)
	{
		return;
	}
	else
	{
		int  pID;
		char aName[64];

		trap_Args(aName, sizeof(aName));
		pID = CG_findClientNum(aName);

		if (pID >= 0 && !CG_mvMergedClientLocate(pID))
		{
			trap_SendClientCommand(va("mvadd %d\n", pID));
		}
	}
}
Exemplo n.º 8
0
/*
=================
CG_Play_f
=================
*/
void CG_Play_f( void ) {
	int 		i;
	int			c;
	sfxHandle_t	h;

	c = trap_Argc();

	if( c < 2 ) {
		Com_Printf ("Usage: play <sound filename> [sound filename] [sound filename] ...\n");
		return;
	}

	for( i = 1; i < c; i++ ) {
		h = trap_S_RegisterSound( CG_Argv( i ), qfalse );

		if( h ) {
			trap_S_StartLocalSound( h, CHAN_LOCAL_SOUND );
		}
	}
}
Exemplo n.º 9
0
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gclient_t	*cl;
	char		str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 3 ) {
		G_Printf("Usage: forceteam <player> <team>\n");
		return;
	}

	// find the player
	trap_Argv( 1, str, sizeof( str ) );
	cl = ClientForString( str );
	if ( !cl ) {
		return;
	}

	// set the team
	trap_Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[cl - level.clients], str );
}
Exemplo n.º 10
0
void Cmd_NewJail_f(gentity_t *ent)
{
	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 1)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mnewjail\n\""));
		return;
	}

	if(jails_add(ent->client->ps.origin, ent->client->ps.viewangles))
		MM_SendMessage(ent - g_entities, va("print \"New jail spot created.\n\""));
	else
		MM_SendMessage(ent - g_entities, va("print \"Error creating new jail spot.\n\""));

	vmCvar_t mapname;
	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);
	MM_WriteData(va("jails\\%s.json", mapname.string), MM_WriteJails);
}
Exemplo n.º 11
0
static void CG_TeamVoiceChat_f( void ) {
	char chatCmd[64];

	if ( cgs.gametype < GT_WOLF || trap_Argc() != 2 ) {
		return;
	}

	// NERVE - SMF - don't let spectators voice chat
	// NOTE - This cg.snap will be the person you are following, but its just for intermission test
	if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) {
		if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) {
			CG_Printf( CG_TranslateString( "Can't team voice chat as a spectator.\n" ) );
			return;
		}
	}

	trap_Argv( 1, chatCmd, 64 );

	trap_SendConsoleCommand( va( "cmd vsay_team %s\n", chatCmd ) );
}
Exemplo n.º 12
0
// Prints specific callvote command help description.
qboolean G_voteDescription(gentity_t *ent, qboolean fRefereeCmd, int cmd)
{
	char arg[MAX_TOKEN_CHARS];
	char *ref_cmd = (fRefereeCmd) ? "\\ref" : "\\callvote";

	if (!ent)
	{
		return(qfalse);
	}

	trap_Argv(2, arg, sizeof(arg));
	if (!Q_stricmp(arg, "?") || trap_Argc() == 2)
	{
		trap_Argv(1, arg, sizeof(arg));
		G_refPrintf(ent, "\nUsage: ^3%s %s%s\n", ref_cmd, arg, aVoteInfo[cmd].pszVoteHelp);
		return(qtrue);
	}

	return(qfalse);
}
Exemplo n.º 13
0
// *** Map Restart ***
int G_MapRestart_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if(arg) {
		if(trap_Argc() > 2) {
			if(!Q_stricmp(arg2, "?")) {
				G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
				return(G_INVALID);
			}
		}

	// Vote action (vote has passed)
	} else {
		// Restart the map back to warmup
		Svcmd_ResetMatch_f(qfalse, qtrue);
		AP("cp \"^1*** Level Restarted! ***\n\"");
	}

	return(G_OK);
}
Exemplo n.º 14
0
/*
=================
CG_ParseScores

=================
*/
static void CG_ParseScores( void )
{
	int i;

	cg.numScores = ( trap_Argc() - 3 ) / 6;

	if ( cg.numScores > MAX_CLIENTS )
	{
		cg.numScores = MAX_CLIENTS;
	}

	cg.teamScores[ 0 ] = atoi( CG_Argv( 1 ) );
	cg.teamScores[ 1 ] = atoi( CG_Argv( 2 ) );

	memset( cg.scores, 0, sizeof( cg.scores ) );

	if ( cg_debugRandom.integer )
	{
		CG_Printf( "cg.numScores: %d\n", cg.numScores );
	}

	for ( i = 0; i < cg.numScores; i++ )
	{
		//
		cg.scores[ i ].client = atoi( CG_Argv( i * 6 + 3 ) );
		cg.scores[ i ].score = atoi( CG_Argv( i * 6 + 4 ) );
		cg.scores[ i ].ping = atoi( CG_Argv( i * 6 + 5 ) );
		cg.scores[ i ].time = atoi( CG_Argv( i * 6 + 6 ) );
		cg.scores[ i ].weapon = atoi( CG_Argv( i * 6 + 7 ) );
		cg.scores[ i ].upgrade = atoi( CG_Argv( i * 6 + 8 ) );

		if ( cg.scores[ i ].client < 0 || cg.scores[ i ].client >= MAX_CLIENTS )
		{
			cg.scores[ i ].client = 0;
		}

		cgs.clientinfo[ cg.scores[ i ].client ].score = cg.scores[ i ].score;

		cg.scores[ i ].team = cgs.clientinfo[ cg.scores[ i ].client ].team;
	}
}
Exemplo n.º 15
0
// *** Nextmap ***
int G_Nextmap_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) {
	// Vote request (vote is being initiated)
	if ( arg ) {
		if ( trap_Argc() > 2 ) {
			G_refPrintf( ent, "Usage: ^3%s %s%s\n", ( ( fRefereeCmd ) ? "\\ref" : "\\callvote" ), arg, aVoteInfo[dwVoteIndex].pszVoteHelp );
			return( G_INVALID );
		} else if ( !vote_allow_nextmap.integer && ent && !ent->client->sess.referee ) {
			G_voteDisableMessage( ent, arg );
			return( G_INVALID );
		} else {
			char s[MAX_STRING_CHARS];
			if ( g_gametype.integer == GT_WOLF_CAMPAIGN ) {
				trap_Cvar_VariableStringBuffer( "nextcampaign", s, sizeof( s ) );
				if ( !*s ) {
					G_refPrintf( ent, "'nextcampaign' is not set." );
					return( G_INVALID );
				}
			} else {
				trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) );
				if ( !*s ) {
					G_refPrintf( ent, "'nextmap' is not set." );
					return( G_INVALID );
				}
			}
		}

		// Vote action (vote has passed)
	} else {
		if ( g_gametype.integer == GT_WOLF_CAMPAIGN ) {
			// Load in the nextcampaign
			trap_SendConsoleCommand( EXEC_APPEND, "vstr nextcampaign\n" );
			AP( "cp \"^3*** Loading nextcampaign! ***\n\"" );
		} else {
			// Load in the nextmap
			trap_SendConsoleCommand( EXEC_APPEND, "vstr nextmap\n" );
			AP( "cp \"^3*** Loading nextmap! ***\n\"" );
		}
	}

	return( G_OK );
}
Exemplo n.º 16
0
/*
===================
Svcmd_EntityList_f
===================
*/
void Svcmd_EntityList_f(void)
{
	int       e, entsFree = 0;
	gentity_t *check = g_entities + 1;

	// FIXME: create line before print
	for (e = 0; e < MAX_GENTITIES ; e++, check++)
	{
		if (!check->inuse)
		{
			if (trap_Argc() > 1)
			{
				G_Printf("^2%4i: %s\n", e, check->classname);
			}
			entsFree++;
			continue;
		}

		G_Printf("%4i:", e);

		if (check->s.eType >= 0 && check->s.eType <= ET_EVENTS)
		{
			G_Printf("%-27s", enttypenames[check->s.eType]);
		}
		else
		{
			G_Printf("%-27i", check->s.eType); // tempEntity FIXME: print event
		}

		if (check->classname)
		{
			G_Printf(" %s\n", check->classname);
		}
		else
		{
			G_Printf(" *unknown classname*\n");
		}
	}
	G_Printf("%4i: entities not in use\n", entsFree);
	G_Printf("%4i: num_entities\n", level.num_entities);
}
Exemplo n.º 17
0
/*
=================
Cmd_Follow_f
=================
*/
void Cmd_Follow_f( gentity_t *ent ) {
	int		i;
	char	arg[MAX_TOKEN_CHARS];

	if ( trap_Argc() != 2 ) {
		if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
			StopFollowing( ent );
		}
		return;
	}

	trap_Argv( 1, arg, sizeof( arg ) );
	i = ClientNumberFromString( ent, arg );
	if ( i == -1 ) {
		return;
	}

	// can't follow self
	if ( &level.clients[ i ] == ent->client ) {
		return;
	}

	// can't follow another spectator
	if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
		return;
	}

	// if they are playing a tournement game, count as a loss
	if ( (g_gametype.integer == GT_TOURNAMENT )
		&& ent->client->sess.sessionTeam == TEAM_FREE ) {
		ent->client->sess.losses++;
	}

	// first set them to spectator
	if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
		SetTeam( ent, "spectator" );
	}

	ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
	ent->client->sess.spectatorClient = i;
}
Exemplo n.º 18
0
/*
=================
CG_Announce_f

Play an announcer sound
=================
*/
static void CG_Announce( void )
{
  const char *event, *soundName;

  if( !cg_announcer.integer )
    return;

  if( trap_Argc( ) != 2 )
    return;

  event = CG_Argv( 1 );

  if( !Q_stricmp( event, "votenow" ) ||
      !Q_stricmp( event, "votecancelled" ) ||
      !Q_stricmp( event, "votefailed" ) ||
      !Q_stricmp( event, "votepassed" ) || 
      !Q_stricmp( event, "timelimit_hit" ) ||
      !Q_stricmp( event, "timelimit_1min" ) ||
      !Q_stricmp( event, "timelimit_5min" ) ||
      !Q_stricmp( event, "suddendeath" ) ||
      !Q_stricmp( event, "sdimminent" ) || 
      !Q_stricmp( event, "alienswin" ) || 
      !Q_stricmp( event, "aliensadmit" ) ||
      !Q_stricmp( event, "alienslocked" ) ||
      !Q_stricmp( event, "aliensunlocked" ) ||
      !Q_stricmp( event, "humanswin" ) || 
      !Q_stricmp( event, "humansadmit" ) ||
      !Q_stricmp( event, "humanslocked" ) ||
      !Q_stricmp( event, "humansunlocked" ) ||
      !Q_stricmp( event, "stalemate" ) ||
      !Q_stricmp( event, "1minremains" ) ||
      !Q_stricmp( event, "5minremains" ) )
    soundName = va( "sound/feedback/%s.wav", event );
  else
    return;

  cg.announcerStackLatest++;
  cg.announcerStackLatest %= MAX_ANNOUNCER_STACK;

  cg.announcerStack[ cg.announcerStackLatest ] = trap_S_RegisterSound( soundName, qfalse );
}
Exemplo n.º 19
0
// forty - #607 - Merge in Density's damage received display code
// Sends a player's stats to the requesting client.
void G_statsPrint(gentity_t *ent, int nType)
{
    int  pid;
    char *cmd = (nType == 0) ? "ws" : ((nType == 1) ? "wws" : "gstats");    // Yes, not the cleanest
    char arg[MAX_TOKEN_CHARS];

    if (!ent || (ent->r.svFlags & SVF_BOT))
    {
        return;
    }

    // If requesting stats for self, its easy.
    if (trap_Argc() < 2)
    {
        if (ent->client->sess.sessionTeam != TEAM_SPECTATOR)
        {
            CP(va("%s %s\n", cmd, G_createStats(ent, ent)));
            // Specs default to players they are chasing
        }
        else if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW)
        {
            CP(va("%s %s\n", cmd, G_createStats(g_entities + ent->client->sess.spectatorClient, ent)));
        }
        else
        {
            CP("cpm \"Type ^3\\stats <player_id>^7 to see stats on an active player.\n\"");
            return;
        }
    }
    else
    {
        // Find the player to poll stats.
        trap_Argv(1, arg, sizeof(arg));
        if ((pid = ClientNumberFromString(ent, arg)) == -1)
        {
            return;
        }

        CP(va("%s %s\n", cmd, G_createStats(g_entities + pid, ent)));
    }
}
/*
===================
Svcmd_ClientCommand_f

<cmd> <cid> <text>
===================
*/
static void Svcmd_ClientCommand_f( clientCommand_t cmd ) {
    char str[3], *cmdstr;
    int cid;

    if ( trap_Argc() < 3 ) {
        // FIXME: Use real command in error message
        G_Printf( "usage: $cmd <cid> <text>\n" );
        return;
    }

    switch ( cmd ) {
    case CCMD_MP:
        cmdstr = "mp";
        break;
    case CCMD_CP:
        cmdstr = "cp";
        break;
    case CCMD_PRINT:
        cmdstr = "print";
        break;

    default:
        cmdstr = NULL;
        G_Error( "Svcmd_ClientCommand_f: cmd out of clientCommand_t range!\n" );
    }

    trap_Argv( 1, str, sizeof( str ) );
    cid = atoi( str );

    if ( ( ( cid < 0 ) || ( cid >= MAX_CLIENTS ) ) && ( cid != -1 ) ) {
        G_Printf( "Not a valid client number.\n" );
        return;
    }

    if ( (cid != -1 ) && ( level.clients[cid].pers.connected != CON_CONNECTED ) ) {
        G_Printf( "Client not connected.\n" );
        return;
    }

    trap_SendServerCommand( cid, va( "%s \"%s\"" , cmdstr, ConcatArgs( 2 ) ) );
}
Exemplo n.º 21
0
static void CG_ParsePings(void)
{
	int	i, k;
	int	numClients;

	numClients = trap_Argc() - 1;
	if (numClients > MAX_CLIENTS) {
		numClients = MAX_CLIENTS;
	}

	for (i = 0, k = 0; i < numClients; ++i) {
		if (!cgs.clientinfo[k].infoValid) {
			continue;
		}
		if (cgs.clientinfo[k].botSkill) {
			cgs.clientinfo[k].ping = 0;
			continue;
		}
		cgs.clientinfo[k++].ping = atoi(BG_Argv(i + 1));
	}
}
Exemplo n.º 22
0
static void CG_Rocket_EventPlay()
{
	const char *track = nullptr;

	// Specifying multiple files to randomly select between
	if ( trap_Argc() > 2 )
	{
		int numSounds = atoi( CG_Argv( 1 ) );
		if ( numSounds > 0 )
		{
			int selection = rand() % numSounds + 1;
			track = CG_Argv( 1 + selection );
			trap_S_StartBackgroundTrack( track, track );
		}
	}
	else
	{
		track = CG_Argv( 1 );
		trap_S_StartBackgroundTrack( track, track );
	}
}
Exemplo n.º 23
0
void CG_parseMapVoteListInfo()
{
	int i;

	cgs.dbNumMaps = (trap_Argc() - 2) / 4;

	if (atoi(CG_Argv(1)))
	{
		cgs.dbMapMultiVote = qtrue;
	}

	for (i = 0; i < cgs.dbNumMaps; i++)
	{
		Q_strncpyz(cgs.dbMaps[i], CG_Argv((i * 4) + 2),
		           sizeof(cgs.dbMaps[0]));
		cgs.dbMapVotes[i]      = 0;
		cgs.dbMapID[i]         = atoi(CG_Argv((i * 4) + 3));
		cgs.dbMapLastPlayed[i] = atoi(CG_Argv((i * 4) + 4));
		cgs.dbMapTotalVotes[i] = atoi(CG_Argv((i * 4) + 5));
		if (CG_FindArenaInfo(va("scripts/%s.arena", cgs.dbMaps[i]),
		                     cgs.dbMaps[i], &cgs.arenaData))
		{
			Q_strncpyz(cgs.dbMapDispName[i],
			           cgs.arenaData.longname,
			           sizeof(cgs.dbMaps[0]));
		}
		else
		{
			Q_strncpyz(cgs.dbMapDispName[i],
			           cgs.dbMaps[i],
			           sizeof(cgs.dbMaps[0]));
		}
	}

	CG_LocateArena();

	cgs.dbMapListReceived = qtrue;

	return;
}
Exemplo n.º 24
0
/*
=================
Cmd_Team_f
=================
*/
void Cmd_Team_f( gentity_t *ent ) {
	int			oldTeam;
	char		s[MAX_TOKEN_CHARS];

	if ( trap_Argc() != 2 ) {
		oldTeam = ent->client->sess.sessionTeam;
		switch ( oldTeam ) {
		case TEAM_BLUE:
			trap_SendServerCommand( ent-g_entities, "print \"Blue team\n\"" );
			break;
		case TEAM_RED:
			trap_SendServerCommand( ent-g_entities, "print \"Red team\n\"" );
			break;
		case TEAM_FREE:
			trap_SendServerCommand( ent-g_entities, "print \"Free team\n\"" );
			break;
		case TEAM_SPECTATOR:
			trap_SendServerCommand( ent-g_entities, "print \"Spectator team\n\"" );
			break;
		}
		return;
	}

	if ( ent->client->switchTeamTime > level.time ) {
		trap_SendServerCommand( ent-g_entities, "print \"May not switch teams more than once per 5 seconds.\n\"" );
		return;
	}

	// if they are playing a tournement game, count as a loss
	if ( (g_gametype.integer == GT_TOURNAMENT )
		&& ent->client->sess.sessionTeam == TEAM_FREE ) {
		ent->client->sess.losses++;
	}

	trap_Argv( 1, s, sizeof( s ) );

	SetTeam( ent, s );

	ent->client->switchTeamTime = level.time + 5000;
}
Exemplo n.º 25
0
qboolean JPLua_Event_ServerCommand( void )
{
#ifdef JPLUA
	for ( JPLua.currentPlugin = JPLua.plugins;
			JPLua.currentPlugin;
			JPLua.currentPlugin = JPLua.currentPlugin->next
		)
	{
		jplua_plugin_command_t *cmd = JPLua.currentPlugin->serverCmds;

		while ( cmd )
		{
			int top = 0;
			int i = 0;

			if ( !Q_stricmp( CG_Argv( 0 ), cmd->command ) )
			{
				lua_rawgeti( JPLua.state, LUA_REGISTRYINDEX, cmd->handle );

				//Push table of arguments
				lua_newtable( JPLua.state );
				top = lua_gettop( JPLua.state );
				for ( i=1; i<trap_Argc(); i++ )
				{
					lua_pushnumber( JPLua.state, i );
					lua_pushstring( JPLua.state, CG_Argv( i ) );
					lua_settable( JPLua.state, top );
				}

				JPLUACALL( JPLua.state, 1, 1 );
				return qtrue;
			}

			cmd = cmd->next;
		}
	}
#endif // JPLUA

	return qfalse;
}
Exemplo n.º 26
0
static void Svcmd_Pr_f( void )
{
  char targ[ 4 ];
  int cl;

  if( trap_Argc( ) < 3 )
  {
    G_Printf( "usage: <clientnum|-1> <message>\n" );
    return;
  }

  trap_Argv( 1, targ, sizeof( targ ) );
  cl = atoi( targ );

  if( cl >= MAX_CLIENTS || cl < -1 )
  {
    G_Printf( "invalid clientnum %d\n", cl );
    return;
  }

  trap_SendServerCommand( cl, va( "print \"%s\n\"", ConcatArgs( 2 ) ) );
}
Exemplo n.º 27
0
static void CG_ParseTeamInfo(void)
{
	int				i, argc;
	int				clientNum;
	clientInfo_t	*ci;

	argc = trap_Argc() - 1;

	i = 1;
	while (i < argc) {
		clientNum = atoi(BG_Argv(i++));
		if (clientNum < 0 || clientNum > MAX_CLIENTS - 1) {
			CG_Printf(S_COLOR_YELLOW "Invalid clientNum in tinfo.\n");
			continue;
		}
		ci = &cgs.clientinfo[clientNum];
		ci->location = atoi(BG_Argv(i++));
		ci->health = atoi(BG_Argv(i++));
		ci->armor = atoi(BG_Argv(i++));
		ci->weapon = atoi(BG_Argv(i++));
	}
}
Exemplo n.º 28
0
Arquivo: g_vote.c Projeto: ETrun/ETrun
/**
 * Random map vote
 */
int G_Randommap_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) {
	// Nico, silent GCC
	(void)arg2;

	// Nico, check if API is used
	if (!g_useAPI.integer) {
		CP(va("print \"%s^w: random map voting is disabled on this server.\n\"", GAME_VERSION_COLORED));
		return G_INVALID;
	}

	// Vote request (vote is being initiated)
	if (arg) {
		if (trap_Argc() > 2) {
			G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			return G_INVALID;
		} else if (!vote_allow_randommap.integer && ent && !ent->client->sess.referee) {
			G_voteDisableMessage(ent, arg);
			return G_INVALID;
		}

		// Vote action (vote has passed)
	} else {
		char *result = NULL;

		AP("cp \"Loading a random map!\n\"");

		result = malloc(RESPONSE_MAX_SIZE * sizeof (char));

		if (!result) {
			G_Error("G_Randommap_v: malloc failed\n");
		}

		if (!G_API_randommap(result, ent, level.rawmapname)) {
			CP(va("print \"%s^w: random map vote failed!\n\"", GAME_VERSION_COLORED));
			return G_INVALID;
		}
	}
	return G_OK;
}
Exemplo n.º 29
0
void Cmd_ListJail_f(gentity_t *ent)
{
	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 1)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mlistjail\n\""));
		return;
	}

	MM_SendMessage(ent - g_entities, "print \"Jail spots:\n\"");
	MM_SendMessage(ent - g_entities, "print \"  Origin\n\"");

	jail_t *root = jails.next;
	int i = 0;
	while(root)
	{
		MM_SendMessage(ent - g_entities, va("print \"%i (%i %i %i)\n\"", i++, (int)root->origin[0], (int)root->origin[1], (int)root->origin[2]));
		root = root->next;
	}
}
Exemplo n.º 30
0
/*
==================
G_GetPlayerByName
==================
*/
gclient_t *G_GetPlayerByName(char *name)
{
	int       i;
	gclient_t *cl;
	char      cleanName[64];

	// make sure server is running
	if (!G_Is_SV_Running())
	{
		return NULL;
	}

	if (trap_Argc() < 2)
	{
		G_Printf("No player specified.\n");
		return NULL;
	}

	for (i = 0; i < level.numConnectedClients; i++)
	{
		cl = &level.clients[level.sortedClients[i]];

		if (!Q_stricmp(cl->pers.netname, name))
		{
			return cl;
		}

		Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
		Q_CleanStr(cleanName);
		if (!Q_stricmp(cleanName, name))
		{
			return cl;
		}
	}

	G_Printf("Player %s is not on the server\n", name);

	return NULL;
}