Advertisement
Guest User

Untitled

a guest
May 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. enum
  2. {
  3. TYPE_NORMAL_VEHICLE,
  4. TYPE_DATABASE_VEHICLE
  5. }
  6.  
  7. enum myVehicleEnum
  8. {
  9. vID,
  10. vModelID,
  11. Float:vX,
  12. Float:vY,
  13. Float:vZ,
  14. Float:vA,
  15. vColor1,
  16. vColor2,
  17. vRespawn,
  18. vSiren,
  19. vType
  20. }
  21. new MyVehicles[MAX_VEHICLES][myVehicleEnum];
  22.  
  23. GetFreeSlot()
  24. {
  25. new id = -1;
  26.  
  27. for(new i = 0; i < MAX_VEHICLES; i++)
  28. {
  29. if(MyVehicles[i][vUID] == 0)
  30. {
  31. id = i; // we found a free array slot
  32. break;
  33. }
  34. }
  35.  
  36. return id;
  37. }
  38.  
  39. CreateScriptedVehicle(modelid, Float:vX, Float:vY, Float:vZ, Float:vA, vColor1, vColor2, vRespawn = -1, vSiren = 0, vType = TYPE_NORMAL_VEHICLE)
  40. {
  41. new slot = GetFreeSlot();
  42.  
  43. if(slot == -1) // no free slot found, don't create the vehicle and send a message
  44. {
  45. printf("Can't create vehicle, no free slot found!");
  46. }
  47.  
  48. MyVehicles[slot][vModelID] = modelid;
  49. MyVehicles[slot][vX] = vX;
  50. MyVehicles[slot][vY] = vY;
  51. MyVehicles[slot][vZ] = vZ;
  52. MyVehicles[slot][vA] = vA;
  53. MyVehicles[slot][vColor1] = vColor1;
  54. MyVehicles[slot][vColor2] = vColor2;
  55. MyVehicles[slot][vRespawn] = vRespawn;
  56. MyVehicles[slot][vSiren] = vSiren;
  57. MyVehicles[slot][vType] = vType;
  58.  
  59. if(MyVehicles[slot][vType] == TYPE_DATABASE_VEHICLE)
  60. {
  61. //Here you can insert the vehicle to the database, if it isn't already in it and you load those vehicles before you create normal ones in OnGameModeInit, for example:
  62. //LoadDatabaseVehicles();
  63. //...
  64. //CreateScriptedVehicle(...);
  65. //It should search for a free array id there and if you want to save, you only save those vehicles with vType = TYPE_DATABASE_VEHICLE
  66. }
  67.  
  68. return CreateVehicle(modelid, vX, vY, vZ, vA, vColor1, vColor2, vRespawn, vSiren);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement