Exemple #1
0
void VehicleExit(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the player id
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Read the vehicle id
	EntityId vehicleId;
	pBitStream->Read(vehicleId);

	// Read the seat
	byte byteSeat;
	pBitStream->Read(byteSeat);

	// Get the player instance
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Is the player instance valid?
	if (pPlayer)
	{
		// Handle this with the player
		RakNet::BitStream bitStream;
		bitStream.Write(playerId);
		bitStream.Write(vehicleId);
		bitStream.Write(byteSeat);
		CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_EXIT_VEHICLE), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, -1, true);
		CScriptArguments args;
		args.push(pPlayer->GetScriptPlayer());
		CEvents::GetInstance()->Call("playerExitVehicle", &args, CEventHandler::eEventType::NATIVE_EVENT, 0);
	}

	CLogFile::Printf("RPC_EXIT_VEHICLE - Player: %d, Vehicle: %d, Seat: %d", playerId, vehicleId, byteSeat);
}
Exemple #2
0
void PlayerRequestSpawn(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	CLogFile::Printf("%s", __FUNCTION__);

	// Get the player id
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Get a pointer to the player
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Is the player pointer valid?
	if (pPlayer)
	{
		if (CEvents::GetInstance()->IsEventRegistered("playerRequestSpawn"))
		{
			CScriptArguments args;
			args.push(pPlayer->GetScriptPlayer());
			CEvents::GetInstance()->Call("playerRequestSpawn", &args, CEventHandler::eEventType::NATIVE_EVENT, 0);
		}
		else
		{
			RakNet::BitStream bitStream;
			bitStream.Write(CVector3(DEFAULT_SPAWN_POSITION)); //spawnPos
			bitStream.Write(0.0f); //fHeading
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_PLAYER_SPAWN), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);
		}
		CLogFile::Printf("[spawn] %s has requestred a spawn.", pPlayer->GetName().Get());
	}
}
Exemple #3
0
void CheckpointExit(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the player id
	EntityId playerId = (EntityId)pPacket->guid.systemIndex;

	// Read the checkpoint id
	EntityId checkpointId;
	pBitStream->Read(checkpointId);

	// Get the player instance
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Get the checkpoint instance
	CCheckpointEntity * pCheckpoint = CServer::GetInstance()->GetCheckpointManager()->GetAt(checkpointId);

	// Is the player instance valid?
	if (pPlayer)
	{
		CScriptArguments args;
		args.push(pPlayer->GetScriptPlayer());
		args.push(pCheckpoint->GetScriptCheckpoint());
		CEvents::GetInstance()->Call("playerExitCheckpoint", &args, CEventHandler::eEventType::NATIVE_EVENT, 0);
	}

	CLogFile::Printf("RPC_EXIT_CHECKPOINT");
}
void CNetworkModule::UpdateNetwork(void)
{
	// Create a packet
	RakNet::Packet * pPacket = NULL;

	// Process RakNet
	while(pPacket = m_pRakPeer->Receive())
	{
		switch(pPacket->data[0])
		{
			case ID_NEW_INCOMING_CONNECTION:
			{
				CLogFile::Printf("[network] Incoming connection from %s.", pPacket->systemAddress.ToString(true, ':'));
				break;
			}

			case ID_DISCONNECTION_NOTIFICATION:
			{
				// Is the player active in the player manager?
				if(CServer::GetInstance()->GetPlayerManager()->Exists((EntityId)pPacket->systemAddress.systemIndex))
				{
					CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt((EntityId)pPacket->systemAddress.systemIndex);
					CLogFile::Printf("[quit] %d has left the server (%s).", pPlayer->GetId(), SharedUtility::DiconnectReasonToString(1).Get());
					
					// Delete the player from the manager
					CServer::GetInstance()->GetPlayerManager()->Delete((EntityId)pPacket->systemAddress.systemIndex);
				}
				break;
			}

			case ID_CONNECTION_LOST:
			{
				// Is the player active in the player manager?
				if(CServer::GetInstance()->GetPlayerManager()->Exists((EntityId)pPacket->systemAddress.systemIndex))
				{
					CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt((EntityId)pPacket->systemAddress.systemIndex);
					CLogFile::Printf("[quit] %d has left the server (%s).", pPlayer->GetId(), SharedUtility::DiconnectReasonToString(0).Get());
					
					// Delete the player from the manager
					CServer::GetInstance()->GetPlayerManager()->Delete((EntityId)pPacket->systemAddress.systemIndex);

				}
				break;
			}
		}

		// Deallocate the memory used by the packet
		m_pRakPeer->DeallocatePacket(pPacket);
	}
}
//
// this is the smarts for the rocket launcher in coop
//
// if there is a player behind/below the carrier, and we can shoot, and we can trace a LOS to them ..
// pick one of the group, and let it rip
void CCarrier::CoopCheck ()
{
	// no more than 4 players in coop, so..
	static std::vector<CPlayerEntity*> targets;
	targets.clear();

	// if we're not in coop, this is a noop
	if (!(Game.GameMode & GAME_COOPERATIVE))
		return;
	// if we are, and we have recently fired, bail
	if (RefireWait > Level.Frame)
		return;

	// cycle through players
	for (int player = 1; player <= Game.MaxClients; player++)
	{
		CPlayerEntity *ent = entity_cast<CPlayerEntity>(Game.Entities[player].Entity);

		if (!ent->GetInUse())
			continue;
		
		if (IsInBack(Entity, ent) || IsBelow(Entity, ent))
		{
			CTrace tr (Entity->State.GetOrigin(), ent->State.GetOrigin(), Entity, CONTENTS_MASK_SOLID);
		
			if (tr.Fraction == 1.0)
				targets.push_back (ent);
		}
	}

	if (targets.empty())
		return;

	int target = irandom(targets.size());

	// make sure to prevent rapid fire rockets
	RefireWait = Level.Frame + CARRIER_ROCKET_TIME;

	// save off the real enemy
	IBaseEntity *OldEnemy = *Entity->Enemy;
	// set the new guy as temporary enemy
	Entity->Enemy = targets[target];
	Rocket ();
	// put the real enemy back
	Entity->Enemy = OldEnemy;

	// we're done
	return;
}
	void Explode ()
	{
		// free the trigger field
		//PMM - changed teammaster to "mover" .. owner of the field is the prox
		if (Field && Field->GetOwner() == this)
			Field->Free ();

		IBaseEntity *Owner = this;
		if (Firer)
		{
			Owner = Firer;
			Firer->PlayerNoiseAt (State.GetOrigin(), PNOISE_IMPACT);
		}

		// play quad sound if appopriate
		if (Damage > PROX_DAMAGE)
			PlaySound (CHAN_ITEM, SoundIndex("items/damage3.wav"));

		CanTakeDamage = false;
		SplashDamage (Owner, Damage, this, PROX_DAMAGE_RADIUS, MOD_PROX);

		if (GroundEntity)
			CGrenadeExplosion (State.GetOrigin().MultiplyAngles (-0.02f, Velocity)).Send();
		else
			CRocketExplosion (State.GetOrigin().MultiplyAngles (-0.02f, Velocity)).Send();

		Free ();
	}
Exemple #7
0
/*
=================
CheckDMRules
=================
*/
void CheckDMRules ()
{
	if (Level.Intermission.Time)
		return;

	if (!(Game.GameMode & GAME_DEATHMATCH))
		return;

#if CLEANCTF_ENABLED
//ZOID
	if ((Game.GameMode & GAME_CTF) && CTFCheckRules())
	{
		EndDMLevel ();
		return;
	}
//ZOID
#endif

	if (CvarList[CV_TIME_LIMIT].Float())
	{
		if (Level.Frame >= ((CvarList[CV_TIME_LIMIT].Float()*60)*10))
		{
			BroadcastPrint (PRINT_HIGH, "Timelimit hit.\n");
			EndDMLevel ();
			return;
		}
	}

	if (CvarList[CV_FRAG_LIMIT].Integer())
	{
		for (uint8 i = 0; i < Game.MaxClients; i++)
		{
			CPlayerEntity *cl = entity_cast<CPlayerEntity>(Game.Entities[i+1].Entity);
			if (!cl->GetInUse())
				continue;

			if (cl->Client.Respawn.Score >= CvarList[CV_FRAG_LIMIT].Integer())
			{
				BroadcastPrint (PRINT_HIGH, "Fraglimit hit.\n");
				EndDMLevel ();
				return;
			}
		}
	}
}
Exemple #8
0
void PlayerChat(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the playerid
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Read if this is a command
	bool bIsCommand = pBitStream->ReadBit();

	// Read the input
	RakNet::RakString strInput;
	pBitStream->Read(strInput);

	// Is the player active?
	if (CServer::GetInstance()->GetPlayerManager()->DoesExists(playerId))
	{
		// Get a pointer to the player
		CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

		// Is the pointer valid?
		if (pPlayer)
		{
			// Is this not a command?
			if (!bIsCommand)
			{
				CLogFile::Printf("[chat] %s: %s", pPlayer->GetName().Get(), strInput.C_String());

				// Send the RPC back to other players
				RakNet::BitStream bitStream;
				bitStream.Write(playerId);
				bitStream.Write(strInput);
				CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_PLAYER_CHAT), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, -1, true);
			}
			else
			{
				CLogFile::Printf("[command] %s: %s", pPlayer->GetName().Get(), strInput.C_String());

				CScriptArguments args;
				args.push(strInput);
				args.push(pPlayer->GetScriptPlayer());
				CEvents::GetInstance()->Call("playerCommand", &args, CEventHandler::eEventType::NATIVE_EVENT, nullptr);
			}
		}
	}
}
Exemple #9
0
void PetStash::SetEffectModelNo( int nEffectNo )
{
	m_nEffectModelNo = nEffectNo; 

	if (m_nEffectModelNo < 0)
	{
		_pNetwork->MyCharacterInfo.itemEffect.DeletePetStashEffect();
		return;
	}

	CEntity			*penPlEntity;
	CPlayerEntity	*penPlayerEntity;
	penPlEntity = CEntity::GetPlayerEntity(0);		// 캐릭터 자기 자신
	penPlayerEntity = static_cast<CPlayerEntity *>(penPlEntity);
	CModelInstance *pMI			= NULL;
	pMI	= penPlayerEntity->GetModelInstance();
	
	_pNetwork->MyCharacterInfo.itemEffect.AddPetStashEffect( m_nEffectModelNo, &pMI->m_tmSkaTagManager);
}
void CUIPetStashSelectEffect::_PlaySound(eSoundType type)
{
	CEntity			*penPlEntity;
	CPlayerEntity	*penPlayerEntity;

	penPlEntity = CEntity::GetPlayerEntity( 0 );
	penPlayerEntity = (CPlayerEntity *)penPlEntity;

	switch(type)
	{
	case SOUND_TYPE_MOVE:
		penPlayerEntity->PlayPetStashEffectSound();
		break;

	case SOUND_TYPE_SELECT:
		penPlayerEntity->PlayPetStashCardSelSound();
		break;
	}
	
}
	void SaveFields (CFile &File)
	{
		IBounceProjectile::SaveFields (File);
		ITouchableEntity::SaveFields (File);
		IHurtableEntity::SaveFields (File);
		IThinkableEntity::SaveFields (File);

		File.Write<EProxThinkType> (ThinkType);
		File.Write<sint32> ((Field != NULL && Field->GetInUse()) ? Field->State.GetNumber() : -1);
		File.Write<sint32> ((Firer != NULL && Firer->GetInUse()) ? Firer->State.GetNumber() : -1);
		File.Write<int> (Damage);
		File.Write<FrameNumber> (Wait);
	};
