Esempio n. 1
0
	bool SetToRespawn() const
		{ return SetVehicleToRespawn(id_); }
Esempio n. 2
0
cell AMX_NATIVE_CALL Natives::SetDynamicVehicleToRespawn(AMX *amx, cell *params)
{
	CHECK_PARAMS(1, "SetDynamicVehicleToRespawn");
	boost::unordered_map<int, Item::SharedVehicle>::iterator v = core->getData()->vehicles.find(static_cast<int>(params[1]));
	if (v != core->getData()->vehicles.end())
	{
		Eigen::Vector3f position = v->second->position;
		v->second->position = v->second->spawn.position;
		v->second->angle = v->second->spawn.angle;
		v->second->color1 = v->second->spawn.color1;
		v->second->color2 = v->second->spawn.color2;
		v->second->paintjob = 4; // In GTA, you can use 0 - 3 IDs for paintjobs, 4 is invalid
		v->second->health = 1000.0f;
		v->second->carmods.clear();
		if (v->second->touched)
		{
			v->second->touched = false;
			v->second->used = true;
			core->getStreamer()->movingVehicles.erase(v->second);
		}
		v->second->spawnedTick = GetTickCount();

		// Reset vehicle damage
		v->second->panels = 0;
		v->second->doors = 0;
		v->second->lights = 0;
		v->second->tires = 0;

		// Set vehicle parameters as unset
		v->second->params.engine = VEHICLE_PARAMS_UNSET;
		v->second->params.lights = VEHICLE_PARAMS_UNSET;
		v->second->params.alarm = VEHICLE_PARAMS_UNSET;
		v->second->params.doors = VEHICLE_PARAMS_UNSET;
		v->second->params.bonnet = VEHICLE_PARAMS_UNSET;
		v->second->params.boot = VEHICLE_PARAMS_UNSET;
		v->second->params.objective = VEHICLE_PARAMS_UNSET;
		v->second->params.siren = VEHICLE_PARAMS_UNSET;
		v->second->params.cardoors.driver = VEHICLE_PARAMS_UNSET;
		v->second->params.cardoors.passenger = VEHICLE_PARAMS_UNSET;
		v->second->params.cardoors.backleft = VEHICLE_PARAMS_UNSET;
		v->second->params.cardoors.backright = VEHICLE_PARAMS_UNSET;
		v->second->params.carwindows.driver = VEHICLE_PARAMS_UNSET;
		v->second->params.carwindows.passenger = VEHICLE_PARAMS_UNSET;
		v->second->params.carwindows.backleft = VEHICLE_PARAMS_UNSET;
		v->second->params.carwindows.backright = VEHICLE_PARAMS_UNSET;
		boost::unordered_map<int, int>::iterator i = core->getData()->internalVehicles.find(v->first);
		if (i != core->getData()->internalVehicles.end())
		{
			SetVehicleToRespawn(i->second);
			SetVehiclePos(i->second, v->second->position[0], v->second->position[1], v->second->position[2]);
			SetVehicleZAngle(i->second, v->second->angle);
			LinkVehicleToInterior(i->second, v->second->interior);
			SetVehicleVirtualWorld(i->second, v->second->worldID);
		}
		else
		{
			for (std::set<AMX*>::iterator a = core->getData()->interfaces.begin(); a != core->getData()->interfaces.end(); ++a)
			{
				int amxIndex = 0;
				if (!amx_FindPublic(*a, "OnDynamicVehicleSpawn", &amxIndex))
				{
					amx_Push(*a, static_cast<cell>(v->first));
					amx_Exec(*a, NULL, amxIndex);
				}
			}
		}
		if (position[0] != v->second->position[0] || position[1] != v->second->position[1])
		{
			if (v->second->cell)
			{
				core->getGrid()->removeVehicle(v->second, true);
			}
		}
		return 1;
	}
	return 0;
}