cell AMX_NATIVE_CALL Natives::PutPlayerInDynamicVehicle(AMX *amx, cell *params) { CHECK_PARAMS(3, "PutPlayerInDynamicVehicle"); int playerid = static_cast<int>(params[1]); int vehicleid = static_cast<int>(params[2]); int seatid = static_cast<int>(params[3]); boost::unordered_map<int, Player>::iterator p = core->getData()->players.find(playerid); if (p != core->getData()->players.end()) { boost::unordered_map<int, Item::SharedVehicle>::iterator v = core->getData()->vehicles.find(vehicleid); if (v != core->getData()->vehicles.end()) { boost::unordered_map<int, int>::iterator i = core->getData()->internalVehicles.find(v->first); if (i == core->getData()->internalVehicles.end()) { int internalID = INVALID_VEHICLE_ID; switch(v->second->modelID) { case 537: case 538: { //internalID = AddStaticVehicle(v->second->modelID, v->second->position[0], v->second->position[1], v->second->position[2], v->second->angle, v->second->color1, v->second->color2); // TODO - This won't work properly without modifing train handling in samp server // If you create train, then you create 4 vehicle - the base model ID has been returned, but the last 3 trailer not and you can't get these IDs - only when these ids are in sequence // but these IDs won't be in sequence when server randomly destroy and create vehicles at different ids - for more info: http://pastebin.com/wZsiVHBr break; } default: { internalID = CreateVehicle(v->second->modelID, v->second->position[0], v->second->position[1], v->second->position[2], v->second->angle, v->second->color1, v->second->color2, -1, v->second->spawn.addsiren); break; } } if (internalID == INVALID_VEHICLE_ID) { return 0; } if (!v->second->numberplate.empty()) { SetVehicleNumberPlate(internalID, v->second->numberplate.c_str()); } if(v->second->interior) { LinkVehicleToInterior(internalID, v->second->interior); } if(v->second->worldID) { SetVehicleVirtualWorld(internalID, v->second->worldID); } if (!v->second->carmods.empty()) { for (std::vector<int>::iterator c = v->second->carmods.begin(); c != v->second->carmods.end(); c++) { AddVehicleComponent(internalID, *c); } } if (v->second->paintjob != 4) { ChangeVehiclePaintjob(internalID, v->second->paintjob); } if(v->second->panels != 0 || v->second->doors != 0 || v->second->lights != 0|| v->second->tires != 0) { UpdateVehicleDamageStatus(internalID, v->second->panels, v->second->doors, v->second->lights, v->second->tires); } if (v->second->health != 1000.0f) { SetVehicleHealth(internalID, v->second->health); } if(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) { SetVehicleParamsEx(internalID, v->second->params.engine, v->second->params.lights, v->second->params.alarm, v->second->params.doors, v->second->params.bonnet, v->second->params.boot, v->second->params.objective); } if(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) { SetVehicleParamsCarDoors(internalID, v->second->params.cardoors.driver, v->second->params.cardoors.passenger, v->second->params.cardoors.backleft, v->second->params.cardoors.backright); } if(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) { SetVehicleParamsCarWindows(internalID, v->second->params.carwindows.driver, v->second->params.carwindows.passenger, v->second->params.carwindows.backleft, v->second->params.carwindows.backright); } if(internalID != INVALID_VEHICLE_ID) { PutPlayerInVehicle(playerid, internalID, seatid); core->getData()->internalVehicles.insert(std::make_pair(v->first, internalID)); } else { return 0; } } else { PutPlayerInVehicle(playerid, i->second, seatid); } if (!v->second->touched) { v->second->touched = true; v->second->used = true; core->getStreamer()->movingVehicles.insert(v->second); } v->second->lastUpdatedTick = GetTickCount(); return 1; } } return 0; }
cell AMX_NATIVE_CALL Natives::UpdateDynamicVehDamageStatus(AMX *amx, cell *params) { CHECK_PARAMS(5, "UpdateDynamicVehDamageStatus"); boost::unordered_map<int, Item::SharedVehicle>::iterator v = core->getData()->vehicles.find(static_cast<int>(params[1])); if (v != core->getData()->vehicles.end()) { v->second->panels = static_cast<int>(params[2]); v->second->doors = static_cast<int>(params[3]); v->second->lights = static_cast<int>(params[4]); v->second->tires = static_cast<int>(params[5]); boost::unordered_map<int, int>::iterator i = core->getData()->internalVehicles.find(v->first); if (i != core->getData()->internalVehicles.end()) { UpdateVehicleDamageStatus(i->second, v->second->panels, v->second->doors, v->second->lights, v->second->tires); } return 1; } return 0; }
bool UpdateDamageStatus(int panels, int doors, int lights, int tires) const { return UpdateVehicleDamageStatus(id_, panels, doors, lights, tires); }