Exemple #12
0
void PlayerSpawn(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the player id
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Get a pointer to the player
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Is the player pointer valid?
	if (pPlayer)
	{
		// Spawn the player
		//pPlayer->SpawnForWorld();

		// Spawn everyone else connected for this player
		//CServer::GetInstance()->GetPlayerManager()->HandlePlayerSpawn(playerId);
		CScriptArguments args;
		args.push(pPlayer->GetScriptPlayer());
		CEvents::GetInstance()->Call("onSpawn", &args, CEventHandler::eEventType::GLOBAL_EVENT, 0);
		CLogFile::Printf("[spawn] %s has spawned.", pPlayer->GetName().Get());
	}
	CLogFile::Printf("%s", __FUNCTION__);
}
Exemple #13
0
void PlayerDeath(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	CLogFile::Printf("%s", __FUNCTION__);

	// Get the player id
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Read the killer id
	EntityId killerId;
	pBitStream->Read(killerId);

	// Get a pointer to the player
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Is the player pointer valid?
	if (pPlayer)
	{
		// Kill the player
		//pPlayer->KillForWorld();

		// Is the killer a player?
		if (killerId != INVALID_ENTITY_ID)
		{
			// Find the killer
			CPlayerEntity* pKiller = CServer::GetInstance()->GetPlayerManager()->GetAt(killerId);

			// Is the killer valid?
			if (pKiller)
				CLogFile::Printf("[death] %s has been killed by %s!", pPlayer->GetName().Get(), pKiller->GetName().Get());
			else
				CLogFile::Printf("[death] %s has been killed!", pPlayer->GetName().Get());
		}
		else
		{
			CLogFile::Printf("[death] %s has died!", pPlayer->GetName().Get());
		}

		CScriptArguments args;
		args.push(pPlayer->GetScriptPlayer());
		CEvents::GetInstance()->Call("playerDeath", &args, CEventHandler::eEventType::NATIVE_EVENT, 0);
	}
}
Exemple #14
0
void PlayerDeath(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the player id
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Read the killer id
	EntityId killerId;
	pBitStream->ReadCompressed(killerId);

	// Get a pointer to the player
	CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);

	// Is the player pointer valid?
	if (pPlayer)
	{
		// Kill the player
		//pPlayer->KillForWorld();

		// Is the killer a player?
		if (killerId != INVALID_ENTITY_ID)
		{
			// Find the killer
			CPlayerEntity* pKiller = CServer::GetInstance()->GetPlayerManager()->GetAt(killerId);

			// Is the killer valid?
			if (pKiller)
				CLogFile::Printf("[death] %s has been killed by %d!", pPlayer->GetName().Get(), pKiller->GetId());
			else
				CLogFile::Printf("[death] %s has been killed by NOT_A_PLAYER!", pPlayer->GetName().Get());
		}
		else
		{
			CLogFile::Printf("[death] %s has died!", pPlayer->GetName().Get());
		}
	}
	CLogFile::Printf("%s", __FUNCTION__);
}
Exemple #15
0
void CStageGamePlay::Release()
{
    CUIManager* pUIManager = CUIManager::getSingleton();

    CEntity* penPlEntity;
    CPlayerEntity* penPlayerEntity;
    penPlEntity = CEntity::GetPlayerEntity(0); //캐릭터 자기 자신
    penPlayerEntity = (CPlayerEntity*) penPlEntity;

#ifndef	VER_TEST
    _pNetwork->m_ubGMLevel = 0;
#endif	// VER_TEST

    // [090826: selo] 시스템 메시지 저장 끝내기
    pUIManager->GetChattingUI()->SaveSysMessageComplete(1);

    // Date : 2006-04-26(오전 11:48:00), By eons
    if( penPlayerEntity->IsPolymophing() )	// 변신 중이라면
    {
        penPlayerEntity->ReturnChange( TRUE );
        const int iStopChangeItem = 521;

        Notice* pNotice = GAMEDATAMGR()->GetNotice();

        if (pNotice != NULL)
            pNotice->DelFromNoticeList(iStopChangeItem, Notice::NOTICE_POLYMOPH);
    }

    // 소환수 리셋
    pUIManager->GetSummonFirst()->ResetSummon();
    pUIManager->GetSummonSecond()->ResetSummon();

    // 개인상점 초기화
    pUIManager->GetPersonalShop()->ResetShop();
    pUIManager->SetCSFlagOff( CSF_PERSONALSHOP );

    // 문스톤 초기화
    pUIManager->SetCSFlagOff( CSF_MOONSTONE );

    // 마운트 초기화
    pUIManager->SetCSFlagOff( CSF_MOUNT_HUNGRY );

    // 길드 리셋
    CUIGuild* pGuild = pUIManager->GetGuild();

    if (pGuild != NULL)
    {
        pGuild->ResetGuild();
        pGuild->ClearMemberList();
        pGuild->ClearGuildSkill();
    }

    // 파티정보 초기화
    GAMEDATAMGR()->GetPartyInfo()->Init();
    // 원정대 초기화
    GAMEDATAMGR()->GetPartyInfo()->InitExpedition();
    pUIManager->GetExpedition()->closeUI();

    ObjInfo* pInfo = ObjInfo::getSingleton();

    // 펫 정보 초기화
    _pNetwork->LeavePet( (CPlayerEntity*)penPlEntity );
    pInfo->GetMyPetInfo()->Init();
    // FIXED : wild pet mount bug [12/12/2010 rumist]
    // 초기화 실패로 매시가 깨지는 것 방지.
    static_cast<CPlayerEntity*>(penPlEntity)->LeavingWildPet( static_cast<CPlayerEntity*>(penPlEntity) );
    pInfo->SetMyApet(NULL);
    // royal rumble init [5/11/2011 rumist]
    pUIManager->GetRadar()->ResetRoyalRumbleStat();
    pUIManager->GetRoyalRumbleIcon()->ShowRoyalRumbleIcon( FALSE );
    // ITS#3867 : 채집 중 이동시 애니메이션 리셋. [2/13/2012 rumist]
    static_cast<CPlayerEntity*>(penPlEntity)->CancelProduct();

    pInfo->GetMySlaveInfo(0)->Init();
    pInfo->GetMySlaveInfo(1)->Init();

    GAMEDATAMGR()->GetGPS()->RelicPosClear();

    // 도움말 리셋
    pUIManager->GetHelper()->ResetHelper();
    pUIManager->GetHelper()->ClearHelperList();

    // NPC 스크롤 리셋
    pUIManager->GetNpcScroll()->CloseNpcScroll();

    penPlayerEntity->ClearMultiTargets();

    _pNetwork->DeleteAllMob();
    _pNetwork->MyCharacterInfo.EntranceType = CURRENT_ENTER_NORMAL; // 초기화

    GameDataManager* pGameData = GameDataManager::getSingleton();

    if (pGameData)
    {
        PetStash* pPetStash = pGameData->GetStashData();

        if (pPetStash)
        {
            pPetStash->SetEffectModelNo(-1);
        }
    }

    int i;
    // Reset inventory
    for( i = 0; i < WEAR_TOTAL; ++i )
    {
        _pNetwork->MyWearItem[i].Init();
        pUIManager->GetInventory()->InitWearBtn(-1, -1, i);
    }
    // Reset Costume Wearing Info

    for( i = 0; i < WEAR_COSTUME_TOTAL; ++i)
    {
        _pNetwork->MyWearCostItem[i].Init();
        pUIManager->GetInventory()->InitCostumeInventory(-1, -1, i);
    }

    _pNetwork->MyCharacterInfo.bOneSuit = FALSE;
    _pNetwork->MyCharacterInfo.iOneSuitDBIndex	= -1;
    _pNetwork->MyCharacterInfo.iOneSuitUniIndex	= -1;

    int		t, each;
    for (t = 0; t <= INVENTORY_TAB_CASH_2; ++t)
    {
        if (t == INVENTORY_TAB_NORMAL)			each = ITEM_COUNT_IN_INVENTORY_NORMAL;
        else if ( t == INVENTORY_TAB_CASH_1 )	each = ITEM_COUNT_IN_INVENTORY_CASH_1;
        else each = ITEM_COUNT_IN_INVENTORY_CASH_2;

        for (i = 0 ; i < each; ++i)
        {
            _pNetwork->MySlotItem[t][i].Init();
            pUIManager->GetInventory()->InitInventory( t, i, -1, -1, -1 );
        }

        if( t >= INVENTORY_TAB_CASH_1 && INVENTORY_TAB_CASH_2 <= t )
            pUIManager->GetInventory()->CashInvenLockOn();
    }

    // 지역을 이동할 때 갖고 있던 GMNotice 를 지우자!
    _UIAutoHelp->ClearGMNNotice();
    pUIManager->ResetHoldBtn();

    MY_INFO()->ClearPetSkill();
    MY_INFO()->clear();

    pUIManager->GetMap()->ClearPlayerEntity();

    CPremiumChar* pChar = GAMEDATAMGR()->GetPremiumChar();

    if (pChar != NULL)
        pChar->Clear();

    pUIManager->GetPremiumChar()->CloseUI();
    pUIManager->GetItemCollection()->CloseUI();

    pUIManager->GetNewsUI()->CloseUI();
    pUIManager->GetNewsWebUI()->CloseUI();

    MSGBOXMGR()->DeleteAll();
}
bool CClientCommands::HandleUserInput(std::string strCommand, std::string strParameters)
{
	if(strCommand == "q"  || strCommand == "quit")
	{
		// Are we connected to the network?
		if(g_pCore->GetNetworkManager()->IsConnected())
		{
			// Disconnect and shutdown RakNet
			g_pCore->GetNetworkManager()->Shutdown(500, true);
		}
		
		TerminateProcess(GetCurrentProcess(), 0);
		return true;
	}
	else if(strCommand == "qq" || strCommand == "quickquit")
	{
		TerminateProcess(GetCurrentProcess(), 0);
		return true;
	}

	else if(strCommand == "cv")
	{
		int iVehicleType = atoi(strParameters.c_str());

		CVector3 vecCreatePos; 
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos);
		vecCreatePos.fX += 4;
		vecCreatePos.fY += 1;

		CVehicleEntity * pVehicle = new CVehicleEntity(iVehicleType,vecCreatePos,0.0f,0,0,0,0);
		if(pVehicle)
		{
			// Add our vehicle
			g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle);

			pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot());

			pVehicle->Create();

			pVehicle->SetPosition(vecCreatePos);
		}
		return true;
	}
	else if(strCommand == "respawn")
	{
		g_pCore->GetGame()->GetLocalPlayer()->Respawn();
		return true;
	}
	else if(strCommand == "debug")
	{
		g_pCore->GetDevelopmentInstance()->CreateDebugPlayer();
		return true;
	}
	else if(strCommand == "weapon")
	{
		if(g_pCore->GetDevelopmentInstance()->GetDebugPlayerPed())
			CIVScript::GiveWeaponToChar(g_pCore->GetDevelopmentInstance()->GetDebugPlayerPed()->GetScriptingHandle(),(CIVScript::eWeapon)CIVScript::WEAPON_SHOTGUN,50,true);
		
		CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),(CIVScript::eWeapon)CIVScript::WEAPON_SHOTGUN,50,true);
		return true;
	}
	else if(strCommand == "cp")
	{
		CVector3 vecCreatePos; 
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos);

		CPlayerEntity * pPlayer = new CPlayerEntity(false);
		if(pPlayer)
		{
			pPlayer->SetModel(7);
			pPlayer->Create();
			pPlayer->Teleport(vecCreatePos);
		}
		return true;
	}
	else if(strCommand == "spawn")
	{
		g_pCore->GetChat()->Output("Spawning local player ...",false);
		g_pCore->GetGame()->OnClientReadyToGamePlay();
		g_pCore->GetGame()->GetLocalPlayer()->SetModel(7);

		int iVehicleType = g_pCore->GetGame()->IsUsingEFLCContent() ? 128 : 91;

		CVector3 vecCreatePos; 
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos);
		vecCreatePos.fX += 4;
		vecCreatePos.fY += 1;

		CVehicleEntity * pVehicle = new CVehicleEntity(iVehicleType,vecCreatePos,0.0f,0,0,0,0);
		if(pVehicle)
		{
			// Add our vehicle
			g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle);

			pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot());

			pVehicle->Create();

			pVehicle->SetPosition(vecCreatePos);
		}

		PTR_CHAT->Output("Type \"/ready\" and seconds later \"/parachute\" to create a parachute!",false);
		return true;
	}
	else if(strCommand == "engine") 
	{
		if(g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity() != NULL)
			g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->SetEngineState(!g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->GetEngineState());
		
		return true;
	}
	else if(strCommand == "saveposition" || strCommand == "save")
	{
		FILE * file = fopen(SharedUtility::GetAbsolutePath("multiplayer//SavePositions.log"), "a");
		if(!file)
		{
			g_pCore->GetChat()->Output("Failed to open 'SavedData.log'");
			return true;
		}

		CVector3 vecPosition;

		// Get our local player
		CLocalPlayer * pLocalPlayer = g_pCore->GetGame()->GetLocalPlayer();

		if(pLocalPlayer->IsInVehicle())
		{
			CVehicleEntity * pVehicle = pLocalPlayer->GetVehicleEntity();

			if(pVehicle)
			{
				pVehicle->GetPosition(vecPosition);
				CVector3 vecRotation;
				pVehicle->GetRotation(vecRotation);
				BYTE byteColors[4];
				pVehicle->GetColors(byteColors[0], byteColors[1], byteColors[2], byteColors[3]);
				fprintf_s(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d);%s%s\n", CIVModelManager::ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, byteColors[0], byteColors[1], byteColors[2], byteColors[3], strParameters.size() > 0 ? " // " : "", strParameters.size() > 0 ? strParameters.c_str() : "");
			}
		}
		else
		{
			pLocalPlayer->GetPosition(vecPosition);
			int iModelId = pLocalPlayer->GetPlayerPed()->GetModelIndex();
			fprintf_s(file, "PlayerData(%d, %f, %f, %f, %f);%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetRotation() ,strParameters.size() > 0 ? " // " : "", strParameters.size() > 0 ? strParameters.c_str() : "");
		}

		fclose(file);
		g_pCore->GetChat()->Output("Position data saved to 'SavePositions.log'");
		return true;
	}
	else if(strCommand == "giveweapon")
	{
		int iWeapon = atoi(strParameters.c_str());
		CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),(CIVScript::eWeapon)iWeapon, 100, true);
		return true;
	}
	else if(strCommand == "xaxis")
	{
		CVector3 vecPositon;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon);

		vecPositon.fX += atoi(strParameters.c_str());
		g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon);
		return true;
	}
	else if(strCommand == "time")
	{
		CIVWeather::SetTime(atoi(strParameters.c_str()),0);
		return true;
	}
	else if(strCommand == "setmodel")
	{
		g_pCore->GetGame()->GetLocalPlayer()->SetModel(atoi(strParameters.c_str()));
		return true;
	}
	else if(strCommand == "testweapon")
	{
		CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),CIVScript::WEAPON_EPISODIC_11,99,false);
		return true;
	}
	else if(strCommand == "ready")
	{
		PTR_CHAT->Output("Installing prachute...");
		CEFLCSupport::InstallPreGameLoad();
		return true;
	}
	else if(strCommand == "parachute")
	{
		PTR_CHAT->Output("Adding prachute...");

		CVector3 vecPosition;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition);
		unsigned int uiPlayerIndex = g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle();

		DWORD dwParachute = 0x58D6A0A0;
		
		//CIVScript::GiveWeaponToChar(uiPlayerIndex, 41, 1, false);
		//CIVScript::CreateObject(dwParachute, vecPosition.fX, vecPosition.fY, vecPosition.fZ + 2, &pObj, 1);
		//CIVScript::AttachObjectToPed(pObj, uiPlayerIndex, 0, 0.02500000, -0.12500000, 5.45000000, 0.00000000, 0.00000000, 0.00000000, 1);

		if(pObj != NULL)
			CIVScript::DeleteObject(&pObj);

		dwParachute = 0x4C19FE43; //0x402B7648;
		CIVScript::CreateObject(dwParachute, vecPosition.fX, vecPosition.fY, -25.0 , &pObj, 1);
		l_U40 = pObj;

		CIVScript::SetObjectDynamic(pObj, 0);
		CIVScript::SetObjectCollision(pObj, 0);
		CIVScript::SetObjectVisible(pObj, 0);
		CIVScript::SetActivateObjectPhysicsAsSoonAsItIsUnfrozen(pObj, 1);

		CIVScript::SetObjectDynamic( pObj, 1 );
        CIVScript::SetObjectCollision( pObj, 1 );
        CIVScript::SetObjectVisible( pObj, 1 );
		CIVScript::AttachObjectToPed( pObj, uiPlayerIndex, 1202, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1 );
		CIVScript::PlayObjectAnim( pObj, "obj_chute_off", "PARACHUTE", 1000.00000000, 0, 1 );
		CIVScript::TaskPlayAnimWithFlags( uiPlayerIndex, "chute_off", "PARACHUTE", 3.00000000, 0, 1280 );
		return true;
	}
	else if(strCommand == "bahama")
	{
		CVector3 vecPos = CVector3(-15.9453f, -13.5865f, -11.7456f);
		g_pCore->GetGame()->GetLocalPlayer()->CPlayerEntity::Teleport(vecPos);
		return true;
	}
	else if(strCommand == "spawnvehicles")
	{
		CVector3 vecPos;
		PTR_LOCALPLAYER->GetPosition(vecPos);

		for(int i = 0; i < 179; i++) {
			vecPos.fX += 5;
			CVehicleEntity * pVehicle = new CVehicleEntity(i,vecPos,0.0f,0,0,0,0);
			if(pVehicle)
			{
				// Add our vehicle
				g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle);

				pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot());

				pVehicle->Create();

				pVehicle->SetPosition(vecPos);
			}
		}
		return true;
	}
	else if(strCommand == "getvehpos")
	{
		int iVehicle = atoi(strParameters.c_str());

		if(g_pCore->GetGame()->GetVehicleManager()->DoesExists(iVehicle)) {
			CVector3 vecPosition;
			g_pCore->GetGame()->GetVehicleManager()->GetAt(iVehicle)->GetPosition(vecPosition);
			PTR_CHAT->Outputf(false,"Position of vehicle %d: %f, %f,%f",iVehicle, vecPosition.fX, vecPosition.fY, vecPosition.fZ);
		}
	}
	else if(strCommand == "ivhelp")
	{
		PTR_CHAT->Output(false, "List of Default IV:MP Commands...");
		PTR_CHAT->Output(false, "** /cv /respawn /debug /weapon /cp /spawn /engine /save /giveweapon /xaxis /time");
		PTR_CHAT->Output(false, "** /setmodel /testweapon /ready /parachute /bahama /spawnvehicles /getvehpos");
		return true;
	}	
}
Exemple #17
0
bool CClientCommands::HandleUserInput(CString strCommand, CString strParameters)
{
	if(strCommand == "q"  || strCommand == "quit")
	{
		// Are we connected to the network?
		if(g_pCore->GetNetworkManager()->IsConnected())
		{
			// Disconnect and shutdown RakNet
			g_pCore->GetNetworkManager()->Shutdown(500, true);
		}
		
		TerminateProcess(GetCurrentProcess(), 0);
		return true;
	}
	else if(strCommand == "qq" || strCommand == "quickquit")
	{
		TerminateProcess(GetCurrentProcess(), 0);
		return true;
	}
	else if (strCommand == "saveposition" || strCommand == "save")
	{
		FILE * file = fopen(SharedUtility::GetAbsolutePath("multiplayer//SavePositions.log"), "a");
		if (!file)
		{
			g_pCore->GetChat()->Print("Failed to open 'SavePositions.log'");
			return true;
		}

		CVector3 vecPosition;

		// Get our local player
		CLocalPlayer * pLocalPlayer = g_pCore->GetGame()->GetLocalPlayer();

		if (pLocalPlayer->IsInVehicle())
		{
			CVehicleEntity * pVehicle = pLocalPlayer->GetVehicleEntity();

			if (pVehicle)
			{
				pVehicle->GetPosition(vecPosition);
				CVector3 vecRotation;
				pVehicle->GetRotation(vecRotation);
				DWORD dwColors[5];
				pVehicle->GetColors(dwColors[0], dwColors[1], dwColors[2], dwColors[3], dwColors[4]);
				fprintf_s(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d, %d);%s%s\n", CIVModelManager::ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, dwColors[0], dwColors[1], dwColors[2], dwColors[3], dwColors[4], strParameters.GetLength() > 0 ? " // " : "", strParameters.GetLength() > 0 ? strParameters.Get() : "");
			}
		}
		else
		{
			pLocalPlayer->GetPosition(vecPosition);
			int iModelId = pLocalPlayer->GetPlayerPed()->GetModelIndex();
			fprintf_s(file, "PlayerData(%d, %f, %f, %f, %f);%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetHeading(), strParameters.GetLength() > 0 ? " // " : "", strParameters.GetLength() > 0 ? strParameters.Get() : "");
		}

		fclose(file);
		g_pCore->GetChat()->Print("Position data saved to 'SavePositions.log'");
		return true;
	}
#ifdef _DEBUG
	else if(strCommand == "cv")
	{
		CVector3 vecCreatePos; 
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos);
		vecCreatePos.fX += 4;

		CVehicleEntity * pVehicle = new CVehicleEntity(atoi(strParameters.Get()), vecCreatePos, 0.0f, 0x000000, 0x000000, 0x000000, 0x000000, 0xFFFFFF);
		if(pVehicle) {
			// Add our vehicle
			pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle));
			pVehicle->Create();
			g_pCore->GetGame()->GetLocalPlayer()->WarpIntoVehicle(pVehicle);
		}
		return true;
	}
	else if(strCommand == "respawn")
	{
		g_pCore->GetGame()->GetLocalPlayer()->Respawn();
		return true;
	}
	else if(strCommand == "cp")
	{
		CVector3 vecCreatePos; 
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos);

		CPlayerEntity * pPlayer = new CPlayerEntity(false);
		if(pPlayer) {
			pPlayer->SetModel(7);
			pPlayer->Create();
			pPlayer->Teleport(vecCreatePos);
		}
		return true;
	}
	else if(strCommand == "engine") 
	{
		if(g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity() != NULL)
			g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->SetEngineState(!g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->GetEngineState());
		
		return true;
	}
	else if(strCommand == "giveweapon")
	{
		CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(), (CIVScript::eWeapon)atoi(strParameters.Get()), 100, true);
		return true;
	}
	else if(strCommand == "xaxis")
	{
		CVector3 vecPositon;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon);

		vecPositon.fX += atoi(strParameters.Get());
		g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon);
		return true;
	}
	else if(strCommand == "yaxis")
	{
		CVector3 vecPositon;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon);

		vecPositon.fY += atoi(strParameters.Get());
		g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon);
		return true;
	}
	else if(strCommand == "zaxis")
	{
		CVector3 vecPositon;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon);

		vecPositon.fZ += atoi(strParameters.Get());
		g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon);
		return true;
	}
	else if(strCommand == "port")
	{
		CVector3 vecPositon;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon);
		vecPositon.fX = 900;
		vecPositon.fY = -71;
		vecPositon.fZ += 20;
		g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon);
		return true;
	}
	else if(strCommand == "time")
	{
		g_pCore->GetTimeManagementInstance()->SetTime(atoi(strParameters.Get()), 0);
		CGameFunction::SetTimeOfDay(atoi(strParameters.Get()), 0);
		return true;
	}
	else if(strCommand == "setmodel")
	{
		g_pCore->GetGame()->GetLocalPlayer()->SetModel(atoi(strParameters.Get()));
		return true;
	}
	else if(strCommand == "setclothes")
	{
		CString strParameter = CString("%s", strParameters.Get());
		g_pCore->GetChat()->Print(strParameter.Get());

		// Get the end of the command
		size_t sCommandEnd = strParameter.Find(" "); 

		// If we don't have a valid end use the end of the string
		if (sCommandEnd == std::string::npos)
		{
			sCommandEnd = strParameter.GetLength();
		}

		// Get the command name
		std::string strCommand2 = strParameter.Substring(0, (sCommandEnd));

		// Get the command parameters
		std::string strParams;

		// Do we have any parameters?
		if(sCommandEnd < strParameter.GetLength())
		{
			strParams = strParameter.Substring((sCommandEnd + 1), strParameter.GetLength());
		}

		g_pCore->GetChat()->Print(CString("Setting clothes part %d to %d", atoi(strCommand2.c_str()), atoi(strParams.c_str())));
		g_pCore->GetGame()->GetLocalPlayer()->SetPedClothes(atoi(strCommand2.c_str()), atoi(strParams.c_str()));

		return true;
	}
	else if(strCommand == "bahama")
	{
		g_pCore->GetGame()->GetLocalPlayer()->CPlayerEntity::SetPosition(CVector3(-15.9453f, -13.5865f, -11.7456f));
		return true;
	}
	else if(strCommand == "spawnvehs")
	{
		CVector3 vecPos;
		PTR_LOCALPLAYER->GetPosition(vecPos);

		for (int i = 0; i < 179; i++)
		{
			vecPos.fX += 5;
			CVehicleEntity * pVehicle = new CVehicleEntity(i, vecPos, 0.0f, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF);
			if(pVehicle)
			{
				// Add our vehicle
				g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle);
				pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot());
				pVehicle->Create();
				pVehicle->SetPosition(vecPos, true);
			}
		}
		return true;
	}
	else if(strCommand == "getvehpos")
	{
		int iVehicle = atoi(strParameters.Get());

		if(g_pCore->GetGame()->GetVehicleManager()->DoesExists(iVehicle)) {
			CVector3 vecPosition;
			g_pCore->GetGame()->GetVehicleManager()->GetAt(iVehicle)->GetPosition(vecPosition);
			PTR_CHAT->Print(CString("Position of vehicle %d: %f, %f,%f", iVehicle, vecPosition.fX, vecPosition.fY, vecPosition.fZ));
		}
		return true;
	}
	else if(strCommand == "ivhelp")
	{
		PTR_CHAT->Print("List of Default IV:N Commands...");
		PTR_CHAT->Print("** /cv /respawn /debug /weapon /cp /spawn /engine /save /giveweapon /xaxis /time");
		PTR_CHAT->Print("** /setmodel /testweapon /ready /parachute /bahama /spawnvehicles /getvehpos");
		return true;
	}
	else if(strCommand == "createtrain")
	{
		g_pCore->GetGame()->GetIVManagement()->CreateTrain(g_pCore->GetGame()->GetLocalPlayer()->GetPosition(), 3, 20.0f, 0);
		return true;
	}
	else if(strCommand == "blip")
	{
		unsigned int uiBlip;
		CIVScript_NativeInvoke::Invoke<unsigned int>(CIVScript::NATIVE_ADD_BLIP_FOR_COORD, 0, 0, 0,&uiBlip); 
		CIVScript_NativeInvoke::Invoke<unsigned int>(CIVScript::NATIVE_CHANGE_BLIP_SPRITE, 10);
		return true;
	}
	else if(strCommand == "sethealth")
	{
		g_pCore->GetGame()->GetLocalPlayer()->SetHealth(atoi(strParameters.Get()));
		return true;
	}
	else if (strCommand == "setarmour")
	{
		g_pCore->GetGame()->GetLocalPlayer()->SetArmour(atoi(strParameters.Get()));
		return true;
	}
#endif
#ifdef SYNC_TEST
	else if (strCommand == "syncTest")
	{
		// Add the player
		CPlayerEntity * pPlayer = new CPlayerEntity;
		pPlayer->SetModel(0); // Set temporary to nico lol
		pPlayer->Create();
		pPlayer->SetNick("Keks");
		pPlayer->SetId(1);
		pPlayer->SetColor(0xFFFFFFFF);
		g_pCore->GetGame()->GetPlayerManager()->Add(1, pPlayer);

		CVector3 vecPosition;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition);
		vecPosition.fX += 2.0f;
		pPlayer->SetPosition(vecPosition);
	}
	else if (strCommand == "getP")
	{
		CVector3 vecPosition;
		g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition);
		vecPosition.fX += 2.0f;
		g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->SetPosition(vecPosition);
	}
	else if (strCommand = "vehicleSync")
	{
		g_pCore->GetGame()->GetLocalPlayer()->PutInVehicle(g_pCore->GetGame()->GetVehicleManager()->GetAt(0), 0);
		CVector3 vecPosition;
		g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->GetPosition(vecPosition);
		CVehicleEntity * pVehicle = new CVehicleEntity(90, vecPosition, 90, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
		if (pVehicle)
		{
			//	// Add our vehicle
			g_pCore->GetGame()->GetVehicleManager()->Add(1, pVehicle);
			pVehicle->SetId(1);
			pVehicle->Create();
			pVehicle->SetPosition(vecPosition, true);
		}
		//g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->PutInVehicle(g_pCore->GetGame()->GetVehicleManager()->GetAt(0), 0);

		//CVehicleEntity * pVehicle = new CVehicleEntity(90, vecPosition, 90, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
		//if (pVehicle)
		//{
		//	//	// Add our vehicle
		//	g_pCore->GetGame()->GetVehicleManager()->Add(vehicleId, pVehicle);
		//	pVehicle->SetId(vehicleId);
		//	pVehicle->Create();
		//	pVehicle->SetPosition(vecPosition, true);
		//}
	}
#endif
	return false;
}
Exemple #18
0
void InitialData(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
	// Get the playerid
	EntityId playerId = (EntityId) pPacket->guid.systemIndex;

	// Read the player version
	DWORD dwVersion;
	pBitStream->Read(dwVersion);

	// Read the player name
	RakNet::RakString _strName;
	pBitStream->Read(_strName);
	CString strName(_strName.C_String());



	// Read the player serial
	RakNet::RakString _strSerial;
	pBitStream->Read(_strSerial);
	CString strSerial(_strSerial.C_String());

	// Is the network version invalid?
	if (dwVersion != (DWORD)/*NETWORK_VERSION*/0x0)
	{
		// TODO
	}

	

	// Is the nickname already in use?
	// TODO: check is nick in use

	// Is the player banned?
	// TODO: check is banned

	// Add the player to the manager
	// TODO: add to player manager
	CPlayerEntity * pPlayer = new CPlayerEntity();

	pPlayer->SetName(strName);

	// Do we need the id; maybe internal for easier sync but definetly not public to the scripting engine
	pPlayer->SetId(CServer::GetInstance()->GetPlayerManager()->Add(pPlayer));
	playerId = pPlayer->GetId();

	CLogFile::Printf("[join] %s (%i) has connected to the server. (%s)", strName.Get(), playerId, strSerial.Get());

	CScriptArguments args;
	CScriptPlayer * pScriptPlayer = new CScriptPlayer();
	pScriptPlayer->SetEntity(pPlayer);
	pPlayer->SetScriptPlayer(pScriptPlayer);
	args.push(pScriptPlayer);
	CEvents::GetInstance()->Call("playerJoin", &args, CEventHandler::eEventType::GLOBAL_EVENT, 0);

	// Construct a new bitstream
	RakNet::BitStream bitStream;

	// Write the player id
	bitStream.WriteCompressed(playerId);

	// Write the player colour
	bitStream.Write(0xFFFFFF/*CServer::GetInstance()->GetPlayerManager()->GetAt(playerId)->GetColor()*/);

	// Write the server name
	bitStream.Write(RakNet::RakString("IV:Network DEV Server"));

	// Write the max player count
	bitStream.Write(CVAR_GET_INTEGER("maxplayers"));

	// Write the port
	bitStream.Write(CVAR_GET_INTEGER("port"));

	// Send it back to the player
	CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_INITIAL_DATA), &bitStream, HIGH_PRIORITY, RELIABLE, playerId, false);

	CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_START_GAME), &bitStream, HIGH_PRIORITY, RELIABLE, playerId, false);

	for (EntityId i = 0; i < CServer::GetInstance()->GetPlayerManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetPlayerManager()->DoesExists(i) && i != playerId)
		{
			bitStream.Reset();
			bitStream.WriteCompressed(i);
			bitStream.Write(CServer::GetInstance()->GetPlayerManager()->GetAt(i)->GetName().Get());
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_NEW_PLAYER), &bitStream, HIGH_PRIORITY, RELIABLE, playerId, false);

		}
	}

	for (EntityId i = 0; i < CServer::GetInstance()->GetPlayerManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetPlayerManager()->DoesExists(i) && i != playerId)
		{
			bitStream.Reset();
			bitStream.WriteCompressed(playerId);
			bitStream.Write(strName.Get());
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_NEW_PLAYER), &bitStream, HIGH_PRIORITY, RELIABLE, i, false);
		}
	}


	for (EntityId i = 0; i < CServer::GetInstance()->GetVehicleManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetVehicleManager()->DoesExists(i))
		{
			bitStream.Reset();
			CVehicleEntity * pVehicle = CServer::GetInstance()->GetVehicleManager()->GetAt(i);
			bitStream.Write(pVehicle->GetId());
			bitStream.Write(/*pVehicle->GetModelId()*/90);

			CVector3 vecPosition;
			pVehicle->GetPosition(vecPosition);
			bitStream.Write(vecPosition);
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_CREATE_VEHICLE), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, -1, true);
		}
	}

	bitStream.Reset();

	bitStream.WriteCompressed(playerId);
	bitStream.Write(7);
	bitStream.Write(3);
	bitStream.Write(3);
	bitStream.Write(1);
}
Exemple #19
0
void DownloadFinished(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{

	// Read the player name
	RakNet::RakString _strName;
	pBitStream->Read(_strName);
	CString strName(_strName.C_String());

	// Read the player serial
	RakNet::RakString _strSerial;
	pBitStream->Read(_strSerial);
	CString strSerial(_strSerial.C_String());

	// Is the nickname already in use?
	// TODO: check is nick in use

	// Is the player banned?
	// TODO: check is banned

	// Add the player to the manager
	// TODO: add to player manager
	CPlayerEntity * pPlayer = new CPlayerEntity();

	pPlayer->SetName(strName);

	// Do we need the id; maybe internal for easier sync but definetly not public to the scripting engine
	pPlayer->SetId(CServer::GetInstance()->GetPlayerManager()->Add(pPlayer));
	EntityId playerId = pPlayer->GetId();
	srand(time(NULL));
	pPlayer->SetColor(CColor(rand() % 256, rand() % 256, rand() % 256).dwHexColor); //generate random color

	CLogFile::Printf("[join] %s (%i) has connected to the server. (%s)", strName.Get(), playerId, strSerial.Get());

	CScriptArguments args;
	CScriptPlayer * pScriptPlayer = new CScriptPlayer();
	pScriptPlayer->SetEntity(pPlayer);
	pPlayer->SetScriptPlayer(pScriptPlayer);
	args.push(pScriptPlayer);
	CEvents::GetInstance()->Call("playerJoin", &args, CEventHandler::eEventType::NATIVE_EVENT, 0);

	// Construct a new bitstream
	RakNet::BitStream bitStream;

	// Write the player id
	bitStream.Write(playerId);

	// Write the player colour
	bitStream.Write(pPlayer->GetColor());

	// Write the server name
	bitStream.Write(RakNet::RakString("IV:Network DEV Server"));

	// Write the max player count
	bitStream.Write(CVAR_GET_INTEGER("maxplayers"));

	// Write the port
	bitStream.Write(CVAR_GET_INTEGER("port"));

	// Send it back to the player
	CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_INITIAL_DATA), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);

	for (EntityId i = 0; i < CServer::GetInstance()->GetPlayerManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetPlayerManager()->DoesExists(i) && i != playerId)
		{
			bitStream.Reset();
			bitStream.Write(i);
			bitStream.Write(CServer::GetInstance()->GetPlayerManager()->GetAt(i)->GetName().Get());
			bitStream.Write(CServer::GetInstance()->GetPlayerManager()->GetAt(i)->GetColor());
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_NEW_PLAYER), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);
		}
	}

	for (EntityId i = 0; i < CServer::GetInstance()->GetPlayerManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetPlayerManager()->DoesExists(i) && i != playerId)
		{
			bitStream.Reset();
			bitStream.Write(playerId);
			bitStream.Write(pPlayer->GetName().Get());
			bitStream.Write(pPlayer->GetColor());
			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_NEW_PLAYER), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, i, false);
		}
	}


	for (EntityId i = 0; i < CServer::GetInstance()->GetVehicleManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetVehicleManager()->DoesExists(i))
		{
			bitStream.Reset();
			CVehicleEntity * pVehicle = CServer::GetInstance()->GetVehicleManager()->GetAt(i);
			bitStream.Write(pVehicle->GetId());
			bitStream.Write(pVehicle->GetModelId());

			CVector3 vecPosition;
			pVehicle->GetPosition(vecPosition);
			bitStream.Write(vecPosition);

			CVector3 vecRotation;
			pVehicle->GetRotation(vecRotation);
			bitStream.Write(vecRotation.fX);

			bitStream.Write(pVehicle->GetColor(1));
			bitStream.Write(pVehicle->GetColor(2));
			bitStream.Write(pVehicle->GetColor(3));
			bitStream.Write(pVehicle->GetColor(4));
			bitStream.Write(pVehicle->GetColor(5));

			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_CREATE_VEHICLE), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);
		}
	}

	for (EntityId i = 0; i < CServer::GetInstance()->GetCheckpointManager()->GetMax(); ++i)
	{
		if (CServer::GetInstance()->GetCheckpointManager()->DoesExists(i))
		{
			bitStream.Reset();
			CCheckpointEntity * pCheckpoint = CServer::GetInstance()->GetCheckpointManager()->GetAt(i);
			bitStream.Write(pCheckpoint->GetId());
			bitStream.Write(pCheckpoint->GetType());

			CVector3 vecPosition;
			pCheckpoint->GetPosition(vecPosition);
			bitStream.Write(vecPosition);

			CVector3 vecTargetPosition;
			pCheckpoint->GetTargetPosition(vecTargetPosition);
			bitStream.Write(vecTargetPosition);

			bitStream.Write(pCheckpoint->GetRadius());

			CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_CREATE_CHECKPOINT), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);


			// Checkpoint visibility
			if (!pCheckpoint->GetVisible())
			{
				bitStream.Reset();

				bitStream.Write(pCheckpoint->GetId());
				CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_CHECKPOINT_HIDE), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, false);

			}
		}
	}
}
//------------------------------------------------------------------------------
// CUISelectResource::StartProduct
// Explain: nSelectResource이 -1일 경우에는 Random으로 처리한다. 
// Date : 2005-08-30,Author: Lee Ki-hwan
//------------------------------------------------------------------------------
void CUISelectResource::StartProduct( int nSelectResource )
{
	CUIManager* pUIManager = CUIManager::getSingleton();

	// 생산시 보내는 메세지에 담을 데이터 저장 
	CTString strTemp;
	// BUG-FIX : ITS(#1727) 펫에 탑승시에는 수집/생산을 할 수 없다. [5/20/2011 rumist]
	if( _pNetwork->MyCharacterInfo.bWildPetRide || _pNetwork->MyCharacterInfo.bPetRide )
	{
		if( m_iResourceType == 4 )
			strTemp = _S( 5490, "펫에 탑승한 상태에서는 퀘스트 아이템을 수집할 수 없습니다." );
		else
			strTemp = _S( 5491, "펫에 탑승한 상태에서는 생산할 수 없습니다." );
		
		pUIManager->GetChattingUI()->AddSysMessage( strTemp, SYSMSG_ERROR );
		return;
	}

	// BUG-FIX : 강신상태에서는 수집 / 채집 불가. [6/3/2011 rumist]
	CPlayerEntity* pPlayerEntity = (static_cast<CPlayerEntity*>(CEntity::GetPlayerEntity(0)));

	if( pPlayerEntity->IsTransforming())
	{
		strTemp = _S( 5494, "강신 상태에서는 수집/채집/생산을 할 수 없습니다." );
		
		pUIManager->GetChattingUI()->AddSysMessage( strTemp, SYSMSG_ERROR );
		return;
	}

	// 선택 한 생산 종류에 따라서 에니메이션 시작 
	extern INDEX idPlayerWhole_Animation[ANIM_TOTAL];
	switch(m_iResourceType)
	{
	case 1://채굴
		{
			INDEX ani = idPlayerWhole_Animation[ANIM_MINE];
			//INDEX ani = ska_StringToID(JobInfo().GetAnimationName( _pNetwork->MyCharacterInfo.job, ANIM_MINE ));
			CEntity::GetPlayerEntity(0)->AddAnimation(ani, AN_LOOPING|AN_CLEAR, 1.0f, 0x03,
					ESKA_MASTER_MODEL_INSTANCE, 1.0f);
		}
		break;
	case 2://채집
		{
			INDEX ani = idPlayerWhole_Animation[ANIM_COLLECT];
			//INDEX ani = ska_StringToID(JobInfo().GetAnimationName( _pNetwork->MyCharacterInfo.job, ANIM_GATHER ));
			CEntity::GetPlayerEntity(0)->AddAnimation(ani, AN_LOOPING|AN_CLEAR, 1.0f, 0x03,
					ESKA_MASTER_MODEL_INSTANCE, 1.0f);
		}
		break;
	case 3://차지
		{
			INDEX ani = idPlayerWhole_Animation[ANIM_GATHER];
			//INDEX ani = ska_StringToID(JobInfo().GetAnimationName( _pNetwork->MyCharacterInfo.job, ANIM_COLLECT ));
			CEntity::GetPlayerEntity(0)->AddAnimation(ani, AN_LOOPING|AN_CLEAR, 1.0f, 0x03,
					ESKA_MASTER_MODEL_INSTANCE, 1.0f);
		}
		break;
	case 4://수집
		{
			INDEX ani = idPlayerWhole_Animation[ANIM_COLLECT];
			//INDEX ani = ska_StringToID(JobInfo().GetAnimationName( _pNetwork->MyCharacterInfo.job, ANIM_GATHER ));
			CEntity::GetPlayerEntity(0)->AddAnimation(ani, AN_LOOPING|AN_CLEAR, 1.0f, 0x03,
					ESKA_MASTER_MODEL_INSTANCE, 1.0f);
		}
		break;
	}

	if( nSelectResource >= 0 ) 
	{
		m_iProduceItemDBIndex = g_iProductItemDBIndex[m_iResourceType-1][nSelectResource];
		strTemp = _pNetwork->GetItemData( g_iProductItemDBIndex[m_iResourceType-1][nSelectResource] )->GetName();
	}
	else 
	{
		m_iProduceItemDBIndex = -1;
	}

	CEntityProperty *pEP = CEntity::GetPlayerEntity(0)->PropertyForTypeAndID(CEntityProperty::EPT_INDEX, 239);
	if(pEP)
	{
		ENTITYPROPERTY( &*CEntity::GetPlayerEntity(0), pEP->ep_slOffset, INDEX) = m_iProduceItemDBIndex;
	}
	
	pEP = CEntity::GetPlayerEntity(0)->PropertyForTypeAndID(CEntityProperty::EPT_BOOL, 221);
	if(pEP)
	{
		ENTITYPROPERTY( &*CEntity::GetPlayerEntity(0), pEP->ep_slOffset, BOOL) = TRUE;
	}
	
	pEP = CEntity::GetPlayerEntity(0)->PropertyForTypeAndID(CEntityProperty::EPT_INDEX, 222);
	if(pEP)
	{
		ENTITYPROPERTY( &*CEntity::GetPlayerEntity(0), pEP->ep_slOffset, INDEX) = m_iResourceType;
	}
	
	// 현재 생산 중이 아이템을 화면에 표시 
	// 수집일경우 
	if(m_iResourceType == 4)
		strTemp += _S(3053, "퀘스트 아이템 수집을 시작합니다." );
	else strTemp += _S( 1824, "생산을 시작합니다." );

	pUIManager->GetChattingUI()->AddSysMessage(strTemp, SYSMSG_NORMAL);

}
Exemple #21
0
void CItemEntity::Touch(IBaseEntity *Other, SBSPPlane *plane, SBSPSurface *surf)
{
	if (!Other)
		return;
	if (!(Other->EntityFlags & EF_PLAYER))
		return;

	if (!(LinkedItem->Flags & ITEMFLAG_GRABBABLE))
		return;		// not a grabbable item?

	CPlayerEntity *Player = entity_cast<CPlayerEntity>(Other);

	if (Player->Health <= 0)
		return; // Dead players can't grab items

	if (!(SpawnFlags & ITEM_TARGETS_USED))
	{
		UseTargets (Other, Message);
		SpawnFlags |= ITEM_TARGETS_USED;
	}

	if (!LinkedItem->Pickup(this,Player))
		return;

	// flash the screen
	Player->Client.BonusAlpha = 0.25;	

	// show icon and name on status bar
	if (Player->Client.Timers.PickupMessageTime != (Level.Frame + 30))
	{
		Player->Client.PlayerState.GetStat (STAT_PICKUP_ICON) = LinkedItem->GetIconIndex();
		Player->Client.PlayerState.GetStat (STAT_PICKUP_STRING) = LinkedItem->GetConfigStringNumber();
		Player->Client.Timers.PickupMessageTime = Level.Frame + 30;
	}

	// change selected item
	if (LinkedItem->Flags & ITEMFLAG_USABLE)
	{
		Player->Client.Persistent.Inventory.SelectedItem = LinkedItem->GetIndex();
		Player->Client.PlayerState.GetStat (STAT_SELECTED_ITEM) = Player->Client.Persistent.Inventory.SelectedItem;
	}

	if (LinkedItem->PickupSound)
		Player->PlaySound (
#if CLEANCTF_ENABLED
		(LinkedItem == NItems::RedFlag || LinkedItem == NItems::BlueFlag) ? CHAN_AUTO : 
#endif
		CHAN_ITEM, LinkedItem->GetPickupSound()
#if CLEANCTF_ENABLED
		, 255, (LinkedItem == NItems::RedFlag || LinkedItem == NItems::BlueFlag) ? ATTN_NONE : ATTN_NORM
#endif
		);

	if (!((Game.GameMode & GAME_COOPERATIVE) &&  (LinkedItem->Flags & ITEMFLAG_STAY_COOP)) || (SpawnFlags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
	{
		if (ShouldRespawn)
			ShouldRespawn = false;
		else
			Free ();
	}
}