Advertisement
Guest User

Reamis

a guest
Dec 14th, 2007
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. /*
  2. This code was designed to allow users to have a larger number of vehicle spawns in their script than
  3. sa-mp will normally allow. The script will allow you to have in theory up to 9999 vehicle
  4. spawns in your gamemode but only 700 of these can be active at any one point simultaneously...basically the script
  5. will only create vehicles if there is somebody around to see them.
  6.  
  7. The default distance it will spawn a car for u is set at 100 meters but you can change that very simply by changing
  8. SPAWN_DISTANCE
  9.  
  10. In order to add streaming vehicle spawns u must add your vehicle spawns into this fs under OnFilterscriptInit using:
  11.  
  12. AddStreamingVehicle(modelid,x,y,z,angle,color1,color2);
  13.  
  14. rather than addstaticvehicle.
  15.  
  16. This script and all code contained within was designed by <tAxI> and is released to the public as freeware.
  17. Any attempts to claim this code as your own will not be taken lightly so don't even try it :-P
  18.  
  19. HOPE U ALL LIKE IT...ENJOY!!!!
  20.  
  21. <tAxI>
  22.  
  23. */
  24. #include <a_samp>
  25.  
  26. #define SPAWN_DISTANCE 150
  27. #define MAX_ACTIVE_VEHICLES 675
  28. #define MODEL_LIMIT 212
  29. #define MAX_ACTIVE_MODELS 65
  30.  
  31. forward proxcheck();
  32.  
  33. new modelcount[MODEL_LIMIT];
  34. new vehcount = 0;
  35. new streamcount = 0;
  36. new vehused[MAX_ACTIVE_VEHICLES];
  37.  
  38. enum vInfo
  39. {
  40. model,
  41. Float:x_spawn,
  42. Float:y_spawn,
  43. Float:z_spawn,
  44. Float:za_spawn,
  45. color_1,
  46. color_2,
  47. spawned,
  48. idnum,
  49. };
  50. new VehicleInfo[9999][vInfo];
  51.  
  52. public OnFilterScriptInit()
  53. {
  54. //cars
  55. AddStreamingVehicle(523,1560.7695,-1694.4358,5.6122,32.7235,-1,-1);//cop bike
  56. AddStreamingVehicle(523,1563.5020,-1694.8240,5.4627,21.6809,-1,-1);//cop bike
  57. AddStreamingVehicle(420,1713.9504,-2323.2983,12.9492,273.7584,-1,-1);//car taxi
  58. AddStreamingVehicle(565,2489.3066,-2605.5688,13.3711,0.4802,-1,-1);
  59. AddStreamingVehicle(596,1570.5022,-1710.5771,5.6091,179.8262,-1,-1);//cop car
  60. // -----------------------------------------------------------------------------
  61. SetTimer("proxcheck",1000,1);
  62. new string[256];
  63. print(" ");
  64. print(" ");
  65. print("tAxI's Dynamic Vehicle Streamer v0.1");
  66. print(" ");
  67. print("-----------------------------------------------------------------");
  68. print(" ");
  69. format(string,sizeof(string),"tAxI's Dynamic Vehicle Streamer has detected %d Vehicle Spawns...",vehcount);
  70. printf(string);
  71. print(" ");
  72. format(string,sizeof(string),"Only %d spawns may be activated at any one time simultaneously...",MAX_ACTIVE_VEHICLES);
  73. printf(string);
  74. print(" ");
  75. print("tAxI's Dynamic Vehicle Streamer is now running...ENJOY!!!");
  76. print(" ");
  77. print("-----------------------------------------------------------------");
  78. print(" ");
  79. print(" ");
  80. print(" ");
  81. return 1;
  82. }
  83.  
  84. public OnVehicleDeath(vehicleid, killerid)
  85. {
  86. SetTimerEx("DeactivateStreamedVehicle",6000,0,"x",vehicleid);
  87. return 1;
  88. }
  89.  
  90. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  91. {
  92. vehused[vehicleid] = 1;
  93. return 1;
  94. }
  95.  
  96. public proxcheck()
  97. {
  98. for(new i = 1;i<vehcount;i++) {
  99. if(VehicleInfo[i][spawned] == 0){
  100. if(IsPlayerClose(i,SPAWN_DISTANCE) == 1){
  101. if(streamcount <= MAX_ACTIVE_VEHICLES) {
  102. if(modelcount[VehicleInfo[i][model]-400] < MAX_ACTIVE_MODELS) {
  103. VehicleInfo[i][idnum] = CreateVehicle(VehicleInfo[i][model], VehicleInfo[i][x_spawn], VehicleInfo[i][y_spawn], VehicleInfo[i][z_spawn], VehicleInfo[i][za_spawn], VehicleInfo[i][color_1], VehicleInfo[i][color_2],11000);
  104. VehicleInfo[i][spawned] = 1;
  105. modelcount[VehicleInfo[i][model]-400]++;
  106. streamcount++;
  107. }
  108. }
  109. }
  110. }
  111. else {
  112. if(vehused[VehicleInfo[i][idnum]] == 0) {
  113. if(IsPlayerClose(i,SPAWN_DISTANCE) == 0) {
  114. DestroyVehicle(VehicleInfo[i][idnum]);
  115. VehicleInfo[i][spawned] = 0;
  116. modelcount[VehicleInfo[i][model]-400]--;
  117. streamcount--;
  118. }
  119. }
  120. }
  121. }
  122. }
  123.  
  124. stock AddStreamingVehicle(modelid,Float:x,Float:y,Float:z,Float:a,col1,col2)
  125. {
  126. vehcount++;
  127. VehicleInfo[vehcount][model] = modelid;
  128. VehicleInfo[vehcount][x_spawn] = x;
  129. VehicleInfo[vehcount][y_spawn] = y;
  130. VehicleInfo[vehcount][z_spawn] = z;
  131. VehicleInfo[vehcount][za_spawn] = a;
  132. VehicleInfo[vehcount][color_1] = col1;
  133. VehicleInfo[vehcount][color_2] = col2;
  134. return 1;
  135. }
  136.  
  137. stock DeactivateStreamedVehicle(vehicleid)
  138. {
  139. vehused[vehicleid] = 0;
  140. return 1;
  141. }
  142.  
  143. stock IsPlayerClose(streamid, Float:MAX)
  144. {
  145. for(new i = 0;i<MAX_PLAYERS;i++){
  146. if(!IsPlayerConnected(i)) continue;
  147. new Float:PPos[3];
  148. GetPlayerPos(i, PPos[0], PPos[1], PPos[2]);
  149. if (PPos[0] >= floatsub(VehicleInfo[streamid][x_spawn], MAX) && PPos[0] <= floatadd(VehicleInfo[streamid][x_spawn], MAX)
  150. && PPos[1] >= floatsub(VehicleInfo[streamid][y_spawn], MAX) && PPos[1] <= floatadd(VehicleInfo[streamid][y_spawn], MAX)
  151. && PPos[2] >= floatsub(VehicleInfo[streamid][z_spawn], MAX) && PPos[2] <= floatadd(VehicleInfo[streamid][z_spawn], MAX))
  152. {
  153. return 1;
  154. }
  155. }
  156. return 0;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement