Advertisement
exod182

Advanced Vehicle Functions

Aug 24th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.62 KB | None | 0 0
  1. /* ---------------------------------
  2. Advanced Vehicle Functions PAWN include
  3.  
  4. - File: a_veh.inc
  5. - Author: Exod_Martinez
  6. ---------------------------------*/
  7. /*
  8. native GetVehiclePaintjob(vehicleid);
  9. native GetVehicleSpawn(vehicleid, &Float:x, &Float:y, &Float:z, &Float:a);
  10. native GetVehicleColor(vehicleid, &color1, &color2);
  11. native GetVehicleRespawnDelay(vehicleid);
  12.  
  13. native ToggleEngine(vehicleid);
  14. native ToggleLights(vehicleid);
  15. native ToggleAlarm(vehicleid);
  16. native ToggleDoors(vehicleid);
  17. native ToggleBonnet(vehicleid);
  18. native ToggleBoot(vehicleid);
  19. native ToggleObjective(vehicleid);
  20.  
  21. //engine, lights, alarm, doors, bonnet, boot, objective
  22. */
  23.  
  24.  
  25. enum exd_vehEnum{
  26. exd_vModel,
  27. Float:exd_vSpawnPos[4],
  28. exd_vColor[2],
  29. exd_vInterior,
  30. exd_vVirtualWorld,
  31. exd_vPaintJob,
  32. exd_vRespawnDelay
  33. }
  34. new exd_Vehicles[MAX_VEHICLES][exd_vehEnum];
  35.  
  36. forward exd_OnVehicleRespray(playerid, vehicleid, color1, color2);
  37.  
  38. stock exd_CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay){
  39. new vid = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay);
  40. exd_Vehicles[vid][exd_vModel] = vehicletype;
  41. exd_Vehicles[vid][exd_vSpawnPos][0] = x; exd_Vehicles[vid][exd_vSpawnPos][1] = y;
  42. exd_Vehicles[vid][exd_vSpawnPos][2] = z; exd_Vehicles[vid][exd_vSpawnPos][3] = rotation;
  43. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  44. exd_Vehicles[vid][exd_vRespawnDelay] = respawn_delay;
  45. return vid;
  46. }
  47.  
  48. stock exd_AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2){
  49. new vid = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2);
  50. exd_Vehicles[vid][exd_vModel] = modelid;
  51. exd_Vehicles[vid][exd_vSpawnPos][0] = spawn_x; exd_Vehicles[vid][exd_vSpawnPos][1] = spawn_y;
  52. exd_Vehicles[vid][exd_vSpawnPos][2] = spawn_z; exd_Vehicles[vid][exd_vSpawnPos][3] = z_angle;
  53. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  54. exd_Vehicles[vid][exd_vRespawnDelay] = -1;
  55. return vid;
  56. }
  57.  
  58. stock exd_AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, respawn_delay){
  59. new vid = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, respawn_delay);
  60. exd_Vehicles[vid][exd_vModel] = modelid;
  61. exd_Vehicles[vid][exd_vSpawnPos][0] = spawn_x; exd_Vehicles[vid][exd_vSpawnPos][1] = spawn_y;
  62. exd_Vehicles[vid][exd_vSpawnPos][2] = spawn_z; exd_Vehicles[vid][exd_vSpawnPos][3] = z_angle;
  63. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  64. exd_Vehicles[vid][exd_vRespawnDelay] = respawn_delay;
  65. return vid;
  66. }
  67.  
  68. stock exd_ChangeVehiclePaintjob(vehicleid, paintjobid){
  69. exd_Vehicles[vehicleid][exd_vPaintJob] = paintjobid;
  70. return ChangeVehiclePaintjob(vehicleid, paintjobid);
  71. }
  72.  
  73. stock exd_ChangeVehicleColor(vehicleid, color1, color2){
  74. exd_Vehicles[vehicleid][exd_vColor][0] = color1;
  75. exd_Vehicles[vehicleid][exd_vColor][1] = color2;
  76. return ChangeVehicleColor(vehicleid, color1, color2);
  77. }
  78.  
  79. stock exd_DestroyVehicle(vehicleid){
  80. exd_Vehicles[vehicleid][exd_vModel] = 0;
  81. for(new i=0;i<4;i++){
  82. exd_Vehicles[vehicleid][exd_vSpawnPos][i] = 0.0;
  83. }
  84. return DestroyVehicle(vehicleid);
  85. }
  86.  
  87. stock GetVehiclePaintjob(vehicleid)return exd_Vehicles[vehicleid][exd_vPaintJob];
  88. stock GetVehicleRespawnDelay(vehicleid)return exd_Vehicles[vehicleid][exd_vRespawnDelay];
  89.  
  90. stock GetVehicleColor(vehicleid, &color1, &color2){
  91. color1 = exd_Vehicles[vehicleid][exd_vColor][0];
  92. color2 = exd_Vehicles[vehicleid][exd_vColor][1];
  93. return true;
  94. }
  95.  
  96. stock GetVehicleSpawn(vehicleid, &Float:x, &Float:y, &Float:z, &Float:a){
  97. x = exd_Vehicles[vehicleid][exd_vSpawnPos][0];
  98. y = exd_Vehicles[vehicleid][exd_vSpawnPos][1];
  99. z = exd_Vehicles[vehicleid][exd_vSpawnPos][2];
  100. a = exd_Vehicles[vehicleid][exd_vSpawnPos][3];
  101. return true;
  102. }
  103.  
  104. stock ToggleEngine(vehicleid){
  105. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  106. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  107. return SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
  108. }
  109.  
  110. stock ToggleLights(vehicleid){
  111. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  112. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  113. return SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
  114. }
  115.  
  116. stock ToggleAlarm(vehicleid){
  117. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  118. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  119. return SetVehicleParamsEx(vehicleid, engine, lights, VEHICLE_PARAMS_ON, doors, bonnet, boot, objective);
  120. }
  121.  
  122. stock ToggleDoors(vehicleid){
  123. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  124. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  125. return SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective);
  126. }
  127.  
  128. stock ToggleBonnet(vehicleid){
  129. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  130. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  131. return SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, VEHICLE_PARAMS_ON, boot, objective);
  132. }
  133.  
  134. stock ToggleBoot(vehicleid){
  135. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  136. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  137. return SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
  138. }
  139.  
  140. stock ToggleObjective(vehicleid){
  141. new bool:engine, bool:lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  142. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  143. return SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, VEHICLE_PARAMS_ON);
  144. }
  145.  
  146. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  147. {
  148. exd_Vehicles[vehicleid][exd_vColor][0] = color1;
  149. exd_Vehicles[vehicleid][exd_vColor][1] = color2;
  150. if (funcidx("exd_OnVehicleRespray") != -1)
  151. {
  152. return CallLocalFunction("exd_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
  153. }
  154. return 1;
  155. }
  156.  
  157. #if defined _ALS_CreateVehicle
  158. #undef CreateVehicle
  159. #else
  160. #define _ALS_CreateVehicle
  161. #endif
  162.  
  163. #if defined _ALS_DestoryVehicle
  164. #undef DestroyVehicle
  165. #else
  166. #define _ALS_DestoryVehicle
  167. #endif
  168.  
  169. #if defined _ALS_AddStaticVehicle
  170. #undef AddStaticVehicle
  171. #else
  172. #define _ALS_AddStaticVehicle
  173. #endif
  174.  
  175. #if defined _ALS_AddStaticVehicleEx
  176. #undef AddStaticVehicleEx
  177. #else
  178. #define _ALS_AddStaticVehicle
  179. #endif
  180.  
  181. #if defined _ALS_ChangeVehiclePaintjob
  182. #undef ChangeVehiclePaintjob
  183. #else
  184. #define _ALS_ChangeVehiclePaintjob
  185. #endif
  186.  
  187. #if defined _ALS_ChangeVehicleColor
  188. #undef ChangeVehicleColor
  189. #else
  190. #define _ALS_ChangeVehicleColor
  191. #endif
  192.  
  193. #if defined _ALS_OnVehicleRespray
  194. #undef OnVehicleRespray
  195. #else
  196. #define _ALS_OnVehicleRespray
  197. #endif
  198.  
  199. #define CreateVehicle exd_CreateVehicle
  200. #define DestroyVehicle exd_DestroyVehicle
  201. #define AddStaticVehicle exd_AddStaticVehicle
  202. #define AddStaticVehicleEx exd_AddStaticVehicleEx
  203. #define ChangeVehiclePaintjob exd_ChangeVehiclePaintjob
  204. #define ChangeVehicleColor exd_ChangeVehicleColor
  205.  
  206. #define OnVehicleRespray exd_OnVehicleRespray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement