Advertisement
Guest User

Untitled

a guest
Dec 30th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf>
  4. #define Max_Indicators 144
  5. enum IndicatorsInfo
  6. {
  7. VID, //ID Modelu Pojazdu
  8. Float:PXLP, //Lewy Przod X
  9. Float:PYLP, //Lewy Przod Y
  10. Float:PZLP,//Lewy Przod Z
  11.  
  12. Float:PXLT, //Lewy Tył X
  13. Float:PYLT, //Lewy Tył Y
  14. Float:PZLT,//Lewy Tył Z
  15.  
  16. Float:PXPP, //Prawy Przod X
  17. Float:PYPP, //Prawy Przod Y
  18. Float:PZPP,//Prawy Przod Z
  19.  
  20. Float:PXPT, //Prawy Tył X
  21. Float:PYPT, //Prawy Tył Y
  22. Float:PZPT //Prawy Tył Z
  23. };
  24.  
  25. new IndicatorsObject[MAX_VEHICLES][6]; //Obiekty kierunkowskazów
  26. new bool:IndiRightOn[MAX_VEHICLES]; //Kierunkowskaz prawy włączony false/true
  27. new bool:IndiLeftOn[MAX_VEHICLES]; //Kierunkowskaz lewy włączony false/true
  28. new bool:IndiEmerOn[MAX_VEHICLES]; //Awaryjne światła włączone false/true
  29. new Indicators[Max_Indicators][IndicatorsInfo] =
  30. {
  31. {422, -0.8, 2.2, -0.3, -0.9, -2.499999, -0.2, 0.8, 2.2, -0.3, 0.9, -2.499999, -0.2},
  32. {482,-0.9,2.399999,-0.3,-0.799999,-2.599999,0.0,0.9,2.399999,-0.3,0.799999,-2.599999,0.0},
  33. };
  34.  
  35. CMD:awaryjne(playerid,params[])
  36. {
  37. new vehicleid = GetPlayerVehicleID(playerid);
  38. if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  39. {
  40. //----------------------Światła Awaryjne
  41. for(new i = 0; i < Max_Indicators; i++)
  42. {
  43. if(Indicators[i][VID] == GetVehicleModel(vehicleid))//Porównanie Modelu pojazdu z modelem w tablicy
  44. {
  45. if(IndiRightOn[vehicleid] == true || IndiLeftOn[vehicleid] == true) return 0;
  46. if(IndiEmerOn[vehicleid] == false)
  47. {
  48. IndiEmerOn[vehicleid] = true;
  49. //Kierunkowskaz Prawy Przedni
  50. IndicatorsObject[vehicleid][0] = CreateObject( 19294,0,0,0,0,0,0,80 );
  51. AttachObjectToVehicle(IndicatorsObject[vehicleid][0], vehicleid, Indicators[i][PXPP], Indicators[i][PYPP], Indicators[i][PZPP], 0, 0, 0);
  52. //Kierunkowskaz Prawy Tylny
  53. IndicatorsObject[vehicleid][1] = CreateObject( 19294,0,0,0,0,0,0,80 );
  54. AttachObjectToVehicle(IndicatorsObject[vehicleid][1], vehicleid, Indicators[i][PXPT], Indicators[i][PYPT], Indicators[i][PZPT], 0, 0, 0);
  55. //Kierunkowskaz Lewy Przedni
  56. IndicatorsObject[vehicleid][2] = CreateObject( 19294,0,0,0,0,0,0,80 );
  57. AttachObjectToVehicle(IndicatorsObject[vehicleid][2], vehicleid, Indicators[i][PXLP], Indicators[i][PYLP], Indicators[i][PZLP], 0, 0, 0);
  58. //Kierunkowskaz Lewy Tylny
  59. IndicatorsObject[vehicleid][3] = CreateObject( 19294,0,0,0,0,0,0,80 );
  60. AttachObjectToVehicle(IndicatorsObject[vehicleid][3], vehicleid, Indicators[i][PXLT], Indicators[i][PYLT], Indicators[i][PZLT], 0, 0, 0);
  61. }else
  62. {
  63. IndiEmerOn[vehicleid] = false;
  64. DestroyObject(IndicatorsObject[vehicleid][0]);
  65. DestroyObject(IndicatorsObject[vehicleid][1]);
  66. DestroyObject(IndicatorsObject[vehicleid][2]);
  67. DestroyObject(IndicatorsObject[vehicleid][3]);
  68. }
  69. }
  70. }
  71. }
  72. return 1;
  73. }
  74.  
  75. public OnVehicleDeath(vehicleid)
  76. {
  77. IndiEmerOn[vehicleid] = false;
  78. IndiRightOn[vehicleid] = false;
  79. IndiLeftOn[vehicleid] = false;
  80. DestroyObject(IndicatorsObject[vehicleid][0]);
  81. DestroyObject(IndicatorsObject[vehicleid][1]);
  82. DestroyObject(IndicatorsObject[vehicleid][2]);
  83. DestroyObject(IndicatorsObject[vehicleid][3]);
  84. DestroyObject(IndicatorsObject[vehicleid][4]);
  85.  
  86. return 1;
  87. }
  88.  
  89. public OnVehicleSpawn(vehicleid)
  90. {
  91. IndiEmerOn[vehicleid] = false;
  92. IndiRightOn[vehicleid] = false;
  93. IndiLeftOn[vehicleid] = false;
  94. DestroyObject(IndicatorsObject[vehicleid][0]);
  95. DestroyObject(IndicatorsObject[vehicleid][1]);
  96. DestroyObject(IndicatorsObject[vehicleid][2]);
  97. DestroyObject(IndicatorsObject[vehicleid][3]);
  98. DestroyObject(IndicatorsObject[vehicleid][4]);
  99.  
  100. return 1;
  101. }
  102.  
  103. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  104. {
  105. if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  106. {
  107. new vehicleid = GetPlayerVehicleID(playerid);
  108. new trailerid = GetVehicleTrailer(GetPlayerVehicleID(playerid));
  109.  
  110. //----------------------Kierunkowskaz Lewy
  111. if(newkeys == 256)
  112. {
  113.  
  114. if(IsTrailerAttachedToVehicle(vehicleid))
  115. {
  116. if(IndiLeftOn[trailerid] == true) return 0;
  117. for(new t = 0; t < Max_Indicators; t++)
  118. {
  119. if(Indicators[t][VID] == GetVehicleModel(GetVehicleTrailer(vehicleid)))
  120. {
  121. if(IndiLeftOn[trailerid] == false)
  122. {
  123. IndiLeftOn[trailerid] = true;
  124. IndicatorsObject[trailerid][4] = CreateObject( 19294,0,0,0,0,0,0,80 );
  125. AttachObjectToVehicle(IndicatorsObject[trailerid][4], trailerid, Indicators[t][PXLT], Indicators[t][PYLT], Indicators[t][PZLT], 0, 0, 0);
  126. }else
  127. {
  128. IndiLeftOn[trailerid] = false;
  129. DestroyObject(IndicatorsObject[trailerid][4]);
  130. }
  131. }
  132. }
  133. }
  134.  
  135. for(new i = 0; i < Max_Indicators; i++)
  136. {
  137. if(Indicators[i][VID] == GetVehicleModel(vehicleid))//Porównanie Modelu pojazdu z modelem w tablicy
  138. {
  139. if(IndiEmerOn[vehicleid] == true || IndiRightOn[vehicleid] == true) return 0;
  140. if(IndiLeftOn[vehicleid] == false)
  141. {
  142.  
  143. IndiLeftOn[vehicleid] = true;
  144. //Kierunkowskaz Lewy Przedni
  145. IndicatorsObject[vehicleid][0] = CreateObject( 19294,0,0,0,0,0,0,80 );
  146. AttachObjectToVehicle(IndicatorsObject[vehicleid][0], vehicleid, Indicators[i][PXLP], Indicators[i][PYLP], Indicators[i][PZLP], 0, 0, 0);
  147. //Kierunkowskaz Lewy Tylny
  148. IndicatorsObject[vehicleid][1] = CreateObject( 19294,0,0,0,0,0,0,80 );
  149. AttachObjectToVehicle(IndicatorsObject[vehicleid][1], vehicleid, Indicators[i][PXLT], Indicators[i][PYLT], Indicators[i][PZLT], 0, 0, 0);
  150.  
  151. }else
  152. {
  153. IndiLeftOn[vehicleid] = false;
  154. DestroyObject(IndicatorsObject[vehicleid][0]);
  155. DestroyObject(IndicatorsObject[vehicleid][1]);
  156.  
  157. }
  158. }
  159. }
  160. }
  161. //----------------------Kierunkowskaz Prawy
  162. if(newkeys == 64)
  163. {
  164.  
  165. if(IsTrailerAttachedToVehicle(vehicleid))
  166. {
  167. if(IndiLeftOn[trailerid] == true) return 0;
  168. for(new t = 0; t < Max_Indicators; t++)
  169. {
  170. if(Indicators[t][VID] == GetVehicleModel(GetVehicleTrailer(vehicleid)))
  171. {
  172. if(IndiRightOn[trailerid] == false)
  173. {
  174. IndiRightOn[trailerid] = true;
  175. IndicatorsObject[trailerid][4] = CreateObject( 19294,0,0,0,0,0,0,80 );
  176. AttachObjectToVehicle(IndicatorsObject[trailerid][4], trailerid, Indicators[t][PXPT], Indicators[t][PYPT], Indicators[t][PZPT], 0, 0, 0);
  177. }else
  178. {
  179. IndiRightOn[trailerid] = false;
  180. DestroyObject(IndicatorsObject[trailerid][4]);
  181. }
  182. }
  183. }
  184. }
  185.  
  186. for(new i = 0; i < Max_Indicators; i++)
  187. {
  188. if(Indicators[i][VID] == GetVehicleModel(vehicleid))//Porównanie Modelu pojazdu z modelem w tablicy
  189. {
  190. if(IndiEmerOn[vehicleid] == true || IndiLeftOn[vehicleid] == true) return 0;
  191. if(IndiRightOn[vehicleid] == false)
  192. {
  193. IndiRightOn[vehicleid] = true;
  194. //Kierunkowskaz Prawy Przedni
  195. IndicatorsObject[vehicleid][0] = CreateObject( 19294,0,0,0,0,0,0,80 );
  196. AttachObjectToVehicle(IndicatorsObject[vehicleid][0], vehicleid, Indicators[i][PXPP], Indicators[i][PYPP], Indicators[i][PZPP], 0, 0, 0);
  197. //Kierunkowskaz Prawy Tylny
  198. IndicatorsObject[vehicleid][1] = CreateObject( 19294,0,0,0,0,0,0,80 );
  199. AttachObjectToVehicle(IndicatorsObject[vehicleid][1], vehicleid, Indicators[i][PXPT], Indicators[i][PYPT], Indicators[i][PZPT], 0, 0, 0);
  200. }else
  201. {
  202. IndiRightOn[vehicleid] = false;
  203. DestroyObject(IndicatorsObject[vehicleid][0]);
  204. DestroyObject(IndicatorsObject[vehicleid][1]);
  205. }
  206. }
  207. }
  208. }
  209. }
  210.  
  211. return 1;
  212. }
  213.  
  214. public OnGameModeInit()
  215. {
  216. SetWeather(2);
  217. return 1;
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement