Advertisement
exod182

Advanced Vehicle Functions 1.3

Aug 27th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.63 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. native ToggleStatus(vehicleid, param[]);
  22.  
  23. //tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], objective
  24. */
  25.  
  26.  
  27. enum exd_vehEnum{
  28. exd_vModel,
  29. Float:exd_vSpawnPos[4],
  30. exd_vColor[2],
  31. exd_vInterior,
  32. exd_vVirtualWorld,
  33. exd_vPaintJob,
  34. exd_vRespawnDelay
  35. bool:exd_vLocked
  36. }
  37. new exd_Vehicles[MAX_VEHICLES][exd_vehEnum];
  38.  
  39. forward exd_OnVehicleRespray(playerid, vehicleid, color1, color2);
  40.  
  41. stock exd_CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay){
  42. new vid = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay);
  43. exd_Vehicles[vid][exd_vModel] = vehicletype;
  44. exd_Vehicles[vid][exd_vSpawnPos][0] = x; exd_Vehicles[vid][exd_vSpawnPos][1] = y;
  45. exd_Vehicles[vid][exd_vSpawnPos][2] = z; exd_Vehicles[vid][exd_vSpawnPos][3] = rotation;
  46. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  47. exd_Vehicles[vid][exd_vRespawnDelay] = respawn_delay;
  48. exd_Vehicles[vid][exd_vLocked] = false;
  49. return vid;
  50. }
  51.  
  52. stock exd_AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2){
  53. new vid = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2);
  54. exd_Vehicles[vid][exd_vModel] = modelid;
  55. exd_Vehicles[vid][exd_vSpawnPos][0] = spawn_x; exd_Vehicles[vid][exd_vSpawnPos][1] = spawn_y;
  56. exd_Vehicles[vid][exd_vSpawnPos][2] = spawn_z; exd_Vehicles[vid][exd_vSpawnPos][3] = z_angle;
  57. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  58. exd_Vehicles[vid][exd_vRespawnDelay] = -1;
  59. exd_Vehicles[vid][exd_vLocked] = false;
  60. return vid;
  61. }
  62.  
  63. stock exd_AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, respawn_delay){
  64. new vid = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, respawn_delay);
  65. exd_Vehicles[vid][exd_vModel] = modelid;
  66. exd_Vehicles[vid][exd_vSpawnPos][0] = spawn_x; exd_Vehicles[vid][exd_vSpawnPos][1] = spawn_y;
  67. exd_Vehicles[vid][exd_vSpawnPos][2] = spawn_z; exd_Vehicles[vid][exd_vSpawnPos][3] = z_angle;
  68. exd_Vehicles[vid][exd_vColor][0] = color1; exd_Vehicles[vid][exd_vColor][1] = color2;
  69. exd_Vehicles[vid][exd_vRespawnDelay] = respawn_delay;
  70. exd_Vehicles[vid][exd_vLocked] = false;
  71. return vid;
  72. }
  73.  
  74. stock exd_ChangeVehiclePaintjob(vehicleid, paintjobid){
  75. exd_Vehicles[vehicleid][exd_vPaintJob] = paintjobid;
  76. return ChangeVehiclePaintjob(vehicleid, paintjobid);
  77. }
  78.  
  79. stock exd_ChangeVehicleColor(vehicleid, color1, color2){
  80. exd_Vehicles[vehicleid][exd_vColor][0] = color1;
  81. exd_Vehicles[vehicleid][exd_vColor][1] = color2;
  82. return ChangeVehicleColor(vehicleid, color1, color2);
  83. }
  84.  
  85. stock exd_DestroyVehicle(vehicleid){
  86. exd_Vehicles[vehicleid][exd_vModel] = 0;
  87. for(new i=0;i<4;i++){
  88. exd_Vehicles[vehicleid][exd_vSpawnPos][i] = 0.0;
  89. }
  90. return DestroyVehicle(vehicleid);
  91. }
  92.  
  93. stock GetVehiclePaintjob(vehicleid)return exd_Vehicles[vehicleid][exd_vPaintJob];
  94. stock GetVehicleRespawnDelay(vehicleid)return exd_Vehicles[vehicleid][exd_vRespawnDelay];
  95.  
  96. stock GetVehicleColor(vehicleid, &color1, &color2){
  97. color1 = exd_Vehicles[vehicleid][exd_vColor][0];
  98. color2 = exd_Vehicles[vehicleid][exd_vColor][1];
  99. return true;
  100. }
  101.  
  102. stock GetVehicleSpawn(vehicleid, &Float:x, &Float:y, &Float:z, &Float:a){
  103. x = exd_Vehicles[vehicleid][exd_vSpawnPos][0];
  104. y = exd_Vehicles[vehicleid][exd_vSpawnPos][1];
  105. z = exd_Vehicles[vehicleid][exd_vSpawnPos][2];
  106. a = exd_Vehicles[vehicleid][exd_vSpawnPos][3];
  107. return true;
  108. }
  109.  
  110. stock ToggleEngine(vehicleid){
  111. new static tmp[7];
  112. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  113. return SetVehicleParamsEx(vehicleid, !tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  114. }
  115.  
  116. stock ToggleLights(vehicleid){
  117. new static tmp[7];
  118. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  119. return SetVehicleParamsEx(vehicleid, tmp[0], !tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  120. }
  121.  
  122. stock ToggleAlarm(vehicleid){
  123. new static tmp[7];
  124. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  125. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], !tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  126. }
  127.  
  128. stock ToggleDoors(vehicleid){
  129. new static tmp[7];
  130. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  131. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], !tmp[3], tmp[4], tmp[5], tmp[6]);
  132. }
  133.  
  134. stock ToggleBonnet(vehicleid){
  135. new static tmp[7];
  136. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  137. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], !tmp[4], tmp[5], tmp[6]);
  138. }
  139.  
  140. stock ToggleBoot(vehicleid){
  141. new static tmp[7];
  142. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  143. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], !tmp[5], tmp[6]);
  144. }
  145.  
  146. stock ToggleObjective(vehicleid){
  147. new static tmp[7];
  148. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  149. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], !tmp[6]);
  150. }
  151.  
  152. stock ToggleStatus(vehicleid, param[]){
  153. new static tmp[7];
  154. GetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  155. if(strcmp(param, "engine", true) == 0 || strcmp(param, "motor", true) == 0){
  156. return SetVehicleParamsEx(vehicleid, !tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  157. }
  158. else if(strcmp(param, "lights", true) == 0 || strcmp(param, "licht", true) == 0){
  159. return SetVehicleParamsEx(vehicleid, tmp[0], !tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  160. }
  161. else if(strcmp(param, "alarm") == 0){
  162. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], !tmp[2], tmp[3], tmp[4], tmp[5], tmp[6]);
  163. }
  164. else if(strcmp(param, "doors") == 0 || strcmp(param, "tuer") == 0){
  165. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], !tmp[3], tmp[4], tmp[5], tmp[6]);
  166. }
  167. else if(strcmp(param, "bonnet") == 0 || strcmp(param, "motorhaube") == 0){
  168. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], !tmp[4], tmp[5], tmp[6]);
  169. }
  170. else if(strcmp(param, "boot") == 0 || strcmp(param, "kofferraum"){
  171. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], !tmp[5], tmp[6]);
  172. }
  173. else if(strcmp(param, "objective") == 0){
  174. return SetVehicleParamsEx(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], !tmp[6]);
  175. }
  176. return print("Es ist ein Fehler aufgetreten: ToggleStatus -> Falscher Parameter");
  177. }
  178.  
  179. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  180. {
  181. exd_Vehicles[vehicleid][exd_vColor][0] = color1;
  182. exd_Vehicles[vehicleid][exd_vColor][1] = color2;
  183. if (funcidx("exd_OnVehicleRespray") != -1)
  184. {
  185. return CallLocalFunction("exd_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
  186. }
  187. return 1;
  188. }
  189.  
  190. #if defined _ALS_CreateVehicle
  191. #undef CreateVehicle
  192. #else
  193. #define _ALS_CreateVehicle
  194. #endif
  195.  
  196. #if defined _ALS_DestoryVehicle
  197. #undef DestroyVehicle
  198. #else
  199. #define _ALS_DestoryVehicle
  200. #endif
  201.  
  202. #if defined _ALS_AddStaticVehicle
  203. #undef AddStaticVehicle
  204. #else
  205. #define _ALS_AddStaticVehicle
  206. #endif
  207.  
  208. #if defined _ALS_AddStaticVehicleEx
  209. #undef AddStaticVehicleEx
  210. #else
  211. #define _ALS_AddStaticVehicle
  212. #endif
  213.  
  214. #if defined _ALS_ChangeVehiclePaintjob
  215. #undef ChangeVehiclePaintjob
  216. #else
  217. #define _ALS_ChangeVehiclePaintjob
  218. #endif
  219.  
  220. #if defined _ALS_ChangeVehicleColor
  221. #undef ChangeVehicleColor
  222. #else
  223. #define _ALS_ChangeVehicleColor
  224. #endif
  225.  
  226. #if defined _ALS_OnVehicleRespray
  227. #undef OnVehicleRespray
  228. #else
  229. #define _ALS_OnVehicleRespray
  230. #endif
  231.  
  232. #define CreateVehicle exd_CreateVehicle
  233. #define DestroyVehicle exd_DestroyVehicle
  234. #define AddStaticVehicle exd_AddStaticVehicle
  235. #define AddStaticVehicleEx exd_AddStaticVehicleEx
  236. #define ChangeVehiclePaintjob exd_ChangeVehiclePaintjob
  237. #define ChangeVehicleColor exd_ChangeVehicleColor
  238.  
  239. #define OnVehicleRespray exd_OnVehicleRespray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement