Example #1
0
void FuncShowMaps(edict_t *pEntity)
{
	FILE *file = NULL;
	const char *path = "AdminMod/maps.txt";
	char fullpath[PATH_MAX];
	char line[MAX_CONF_LEN];
	char buf[MAX_CONF_LEN];

	sup_gamedir_path(path, fullpath);

	file = fopen(fullpath, "r");
	if(!file)
	{
		UTIL_LogPrintf("Unable to open map list file '%s': %s", fullpath, strerror(errno));
		if(pEntity)
			CLIENT_PRINTF(pEntity, print_console, "\nUnable to load map list\n");
		return;
	}

	for(int i = 1, j = 0; !feof(file); i++)
	{
		if(!fgets(line, sizeof(line), file))
		{
			UTIL_LogPrintf("Unable to read %d line", i);
			if(pEntity)
				CLIENT_PRINTF(pEntity, print_console, "\nUnable to load map list\n");
			fclose(file);
			break;
		}

		if(line[0] == '#' || line[0] == ';')
			continue;
		if(strnmatch(line, "//", 2))
			continue;

		j = strlen(line) - 1;
		if(line[j] == '\n')
			line[j] = '\0';

		if(!pEntity)
			LOG_CONSOLE(NULL, "%d) %s", i, line);
		else
		{
			sup_make_str(buf, sizeof(buf), "%d) %s\n", i, line);
			CLIENT_PRINTF(pEntity, print_console, buf);
		}
	}
	fclose(file);
}
Example #2
0
void FuncKickPlayer(edict_t *pEntity, const char *name, const char *reason)
{
	char buf[MAX_NAME];
	char str[MAX_CMD_LEN + 28] = "You've been kicked. Reason: ";
	strncat(str, reason, MAX_CMD_LEN);
	strncat(str, "\n", MAX_CMD_LEN);
	STRNCPY(buf, name, sizeof(buf));
	sup_add_quotes(buf);
	CLIENT_PRINTF(pEntity, print_console, str);

	sup_server_cmd("kick %s", buf);
}
Example #3
0
void PrintBuildInfo(edict_t *ed)
{
	if (!ed)
		return;
	static char MsgBuf[128];
	snprintf(MsgBuf, sizeof(MsgBuf) - 1, "GameDLL info:\n\tBranch: \"%s\"\n", BuildGitBranch);
	CLIENT_PRINTF(ed, print_console, MsgBuf);

	snprintf(MsgBuf, sizeof(MsgBuf) - 1, "\tCommit hash: \"%s\"\n", BuildGitCommitHash);
	CLIENT_PRINTF(ed, print_console, MsgBuf);
	
	//snprintf(MsgBuf, sizeof(MsgBuf) - 1, "\tCommit author: \"%s\"\n", BuildGitCommitAuthor);
	//CLIENT_PRINTF(ed, print_console, MsgBuf);
	if (BuildGitPullRequestNumber[0] != '\0')
	{
		snprintf(MsgBuf, sizeof(MsgBuf) - 1, "\tPull request number: \"%s\\n", BuildGitPullRequestNumber);
		CLIENT_PRINTF(ed, print_console, MsgBuf);
	}

	snprintf(MsgBuf, sizeof(MsgBuf) - 1, "\tDLL Build: %s %s\n\n", BuildDate, BuildTime);
	CLIENT_PRINTF(ed, print_console, MsgBuf);
}
Example #4
0
// Use CMD_ARGV,  CMD_ARGV, and CMD_ARGC to get pointers the character string command.
void ClientCommand( edict_t *pEntity )
{
	const char *pcmd = CMD_ARGV(0);
	const char *pstr;

	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	entvars_t *pev = &pEntity->v;

	if ( FStrEq(pcmd, "say" ) )
	{
		Host_Say( pEntity, 0 );
	}
	else if ( FStrEq(pcmd, "say_team" ) )
	{
		Host_Say( pEntity, 1 );
	}
	else if ( FStrEq(pcmd, "fullupdate" ) )
	{
		GetClassPtr((CBasePlayer *)pev)->ForceClientDllUpdate(); 
	}
	else if ( FStrEq(pcmd, "give" ) )
	{
		if ( g_flWeaponCheat != 0.0)
		{
			int iszItem = ALLOC_STRING( CMD_ARGV(1) );	// Make a copy of the classname
			GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) );
		}
	}
	else if ( FStrEq(pcmd, "fire") )
	{
		if ( g_flWeaponCheat != 0.0)
		{
			CBaseEntity *pPlayer = CBaseEntity::Instance(pEntity);
			if (CMD_ARGC() > 1)
			{
				FireTargets(CMD_ARGV(1), pPlayer, pPlayer, USE_TOGGLE, 0);
			}
			else
			{
				TraceResult tr;
				UTIL_MakeVectors(pev->v_angle);
				UTIL_TraceLine(
					pev->origin + pev->view_ofs,
					pev->origin + pev->view_ofs + gpGlobals->v_forward * 1000,
					dont_ignore_monsters, pEntity, &tr
				);

				if (tr.pHit)
				{
					CBaseEntity *pHitEnt = CBaseEntity::Instance(tr.pHit);
					if (pHitEnt)
					{
						pHitEnt->Use(pPlayer, pPlayer, USE_TOGGLE, 0);
						ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING(pHitEnt->pev->classname), STRING(pHitEnt->pev->targetname) ) );
					}
				}
			}
		}
	}
	else if ( FStrEq(pcmd, "drop" ) )
	{
		// player is dropping an item. 
		GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1));
	}
	else if ( FStrEq(pcmd, "fov" ) )
	{
		if ( g_flWeaponCheat && CMD_ARGC() > 1)
		{
			GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) );
		}
		else
		{
			CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) );
		}
	}
	else if ( FStrEq(pcmd, "use" ) )
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1));
	}
	else if (((pstr = strstr(pcmd, "weapon_")) != NULL)  && (pstr == pcmd))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd);
	}
	else if (FStrEq(pcmd, "lastinv" ))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
	}
	else if ( FStrEq( pcmd, "spectate" ) && (pev->flags & FL_PROXY) )	// added for proxy support
	{
		CBasePlayer * pPlayer = GetClassPtr((CBasePlayer *)pev);

		edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer );
		pPlayer->StartObserver( pev->origin, VARS(pentSpawnSpot)->angles);
	}
	else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) )
	{
		// MenuSelect returns true only if the command is properly handled,  so don't print a warning
	}
	else if ( FStrEq(pcmd, "VModEnable") )
	{
		// clear 'Unknown command: VModEnable' in singleplayer
		return;
	}
	else
	{
		// tell the user they entered an unknown command
		char command[128];

		// check the length of the command (prevents crash)
		// max total length is 192 ...and we're adding a string below ("Unknown command: %s\n")
		strncpy( command, pcmd, 127 );
		command[127] = '\0';

		// tell the user they entered an unknown command
		ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) );
	}
}
Example #5
0
// Use CMD_ARGV,  CMD_ARGV, and CMD_ARGC to get pointers the character string command.
void ClientCommand( edict_t *pEntity )
{
	const char *pcmd = CMD_ARGV(0);
	const char *pstr;

	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	entvars_t *pev = &pEntity->v;

	if ( FStrEq(pcmd, "say" ) )
	{
		Host_Say( pEntity, 0 );
	}
	else if ( FStrEq(pcmd, "say_team" ) )
	{
		Host_Say( pEntity, 1 );
	}
	else if ( FStrEq(pcmd, "spectate" ) )
	{
		// Prevent this is the cvar is set
		if ( allow_spectators.value )
		{
			CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev);
			edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer );
			pPlayer->StartObserver( VARS(pentSpawnSpot)->origin, VARS(pentSpawnSpot)->angles);
		}
	}

	else if ( FStrEq(pcmd, "ob_mode" ) )
	{
		CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev);
		pPlayer->ObserverInput_ChangeMode();
	}
	else if ( FStrEq(pcmd, "ob_prev" ) )
	{
		CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev);
		pPlayer->ObserverInput_PrevPlayer();
	}
	else if ( FStrEq(pcmd, "ob_next" ) )
	{
		CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev);
		pPlayer->ObserverInput_NextPlayer();
	}

	else if ( FStrEq(pcmd, "give" ) )
	{
		if ( g_flWeaponCheat != 0.0)
		{
			int iszItem = ALLOC_STRING( CMD_ARGV(1) );	// Make a copy of the classname
			GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) );
		}
	}

	else if ( FStrEq(pcmd, "drop" ) )
	{
		// player is dropping an item. 
		GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1));
	}
	else if ( FStrEq(pcmd, "fov" ) )
	{
		if ( g_flWeaponCheat && CMD_ARGC() > 1)
		{
			GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) );
		}
		else
		{
			CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) );
		}
	}
	else if ( FStrEq(pcmd, "use" ) )
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1));
	}
	else if (((pstr = strstr(pcmd, "weapon_")) != NULL)  && (pstr == pcmd))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd);
	}
	else if (FStrEq(pcmd, "lastinv" ))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
	}
	else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) )
	{
		// MenuSelect returns true only if the command is properly handled,  so don't print a warning
	}
	else
	{
		// tell the user they entered an unknown command
		char command[128];

		// check the length of the command (prevents crash)
		// max total length is 192 ...and we're adding a string below (#Game_unknown_command)
		strncpy( command, pcmd, 127 );
		command[127] = '\0';

		ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, "#Game_unknown_command", command );
	}
}
Example #6
0
// Use CMD_ARGV,  CMD_ARGV, and CMD_ARGC to get pointers the character string command.
void ClientCommand( edict_t *pEntity )
{
	const char *pcmd = CMD_ARGV(0);
	const char *pstr;

	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	entvars_t *pev = &pEntity->v;

	if ( FStrEq(pcmd, "say" ) )
	{
		Host_Say( pEntity, 0 );
	}
	else if ( FStrEq(pcmd, "say_team" ) )
	{
		Host_Say( pEntity, 1 );
	}
	else if ( FStrEq(pcmd, "give" ) )
	{
		if ( g_flWeaponCheat != 0.0)
		{
			int iszItem = ALLOC_STRING( CMD_ARGV(1) );	// Make a copy of the classname
			GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) );
		}
	}

	else if ( FStrEq(pcmd, "drop" ) )
	{
		// player is dropping an item. 
		GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1));
	}
	else if ( FStrEq(pcmd, "fov" ) )
	{
		if ( g_flWeaponCheat && CMD_ARGC() > 1)
		{
			GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) );
		}
		else
		{
			CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) );
		}
	}
	else if ( FStrEq(pcmd, "use" ) )
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1));
	}
	else if (((pstr = strstr(pcmd, "weapon_")) != NULL)  && (pstr == pcmd))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd);
	}
	else if (FStrEq(pcmd, "lastinv" ))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
	}
	//modif de Julien
	else if (FStrEq(pcmd, "test" ))
	{
		ALERT ( at_console , "testmode ON\n" );
		g_testmode = 1;

		int i = 0;
		while ( i < 5 )
		{
			GetClassPtr((CBasePlayer *)pev)->CheatImpulseCommands( 101 );
			i++;
		}
	}

	//modif de Julien
	else if (FStrEq(pcmd, "testmode" ))
	{
		ALERT ( at_console , "testmode ON\n" );
		g_testmode = 1;
	}



	// SCHED_DIE
	//modif de Julien
	else if (FStrEq(pcmd, "flybee" ))
	{

/*		CBaseMonster *pFlybee = ( CBaseMonster *) UTIL_FindEntityByClassname ( NULL, "monster_flybee" );

		if ( pFlybee != NULL )
		{
			pFlybee->GetScheduleOfType ( SCHED_DIE );
		}*/

		CBaseEntity *pMe = CBaseEntity::Instance ( pEntity );


		CBaseEntity *pE = FindEntityForward( pMe );

		if ( pE )
		{
			if ( pE->pev->takedamage )
				pE->TakeDamage ( pev, pev, pE->pev->health, DMG_GENERIC );
		}
	}

	//modif de Julien
	else if (FStrEq(pcmd, "ordimenu" ))
	{
		if ( atoi(CMD_ARGV(1)) == 2 )
		{
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM );

			//désactive les caméras
			
			edict_t* pentCherche = NULL;

			for ( int i = 0 ; i<15 ; i++ )
			{
				pentCherche = FIND_ENTITY_BY_CLASSNAME ( pentCherche, "monster_camera" );

				if (!FNullEnt(pentCherche))
				{
					CBaseEntity *pTarget = CBaseEntity::Instance(pentCherche);
					pTarget->Use( CBaseEntity::Instance(pEntity), CBaseEntity::Instance(pEntity), USE_ON, 1 );
					//la valeur 1 désactive la camera, 0 la déclenche
				}
			}

			// détruit certains triggers

			pentCherche = NULL;

			for ( int j = 0 ; j<5 ; j++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}
			for ( int k = 0 ; k<5 ; k++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security_2" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}

			for ( int l = 0 ; l<5 ; l++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security_3" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}

		}

		else if ( atoi(CMD_ARGV(1)) == 1 )
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "sentences/blip.wav", 1, ATTN_NORM );
	}

	//modif de Julien
	else if (FStrEq(pcmd, "ordicontrol" ))
	{
		CBaseEntity *pEnt = UTIL_FindEntityByClassname ( NULL, "func_conveyorcontrol" );

		if ( pEnt != NULL )
		{
			pEnt->Use ( GetClassPtr((CBasePlayer *)pev), GetClassPtr((CBasePlayer *)pev), USE_OFF, atoi(CMD_ARGV(1)) );
		}

	}

	else if (FStrEq(pcmd, "keypad" ))
	{
		if ( atoi(CMD_ARGV(1)) == 0 )
		{
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/button10.wav", 1, ATTN_NORM );
			return;
		}

		CBaseEntity *pEntity = UTIL_FindEntityByClassname ( NULL, "func_keypad" );

		while ( pEntity != NULL )
		{
			if ( ENTINDEX(pEntity->edict()) == atoi(CMD_ARGV(1)) )
			{
				FireTargets ( STRING(pEntity->pev->target), pEntity, GetClassPtr((CBasePlayer *)pev), USE_ON, 0 );
				break;
			}

			pEntity = UTIL_FindEntityByClassname ( pEntity, "func_keypad" );
		}

		EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM );

	}

	else if (FStrEq(pcmd, "medkit" ))
	{
		GetClassPtr((CBasePlayer *)pev)->UseMedkit();
	}

	else if (FStrEq(pcmd, "battery" ))
	{
		GetClassPtr((CBasePlayer *)pev)->UseBattery(0);
	}

	else if (FStrEq(pcmd, "soin" ))
	{
		int commande = atoi(CMD_ARGV(1));
		GetClassPtr((CBasePlayer *)pev)->UseBattery(commande);
	}


	else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) )
	{
		// MenuSelect returns true only if the command is properly handled,  so don't print a warning
	}
	else
	{
		// tell the user they entered an unknown command
		ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", pcmd ) );
	}
}