Exemplo n.º 1
0
void CRemotePlayer::HandleVehicleEntryExit()
{
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	MATRIX4X4 mat;

	if(!m_pPlayerPed) return;

	if(GetState() == PLAYER_STATE_ONFOOT) {
		if(m_pPlayerPed->IsInVehicle()) {
			m_pPlayerPed->GetMatrix(&mat);
			m_pPlayerPed->RemoveFromVehicleAndPutAt(mat.pos.X,mat.pos.Y,mat.pos.Z);
		}
		return;
	}

	if( GetState() == PLAYER_STATE_DRIVER || GetState() == PLAYER_STATE_PASSENGER )
	{
		if(!m_pPlayerPed->IsInVehicle()) {
			// if they're onfoot, put them in the vehicle.
			CVehicle *pVehicle = pVehiclePool->GetAt(m_VehicleID);
			if(pVehicle) {
				int iCarID = pVehiclePool->FindGtaIDFromID(m_VehicleID);
				m_pPlayerPed->PutDirectlyInVehicle(iCarID,m_byteSeatID);
			}
		} else {
			// validate the vehicle they're driving is the one they're
			// reporting to be in.
			int iCurrentVehicle = m_pPlayerPed->GetCurrentVehicleID();
			int iReportedVehicle = pVehiclePool->FindGtaIDFromID(m_VehicleID);
			if(iCurrentVehicle != iReportedVehicle) {
				m_pPlayerPed->PutDirectlyInVehicle(iReportedVehicle,m_byteSeatID);
			}
		}
	}
}
Exemplo n.º 2
0
static void Fix(void)
{
	CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
	if (pLocalPlayer->IsInVehicle())
	{
		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
		pVehicle->SetHealth(5000);
	}
}
Exemplo n.º 3
0
static void DoubleCarSpeed(void)
{
	CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
	if (pLocalPlayer->IsInVehicle())
	{
		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
		pVehicle->DoubleSpeed();
	}
}
Exemplo n.º 4
0
static void InvertSpeed(void)
{
	CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
	if (pLocalPlayer->IsInVehicle())
	{
		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
		VECTOR vecMoveSpeed;
		pVehicle->GetMoveSpeedVector(&vecMoveSpeed);
		vecMoveSpeed.X *= -1;
		vecMoveSpeed.Y *= -1;
		vecMoveSpeed.Z *= -1;
		pVehicle->SetMoveSpeedVector(vecMoveSpeed);
	}
}
Exemplo n.º 5
0
static void InstantStop(void)
{
	CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
	if (pLocalPlayer->IsInVehicle())
	{
		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
		VECTOR vecMoveSpeed;
		vecMoveSpeed.X = 0;
		vecMoveSpeed.Y = 0;
		vecMoveSpeed.Z = 0;
		pVehicle->SetMoveSpeedVector(vecMoveSpeed);
		pVehicle->SetTurnSpeedVector(vecMoveSpeed);
	}
}
Exemplo n.º 6
0
void CRemotePlayer::StorePassengerFullSyncData(PASSENGER_SYNC_DATA *ppsSync)
{
	if(GetTickCount() < m_dwWaitForEntryExitAnims) return;

	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();

	memcpy(&m_psSync,ppsSync,sizeof(PASSENGER_SYNC_DATA));
	m_VehicleID = ppsSync->VehicleID;
	m_byteSeatID = ppsSync->byteSeatFlags & 127;
	if (pVehiclePool) m_pCurrentVehicle = pVehiclePool->GetAt(m_VehicleID);
	m_fReportedHealth = (float)ppsSync->bytePlayerHealth;
	m_fReportedArmour = (float)ppsSync->bytePlayerArmour;
	m_byteUpdateFromNetwork = UPDATE_TYPE_PASSENGER;
	
	SetState(PLAYER_STATE_PASSENGER);
}
Exemplo n.º 7
0
void CRemotePlayer::StoreInCarFullSyncData(INCAR_SYNC_DATA *picSync)
{	
	if(GetTickCount() < m_dwWaitForEntryExitAnims) return;

	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();

	memcpy(&m_icSync,picSync,sizeof(INCAR_SYNC_DATA));
	m_VehicleID = picSync->VehicleID;
	if (pVehiclePool) m_pCurrentVehicle = pVehiclePool->GetAt(m_VehicleID);

	m_byteSeatID = 0;
	m_fReportedHealth = (float)picSync->bytePlayerHealth;
	m_fReportedArmour = (float)picSync->bytePlayerArmour;
	m_byteUpdateFromNetwork = UPDATE_TYPE_INCAR;
	
	SetState(PLAYER_STATE_DRIVER);
}
Exemplo n.º 8
0
void CRemotePlayer::UpdateSurfing()
{
	if ( m_ofSync.wSurfInfo > MAX_VEHICLES ) { // its an object

			m_ofSync.wSurfInfo -= MAX_VEHICLES; // derive proper object id
			CObjectPool* pObjectPool = pNetGame->GetObjectPool();
			CObject* pObject = pObjectPool->GetAt((BYTE)m_ofSync.wSurfInfo);

			if (pObject) {
				MATRIX4X4 objMat;
				pObject->GetMatrix(&objMat);
				objMat.pos.X += m_ofSync.vecSurfOffsets.X;
				objMat.pos.Y += m_ofSync.vecSurfOffsets.Y;
				objMat.pos.Z += m_ofSync.vecSurfOffsets.Z;
				m_pPlayerPed->SetMatrix(objMat);
			}

	} else { // must be a vehicle

		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(m_ofSync.wSurfInfo);

		if (pVehicle) {
			MATRIX4X4 matPlayer, matVehicle;
			VECTOR vecMoveSpeed,vecTurnSpeed;

			pVehicle->GetMatrix(&matVehicle);
			pVehicle->GetMoveSpeedVector(&vecMoveSpeed);
			pVehicle->GetTurnSpeedVector(&vecTurnSpeed);

			m_pPlayerPed->GetMatrix(&matPlayer);
		
			matPlayer.pos.X = matVehicle.pos.X + m_ofSync.vecSurfOffsets.X;
			matPlayer.pos.Y = matVehicle.pos.Y + m_ofSync.vecSurfOffsets.Y;
			matPlayer.pos.Z = matVehicle.pos.Z + m_ofSync.vecSurfOffsets.Z;

			m_pPlayerPed->SetMatrix(matPlayer);
			m_pPlayerPed->SetMoveSpeedVector(vecMoveSpeed);
			//m_pPlayerPed->SetTurnSpeedVector(vecTurnSpeed);
		}
	}
}
Exemplo n.º 9
0
void CRemotePlayer::StoreTrailerFullSyncData(TRAILER_SYNC_DATA *trSync)
{
	VEHICLEID TrailerID = m_icSync.TrailerID;
	if (!TrailerID) return;

	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	CVehicle *pVehicle = NULL;

	if (pVehiclePool) pVehicle = pVehiclePool->GetAt(TrailerID);
	if (pVehicle) 
	{
		MATRIX4X4 matWorld;

		memcpy(&matWorld.pos, &trSync->vecPos, sizeof(VECTOR));
		DecompressNormalVector(&matWorld.up, &trSync->cvecDirection);
		DecompressNormalVector(&matWorld.right, &trSync->cvecRoll);
		
		pVehicle->SetMatrix(matWorld);
		pVehicle->SetMoveSpeedVector(trSync->vecMoveSpeed);
	}
}
Exemplo n.º 10
0
void CRemotePlayer::StoreUnoccupiedSyncData(UNOCCUPIED_SYNC_DATA * unocSync)
{

	VEHICLEID UnocID = unocSync->VehicleID;
	if (!UnocID || UnocID == INVALID_VEHICLE_ID) return;
	
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	CVehicle *pVehicle = NULL;
	if (pVehiclePool) {
		pVehicle = pVehiclePool->GetAt(UnocID);
		pVehiclePool->SetLastUndrivenID(UnocID, m_PlayerID);
	}

	if(pVehicle && !pVehicle->HasADriver()) 
	{
		MATRIX4X4 matWorld;

		pVehicle->GetMatrix(&matWorld);

		DecompressNormalVector(&matWorld.up, &unocSync->cvecDirection);
		DecompressNormalVector(&matWorld.right, &unocSync->cvecRoll);

		// if we're pretty already there.. no translation. 
		if( (FloatOffset(unocSync->vecPos.X,matWorld.pos.X) <= 0.1f) &&
			(FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) <= 0.1f) &&
			(FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) <= 0.1f) )
		{
			return;
		}

		// if difference is over 8 units, direct translation
		if( !pVehicle->IsAdded() ||
			(FloatOffset(unocSync->vecPos.X,matWorld.pos.X) > 8.0f) ||
			(FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) > 8.0f) ||
			(FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) > 8.0f) ) {

			matWorld.pos.X = unocSync->vecPos.X;
			matWorld.pos.Y = unocSync->vecPos.Y;
			matWorld.pos.Z = unocSync->vecPos.Z;

			pVehicle->SetMatrix(matWorld);
			pVehicle->SetMoveSpeedVector(unocSync->vecMoveSpeed);
			pVehicle->SetTurnSpeedVector(unocSync->vecTurnSpeed);
			return;
		}

		// gradually increase/decrease velocities towards the target								
		pVehicle->SetMatrix(matWorld);							// rotation
		pVehicle->SetMoveSpeedVector(unocSync->vecMoveSpeed);	// move velocity
		pVehicle->SetTurnSpeedVector(unocSync->vecTurnSpeed);	// turn velocity

		VECTOR vec = {0.0f, 0.0f, 0.0f};		
		pVehicle->GetMoveSpeedVector(&vec);

		if( FloatOffset(unocSync->vecPos.X,matWorld.pos.X) > 0.05 ) {
			vec.X += (unocSync->vecPos.X - matWorld.pos.X) * 0.05f;
		}
		if( FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) > 0.05 ) {
			vec.Y += (unocSync->vecPos.Y - matWorld.pos.Y) * 0.05f;
		}
		if( FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) > 0.05 ) {
			vec.Z += (unocSync->vecPos.Z - matWorld.pos.Z) * 0.05f;
		}

		pVehicle->SetMoveSpeedVector(vec);				
		pVehicle->m_bRemoteUnocSync = true;
	}
}
Exemplo n.º 11
0
void CRemotePlayer::Process()
{
	CPlayerPool *pPool = pNetGame->GetPlayerPool();
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	CLocalPlayer *pLocalPlayer = pPool->GetLocalPlayer();
	MATRIX4X4 matVehicle;
	VECTOR vecMoveSpeed;

	if(IsActive())
	{
		if(m_pPlayerPed)
		{
			m_pPlayerPed->ProcessMarkers(
				pNetGame->m_bLimitGlobalChatRadius,
				pNetGame->m_fGlobalChatRadius,TRUE);

			if(GetTickCount() > m_dwWaitForEntryExitAnims) {
				HandleVehicleEntryExit();
			}

			// ---- ONFOOT NETWORK PROCESSING ----
			if( GetState() == PLAYER_STATE_ONFOOT &&
				m_byteUpdateFromNetwork == UPDATE_TYPE_ONFOOT )
			{	
				if(GetTickCount() > m_dwWaitForEntryExitAnims) {
					HandleVehicleEntryExit();
				}

				// If the user has sent X, Y or Z offsets we need to 'attach' him to the car using these offsets
				if ( !IsSurfingOrTurretMode() )
				{
					// If the user hasn't sent these, they're obviously not on the car, so we just sync
					// their normal movement/speed/etc.
					UpdateOnFootPositionAndSpeed(&m_ofSync.vecPos,&m_ofSync.vecMoveSpeed);
					UpdateOnfootTargetPosition();
				}

				// UPDATE ROTATION
				m_pPlayerPed->SetTargetRotation(m_ofSync.fRotation);
		
				// UPDATE CURRENT WEAPON
				if(m_pPlayerPed->IsAdded() && m_pPlayerPed->GetCurrentWeapon() != m_ofSync.byteCurrentWeapon) {
					m_pPlayerPed->SetArmedWeapon(m_ofSync.byteCurrentWeapon);

					// double check
					if(m_pPlayerPed->GetCurrentWeapon() != m_ofSync.byteCurrentWeapon) {
						m_pPlayerPed->GiveWeapon(m_ofSync.byteCurrentWeapon,9999);
						m_pPlayerPed->SetArmedWeapon(m_ofSync.byteCurrentWeapon);
					}
				}

				// First person weapon action hack
				if (IS_TARGETING(m_ofSync.wKeys)) {
					if (m_pPlayerPed->GetCurrentWeapon() == 34 ||
						m_pPlayerPed->GetCurrentWeapon() == 35 ||
						m_pPlayerPed->GetCurrentWeapon() == 36)
					{
						m_pPlayerPed->SetActionTrigger(12);
					}
				} else if (m_pPlayerPed->GetActionTrigger() == 12) {
					m_pPlayerPed->SetActionTrigger(1);
				}

				m_pCurrentVehicle = NULL;
				m_byteUpdateFromNetwork = UPDATE_TYPE_NONE;
			}

			// ---- DRIVER NETWORK PROCESSING ----
			else if(GetState() == PLAYER_STATE_DRIVER &&
				m_byteUpdateFromNetwork == UPDATE_TYPE_INCAR)
			{
				if(!m_pCurrentVehicle) return;
               
				// MATRIX
				DecompressNormalVector(&matVehicle.right,&m_icSync.cvecRoll);
				DecompressNormalVector(&matVehicle.up,&m_icSync.cvecDirection);

				matVehicle.pos.X = m_icSync.vecPos.X;
				matVehicle.pos.Y = m_icSync.vecPos.Y;
				matVehicle.pos.Z = m_icSync.vecPos.Z;

				// MOVE SPEED
				vecMoveSpeed.X = m_icSync.vecMoveSpeed.X;
				vecMoveSpeed.Y = m_icSync.vecMoveSpeed.Y;
				vecMoveSpeed.Z = m_icSync.vecMoveSpeed.Z;

				// Note: Train Speed and Tire Popping values are mutually exclusive, which means
				//       if one is set, the other one will be affected.

				if( m_pCurrentVehicle->GetModelIndex() == TRAIN_PASSENGER_LOCO ||
					m_pCurrentVehicle->GetModelIndex() == TRAIN_FREIGHT_LOCO ||
					m_pCurrentVehicle->GetModelIndex() == TRAIN_TRAM) {
					// TRAIN MATRIX UPDATE
					UpdateTrainDriverMatrixAndSpeed(&matVehicle,&vecMoveSpeed, m_icSync.fTrainSpeed);
				} else {

					// GENERIC VEHICLE MATRIX UPDATE
					UpdateInCarMatrixAndSpeed(matVehicle,vecMoveSpeed);
					UpdateIncarTargetPosition();
					
					// FOR TIRE POPPING
					if (pNetGame->m_bTirePopping) {
						if (m_pCurrentVehicle->GetVehicleSubtype() == VEHICLE_SUBTYPE_BIKE) {
							m_pCurrentVehicle->SetWheelPopped(0, m_icSync.byteTires[0]);
							m_pCurrentVehicle->SetWheelPopped(1, m_icSync.byteTires[1]);
						} 
						else if ( m_pCurrentVehicle->GetVehicleSubtype() == VEHICLE_SUBTYPE_CAR ) {
							m_pCurrentVehicle->SetWheelPopped(0, m_icSync.byteTires[0]);
							m_pCurrentVehicle->SetWheelPopped(1, m_icSync.byteTires[1]);
							m_pCurrentVehicle->SetWheelPopped(2, m_icSync.byteTires[2]);
							m_pCurrentVehicle->SetWheelPopped(3, m_icSync.byteTires[3]);
						}
					}
				}

				// HYDRA THRUSTERS
				if(m_pCurrentVehicle->GetModelIndex() == HYDRA) {
					m_pCurrentVehicle->SetHydraThrusters(m_icSync.dwHydraThrustAngle);
				}
		
				m_pCurrentVehicle->SetSirenOn(m_icSync.byteSirenOn);
				m_pCurrentVehicle->SetLandingGearState((eLandingGearState)m_icSync.byteLandingGearState);
		
				// VEHICLE HEALTH
				m_pCurrentVehicle->SetHealth(m_icSync.fCarHealth);

				// TRAILER AUTOMATIC ATTACHMENT AS THEY MOVE INTO IT
				if (m_pCurrentVehicle->GetDistanceFromLocalPlayerPed() < LOCKING_DISTANCE)
				{
					if (m_icSync.TrailerID && m_icSync.TrailerID < MAX_VEHICLES)
					{
						CVehicle* pRealTrailer = m_pCurrentVehicle->GetTrailer();
						CVehicle *pTrailerVehicle = pVehiclePool->GetAt(m_icSync.TrailerID);
						if (!pRealTrailer) {
							if (pTrailerVehicle) {
								m_pCurrentVehicle->SetTrailer(pTrailerVehicle);
								m_pCurrentVehicle->AttachTrailer();
							}
						}
					} 
					else
					{
						if (m_pCurrentVehicle->GetTrailer()) {
							m_pCurrentVehicle->DetachTrailer();
							m_pCurrentVehicle->SetTrailer(NULL);
						}
					}
				}
				else
				{
					m_pCurrentVehicle->SetTrailer(NULL);
				}

				// UPDATE CURRENT WEAPON (FOR DRIVER!)
				if( m_pPlayerPed->IsAdded() &&
					m_pPlayerPed->GetCurrentWeapon() != m_icSync.byteCurrentWeapon ) {
					m_pPlayerPed->SetArmedWeapon(m_icSync.byteCurrentWeapon);
					if(m_pPlayerPed->GetCurrentWeapon() != m_icSync.byteCurrentWeapon) {
						m_pPlayerPed->GiveWeapon(m_icSync.byteCurrentWeapon,9999);
						m_pPlayerPed->SetArmedWeapon(m_icSync.byteCurrentWeapon);
					}
				}
				m_byteUpdateFromNetwork = UPDATE_TYPE_NONE;
			}

			// ---- PASSENGER NETWORK PROCESSING ----
			else if(GetState() == PLAYER_STATE_PASSENGER && 
				m_byteUpdateFromNetwork == UPDATE_TYPE_PASSENGER)
			{
				if(!m_pCurrentVehicle) return;
				// UPDATE CURRENT WEAPON
				if( m_pPlayerPed->IsAdded() &&
					m_pPlayerPed->GetCurrentWeapon() != m_psSync.byteCurrentWeapon ) {
					m_pPlayerPed->SetArmedWeapon(m_psSync.byteCurrentWeapon);
					if(m_pPlayerPed->GetCurrentWeapon() != m_psSync.byteCurrentWeapon) {
						m_pPlayerPed->GiveWeapon(m_psSync.byteCurrentWeapon,9999);
						m_pPlayerPed->SetArmedWeapon(m_psSync.byteCurrentWeapon);
					}
				}
				// FOR INITIALISING PASSENGER DRIVEBY
				if(!m_bPassengerDriveByMode && m_pPlayerPed->GetActionTrigger() == ACTION_INCAR) {
					if(m_psSync.byteDriveBy) {
						if(m_pPlayerPed->IsAdded()) {
							if(m_pPlayerPed->StartPassengerDriveByMode()) {
								m_bPassengerDriveByMode = TRUE;
							}
						}
					}
				}
				m_byteUpdateFromNetwork = UPDATE_TYPE_NONE;
			}

			// ------ PROCESSED FOR ALL FRAMES ----- 
			if(GetState() == PLAYER_STATE_ONFOOT) {
				m_bPassengerDriveByMode = FALSE;
				ProcessSpecialActions(m_ofSync.byteSpecialAction);
				m_pPlayerPed->SetTargetRotation(m_ofSync.fRotation);
				m_pPlayerPed->SetKeys(m_ofSync.wKeys,m_ofSync.lrAnalog,m_ofSync.udAnalog);
				
				if(IsSurfingOrTurretMode()) {
					UpdateSurfing();
					m_pPlayerPed->SetGravityProcessing(0);
					m_pPlayerPed->SetCollisionChecking(0);
				} else {
					m_pPlayerPed->SetGravityProcessing(1);
					m_pPlayerPed->SetCollisionChecking(1);
				}
			}
			else if(GetState() == PLAYER_STATE_DRIVER) {
				m_bPassengerDriveByMode = FALSE;
				m_pPlayerPed->CheckVehicleParachute();
				
				// REMOVE PLAYER MODEL IN RC VEHICLE
				if(m_pCurrentVehicle && m_pCurrentVehicle->IsRCVehicle()) {
					m_pPlayerPed->Remove();
				}

				if(m_iIsInAModShop)	{
					VECTOR vec = {0.0f,0.0f,0.0f};
					m_pPlayerPed->SetKeys(0,0,0);
					if(m_pCurrentVehicle) m_pCurrentVehicle->SetMoveSpeedVector(vec);
				} else {
					m_pPlayerPed->SetKeys(m_icSync.wKeys,m_icSync.lrAnalog,m_icSync.udAnalog);
				}
			}
			else if(GetState() == PLAYER_STATE_PASSENGER) {
				m_pPlayerPed->CheckVehicleParachute();
				m_pPlayerPed->SetKeys(m_psSync.wKeys,0,0);
			}
			else {
				m_bPassengerDriveByMode = FALSE;
				m_pPlayerPed->SetKeys(0,0,0);
			}

			m_pPlayerPed->SetHealth(100.0f);
			//m_pPlayerPed->SetArmour(100.0f);
		}
	}
	else {
		// NOT ACTIVE
		if(m_pPlayerPed) {
			ResetAllSyncAttributes();
			m_pPlayerPed->Destroy();
			delete m_pPlayerPed;
			m_pPlayerPed = NULL;
		}
	}
}
Exemplo n.º 12
0
void ClientJoin(PCHAR Data, int iBitLength, PlayerID sender)
{
	RakNet::BitStream bsData(Data,iBitLength/8,FALSE);
	CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	CPickupPool *pPickupPool = pNetGame->GetPickupPool();
	CPedPool *pPedPool = pNetGame->GetPedPool();

	CHAR szPlayerName[MAX_PLAYER_NAME];
	BYTE bytePlayerID;
	BYTE byteVersion;
	BYTE byteNickLen;

	bsData.Read(byteVersion);

	if(byteVersion != NETGAME_VERSION) {
		pNetGame->GetNetSends()->ConnectionRejected(sender, REJECT_REASON_BAD_VERSION);
		return;
	}

	bsData.Read(byteNickLen);
	bsData.Read(szPlayerName,byteNickLen);
	szPlayerName[byteNickLen] = '\0';

	FilterInvalidNickChars(szPlayerName);
	byteNickLen = strlen(szPlayerName);

	if(byteNickLen==0 || byteNickLen > 16 || pPlayerPool->IsNickInUse(szPlayerName)) {
		pNetGame->GetNetSends()->ConnectionRejected(sender, REJECT_REASON_BAD_NICKNAME);
		return;
	}

	bytePlayerID = pRak->GetIndexFromPlayerID(sender);
	
	// Add this client to the player pool.
	pPlayerPool->New(bytePlayerID, szPlayerName);

	// Send this client back an 'InitGame' Call
	pNetGame->GetNetSends()->InitGame(sender, pNetGame->m_vecInitPlayerPos, pNetGame->m_vecInitCameraPos, pNetGame->m_vecInitCameraLook, pNetGame->m_WorldBounds, pNetGame->m_iSpawnsAvailable, pNetGame->m_byteFriendlyFire, pNetGame->m_byteShowOnRadar, pNetGame->m_startInterior);

	// Send this client existing players
	pNetGame->GetNetSends()->FirstJoin(sender);

	// Spawn all existing vehicles for player.
	CVehicle *pVehicle;
	BYTE x=0;

	while(x!=MAX_VEHICLES) {
		if(pVehiclePool->GetSlotState(x) == TRUE) {
			pVehicle = pVehiclePool->GetAt(x);
			if(pVehicle->IsActive()) pVehicle->SpawnForPlayer(bytePlayerID);
		}
		x++;
	}

	CPickup *pPickup;
	x=0;

	while(x!=MAX_PICKUPS) {
		if(pPickupPool->GetSlotState(x) == TRUE) {
			pPickup = pPickupPool->GetAt(x);
			if(pPickup->IsActive()) pPickup->SpawnForPlayer(bytePlayerID);
		}
		x++;
	}

	/*CPed *pPed;
	x=0;

	while(x!=MAX_PEDS) {
		if(pPedPool->GetSlotState(x) == TRUE) {
			pPed = pPedPool->GetAt(x);
			if(pPed->IsActive()) pPed->SpawnForPlayer(bytePlayerID);
		}
		x++;
	}*/

	pNetGame->GetGameLogic()->HandleClientJoin(bytePlayerID);
//	lua_getglobal( L, "OnPlayerJoinDataChange" );
//	lua_pushnumber( L, strlen(szPlayerName) );
//	lua_pushstring( L, szPlayerName );
//	lua_pcall( L, 2, 0, 0 );
}