コード例 #1
1
void PlayerHandler::TeleportPlayer(int playerid, WorldPositionObject pos)
{
	SetPlayerVirtualWorld(playerid, pos.virtualWorld_);
	SetPlayerInterior(playerid, pos.sampInteriorId_);
	SetPlayerPos(playerid, pos.x_, pos.y_, pos.z_);
	if (GetPlayerState(playerid) == 2)
	{
		int vehicleId = GetPlayerVehicleID(playerid);
		LinkVehicleToInterior(vehicleId, pos.sampInteriorId_);
		SetVehicleVirtualWorld(vehicleId, pos.virtualWorld_);
		SetVehiclePos(vehicleId, pos.x_, pos.y_, pos.z_);
		PutPlayerInVehicle(playerid, vehicleId, 0);
	}
	SetPVarInt(playerid, "oldinterior", GetPVarInt(playerid, "currentinterior"));
	SetPVarInt(playerid, "currentinterior", pos.interiorId_);
}
コード例 #2
0
cell AMX_NATIVE_CALL Natives::IsDynamicVehicleOccupied(AMX *amx, cell *params)
{
	CHECK_PARAMS(1, "IsDynamicVehicleOccupied");
	boost::unordered_map<int, int>::iterator i = core->getData()->internalVehicles.find(static_cast<int>(params[1]));
	if (i != core->getData()->internalVehicles.end())
	{
		for (boost::unordered_map<int, Player>::iterator p = core->getData()->players.begin(); p != core->getData()->players.end(); p++)
		{
			if (GetPlayerVehicleID(p->first) == i->second) return 1;
		}
	}
	return 0;
}
コード例 #3
0
cell AMX_NATIVE_CALL Natives::IsPlayerInAnyDynamicVehicle(AMX *amx, cell *params)
{
	CHECK_PARAMS(1, "IsPlayerInAnyDynamicVehicle");
	int internalid = GetPlayerVehicleID(static_cast<int>(params[1]));
	if (internalid)
	{
		for (boost::unordered_map<int, int>::iterator i = core->getData()->internalVehicles.begin(); i != core->getData()->internalVehicles.end(); i++)
		{
			if (i->second == internalid)
			{
				return 1;
			}
		}
	}
	return 0;
}
コード例 #4
0
void Streamer::performPlayerUpdate(Player &player, bool automatic)
{
	Eigen::Vector3f delta = Eigen::Vector3f::Zero(), position = player.position;
	int state = GetPlayerState(player.playerID);
	bool update = true;
	if (automatic)
	{
		player.interiorID = GetPlayerInterior(player.playerID);
		player.worldID = GetPlayerVirtualWorld(player.playerID);
		GetPlayerPos(player.playerID, &player.position[0], &player.position[1], &player.position[2]);
		if (state != PLAYER_STATE_NONE && state != PLAYER_STATE_WASTED)
		{
			if (player.position != position)
			{
				position = player.position;
				Eigen::Vector3f velocity = Eigen::Vector3f::Zero();
				if (state == PLAYER_STATE_ONFOOT)
				{
					GetPlayerVelocity(player.playerID, &velocity[0], &velocity[1], &velocity[2]);
				}
				else if (state == PLAYER_STATE_DRIVER || state == PLAYER_STATE_PASSENGER)
				{
					GetVehicleVelocity(GetPlayerVehicleID(player.playerID), &velocity[0], &velocity[1], &velocity[2]);
				}
				float velocityNorm = velocity.squaredNorm();
				if (velocityNorm >= velocityBoundaries.get<0>() && velocityNorm <= velocityBoundaries.get<1>())
				{
					delta = velocity * averageUpdateTime;
					player.position += delta;
				}
			}
			else
			{
				update = player.updateWhenIdle;
			}
		}
		else
		{
			update = false;
		}
	}
	std::vector<SharedCell> cells;
	if (update)
	{
		core->getGrid()->findAllCells(player, cells);
		if (!cells.empty())
		{
			if (!core->getData()->objects.empty() && player.enabledItems[STREAMER_TYPE_OBJECT] && !IsPlayerNPC(player.playerID))
			{
				processObjects(player, cells);
			}
			if (!core->getData()->checkpoints.empty() && player.enabledItems[STREAMER_TYPE_CP])
			{
				processCheckpoints(player, cells);
			}
			if (!core->getData()->raceCheckpoints.empty() && player.enabledItems[STREAMER_TYPE_RACE_CP])
			{
				processRaceCheckpoints(player, cells);
			}
			if (!core->getData()->mapIcons.empty() && player.enabledItems[STREAMER_TYPE_MAP_ICON] && !IsPlayerNPC(player.playerID))
			{
				processMapIcons(player, cells);
			}
			if (!core->getData()->textLabels.empty() && player.enabledItems[STREAMER_TYPE_3D_TEXT_LABEL] && !IsPlayerNPC(player.playerID))
			{
				processTextLabels(player, cells);
			}
			if (!core->getData()->areas.empty() && player.enabledItems[STREAMER_TYPE_AREA])
			{
				if (!delta.isZero())
				{
					player.position = position;
				}
				processAreas(player, cells);
				if (!delta.isZero())
				{
					player.position += delta;
				}
			}
		}
	}
	if (automatic)
	{
		if (!core->getData()->pickups.empty())
		{
			if (!update)
			{
				core->getGrid()->findMinimalCells(player, cells);
			}
			processPickups(player, cells);
		}
		if (!delta.isZero())
		{
			player.position = position;
		}
		executeCallbacks();
	}
}