Advertisement
djhonga2001

Untitled

Jan 22nd, 2017
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //spawning
  2. void request_vehicle(std::string modelName, std::string modelTitle)
  3. {
  4. uint model = joaat(modelName);
  5. STREAMING::REQUEST_MODEL(model);
  6. DWORD now = GetTickCount();
  7. while (!STREAMING::HAS_MODEL_LOADED(model) && GetTickCount() < now + 5000)
  8. {
  9. WAIT(0);
  10. }
  11.  
  12. if (!STREAMING::HAS_MODEL_LOADED(model))
  13. {
  14. notifyBottom("Timed out requesting %s : 0x%X", modelTitle.c_str(), model);
  15. return;
  16. }
  17.  
  18. auto vehicle = do_spawn_vehicle(model, true);
  19. if (vehicle)
  20. {
  21. // Add blip
  22. //if (featureAddBlipForSpawnedVehicles)
  23. // add_blip_for_vehicle(vehicle);
  24. // Add to All Spawned Vehicles list
  25. SpawnedVehicle* db = new SpawnedVehicle();
  26. db->hash = model;
  27. db->name = modelTitle;
  28. db->vehicle = vehicle;
  29. spawnedVehicles.push_back(db);
  30. notifyBottom("Spawned %s : 0x%X", modelTitle.c_str(), model);
  31. }
  32. }
  33.  
  34. Vehicle do_spawn_vehicle(uint model, bool cleanup)
  35. {
  36. auto heading = selfHeading;
  37. auto coords = selfCoords;
  38.  
  39. float forward = 5.f;
  40. float xVect = forward * sin(degToRad(heading)) * -1.0f;
  41. float yVect = forward * cos(degToRad(heading));
  42. BOOL isAircraft = VEHICLE::IS_THIS_MODEL_A_HELI(model) || VEHICLE::IS_THIS_MODEL_A_PLANE(model);
  43.  
  44. Vehicle vehicle = NULL;
  45. if (isAircraft && isVehWrapInSpawned)
  46. {
  47. vehicle = VEHICLE::CREATE_VEHICLE(model, coords.x + xVect, coords.y + yVect, coords.z + 1000, heading, TRUE, TRUE);
  48. VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, 500.0f);
  49. VEHICLE::SET_HELI_BLADES_FULL_SPEED(vehicle);
  50. }
  51. else
  52. {
  53. vehicle = VEHICLE::CREATE_VEHICLE(model, coords.x + xVect, coords.y + yVect, coords.z, heading, TRUE, TRUE);
  54. VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(vehicle);
  55. }
  56.  
  57. DECORATOR::DECOR_SET_INT(vehicle, "MPBitset", 0);
  58.  
  59. if (isVehSpawnTuned) upgradeVehMaximum(vehicle);
  60. if (isVehWrapInSpawned) PED::SET_PED_INTO_VEHICLE(selfPed, vehicle, -1);
  61.  
  62. return vehicle;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement