コード例 #1
0
/**
 * The player is spawning.
 *
 * @param clientIndex	The client index.
 **/
void SpawnOnClientSpawn(int clientIndex)
{
	// Get real player index from event key
	CBasePlayer* cBasePlayer = view_as<CBasePlayer>(clientIndex); 

	// Update weapons and model indexes
	if(cBasePlayer->m_bSurvivor || cBasePlayer->m_bZombie || gRoundNum <= 1)
	{
		// Remove all weapons
		WeaponsRemoveAll(cBasePlayer);
	
		// Give default weapon
		cBasePlayer->CItemMaterialize(WEAPONS_SPAWN_WEAPON);
	}

	// If gamemode didn't started
	if(bNewRound)
	{
		// Reset respawn count
		cBasePlayer->m_nRespawnTimes = 0;
		
		// Reset limit of extra items
		ItemsRemoveLimit(view_as<int>(cBasePlayer));
	}
	
	// Reset all variables
	cBasePlayer->m_bZombie 					= false;
	cBasePlayer->m_bSurvivor 				= false;
	cBasePlayer->m_bNemesis 				= false;
	cBasePlayer->m_bSkill 					= false;
	cBasePlayer->m_bNightVisionOn 			= 0;
	cBasePlayer->m_nLastBoughtAmount 		= 0;
	cBasePlayer->m_nSkillCountDown 			= 0;
	cBasePlayer->m_iLevel 					= 1;
	cBasePlayer->m_iMoveType 				= MOVETYPE_WALK;
	cBasePlayer->m_nModelIndex 				= WeaponGetViewModelIndex(view_as<int>(cBasePlayer));
	cBasePlayer->m_iHealth 	   				= GetConVarInt(gCvarList[CVAR_HUMAN_HEALTH]);
	cBasePlayer->m_iArmorValue 				= GetConVarInt(gCvarList[CVAR_HUMAN_ARMOR]);
	cBasePlayer->m_flLaggedMovementValue 	= GetConVarFloat(gCvarList[CVAR_HUMAN_SPEED]); 
	cBasePlayer->m_flGravity 				= GetConVarFloat(gCvarList[CVAR_HUMAN_GRAVITY]);
	cBasePlayer->m_iFOV(90);
	cBasePlayer->m_bSetGlow(false);
	cBasePlayer->m_bFlashLightOn(false); 
	cBasePlayer->m_iRender(255, 255, 255);
	
	// Store spawn origin
	cBasePlayer->m_flGetOrigin(flSpawnOrigin[view_as<int>(cBasePlayer)]);

	// Respawn as zombie?
	if(cBasePlayer->m_bRespawn == ZP_TEAM_ZOMBIE)
	{
		// Is mode started ?
		if (bModeStarted)
		{
			// Make a zombie
			InfectHumanToZombie(view_as<int>(cBasePlayer), false, true);
			return;
		}
	}
	
	// Update human model
	ModelsOnClientSpawn(view_as<int>(cBasePlayer));
	
	// Update level overlay
	ToolsSwitchLevel(cBasePlayer, cBasePlayer->m_iLevel);
}