Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.75 KB | None | 0 0
  1. /*
  2. Module: Hotwire / BreakIgnition
  3. Created by: L3o
  4. */
  5.  
  6. #include <YSI\y_hooks>
  7.  
  8. //=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ [DEFINES]
  9.  
  10. #define HotwireCooldown (120) //=> Koliko sekundi mora cekati do sljedeceg paljenja vozila na zice.
  11.  
  12. //=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ [VARIABLES]
  13. new
  14. PlayerText:HotwireTextdraws[MAX_PLAYERS][8],
  15. PlayerHotwireVehicle[MAX_PLAYERS] = 0,
  16. PlayerHotwireCombination[MAX_PLAYERS] = 0,
  17. PlayerHotwireTime[MAX_PLAYERS] = 0,
  18. hotwiretimer[MAX_PLAYERS];
  19.  
  20. /*
  21. ##### ###### # # ##### ##### ##### ## # # ####
  22. # # # # # # # # # # # # # #
  23. # ##### ## # # # # # # # # # ####
  24. # # ## # # # ##### ###### # ## # #
  25. # # # # # # # # # # # ## ## # #
  26. # ###### # # # ##### # # # # # # ####
  27. */
  28. stock CreateHotwireTextdraws(playerid, bool:created)
  29. {
  30. if(created == false) {
  31. for(new i = 0; i < 8; i++) {
  32. PlayerTextDrawHide(playerid, HotwireTextdraws[playerid][i]);
  33. }
  34. CancelSelectTextDraw(playerid);
  35. }
  36. else if(created == true) {
  37. HotwireTextdraws[playerid][0] = CreatePlayerTextDraw(playerid, 266.732788, 363.863342, "box");
  38. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][0], 0.000000, 7.266665);
  39. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][0], 364.000000, 0.000000);
  40. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][0], 1);
  41. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][0], -1);
  42. PlayerTextDrawUseBox(playerid, HotwireTextdraws[playerid][0], 1);
  43. PlayerTextDrawBoxColor(playerid, HotwireTextdraws[playerid][0], 170);
  44. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][0], 0);
  45. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][0], 0);
  46. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][0], 255);
  47. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][0], 1);
  48. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][0], 1);
  49. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][0], 0);
  50.  
  51. HotwireTextdraws[playerid][1] = CreatePlayerTextDraw(playerid, 278.266571, 374.848541, "LD_SPAC:white"); // Zelena
  52. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][1], 0.000000, 0.000000);
  53. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][1], 7.000000, 48.000000);
  54. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][1], 1);
  55. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][1], 8388863);
  56. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][1], 0);
  57. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][1], 0);
  58. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][1], 255);
  59. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][1], 4);
  60. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][1], 0);
  61. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][1], 0);
  62. PlayerTextDrawSetSelectable(playerid, HotwireTextdraws[playerid][1], true);
  63.  
  64. HotwireTextdraws[playerid][2] = CreatePlayerTextDraw(playerid, 298.667816, 374.648529, "LD_SPAC:white"); // Crvena
  65. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][2], 0.000000, 0.000000);
  66. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][2], 7.000000, 48.000000);
  67. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][2], 1);
  68. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][2], -2147483393);
  69. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][2], 0);
  70. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][2], 0);
  71. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][2], 255);
  72. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][2], 4);
  73. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][2], 0);
  74. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][2], 0);
  75. PlayerTextDrawSetSelectable(playerid, HotwireTextdraws[playerid][2], true);
  76.  
  77. HotwireTextdraws[playerid][3] = CreatePlayerTextDraw(playerid, 319.669097, 374.648529, "LD_SPAC:white"); // Zuta
  78. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][3], 0.000000, 0.000000);
  79. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][3], 7.000000, 48.000000);
  80. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][3], 1);
  81. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][3], -65281);
  82. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][3], 0);
  83. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][3], 0);
  84. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][3], 255);
  85. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][3], 4);
  86. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][3], 0);
  87. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][3], 0);
  88. PlayerTextDrawSetSelectable(playerid, HotwireTextdraws[playerid][3], true);
  89.  
  90. HotwireTextdraws[playerid][4] = CreatePlayerTextDraw(playerid, 341.970458, 374.233703, "LD_SPAC:white"); // Plava
  91. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][4], 0.000000, 0.000000);
  92. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][4], 7.000000, 48.000000);
  93. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][4], 1);
  94. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][4], -1378294017);
  95. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][4], 0);
  96. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][4], 0);
  97. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][4], 255);
  98. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][4], 4);
  99. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][4], 0);
  100. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][4], 0);
  101. PlayerTextDrawSetSelectable(playerid, HotwireTextdraws[playerid][4], true);
  102.  
  103. HotwireTextdraws[playerid][5] = CreatePlayerTextDraw(playerid, 265.000000, 354.881652, "Select_Wire");
  104. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][5], 0.258666, 1.189333);
  105. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][5], 1);
  106. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][5], -1);
  107. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][5], 0);
  108. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][5], -1);
  109. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][5], 255);
  110. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][5], 1);
  111. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][5], 1);
  112. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][5], 0);
  113.  
  114. HotwireTextdraws[playerid][6] = CreatePlayerTextDraw(playerid, 312.733398, 431.381500, " ");
  115. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][6], 0.194666, 0.803555);
  116. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][6], 2);
  117. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][6], -1);
  118. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][6], 0);
  119. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][6], 1);
  120. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][6], 255);
  121. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][6], 1);
  122. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][6], 1);
  123. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][6], 0);
  124.  
  125. HotwireTextdraws[playerid][7] = CreatePlayerTextDraw(playerid, 358.666748, 357.429595, "ld_chat:thumbdn");
  126. PlayerTextDrawLetterSize(playerid, HotwireTextdraws[playerid][7], 0.000000, 0.000000);
  127. PlayerTextDrawTextSize(playerid, HotwireTextdraws[playerid][7], 10.000000, 11.000000);
  128. PlayerTextDrawAlignment(playerid, HotwireTextdraws[playerid][7], 1);
  129. PlayerTextDrawColor(playerid, HotwireTextdraws[playerid][7], -1);
  130. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][7], 0);
  131. PlayerTextDrawSetOutline(playerid, HotwireTextdraws[playerid][7], 0);
  132. PlayerTextDrawBackgroundColor(playerid, HotwireTextdraws[playerid][7], 255);
  133. PlayerTextDrawFont(playerid, HotwireTextdraws[playerid][7], 4);
  134. PlayerTextDrawSetProportional(playerid, HotwireTextdraws[playerid][7], 0);
  135. PlayerTextDrawSetShadow(playerid, HotwireTextdraws[playerid][7], 0);
  136. PlayerTextDrawSetSelectable(playerid, HotwireTextdraws[playerid][7], true);
  137.  
  138. for(new i = 0; i < 8; i++) {
  139. PlayerTextDrawShow(playerid, HotwireTextdraws[playerid][i]);
  140. }
  141. SelectTextDraw(playerid, 0xAFAFAFAA);
  142. }
  143. return (true);
  144. }
  145.  
  146. //=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ [STOCKS]
  147.  
  148. stock ResetHotwireFunctions(playerid)
  149. {
  150. //[player]
  151. CreateHotwireTextdraws(playerid, false); PlayerHotwireTime[playerid] = 80;
  152. PlayerHotwireVehicle[playerid] = 0; PlayerHotwireCombination[playerid] = 0;
  153. return 1;
  154. }
  155.  
  156.  
  157. FUNCTION: Hotwire_Timer()
  158. {
  159. new br_string[64],Float:Pos[3];
  160. foreach(new i: Player)
  161. {
  162. if(PlayerHotwireVehicle[i] == 1)
  163. {
  164. new vehicleid = GetNearestVehicle(i);
  165. new carid = isCOSVehicle(vehicleid);
  166.  
  167. PlayerHotwireTime[i] --;
  168.  
  169. format(br_string,sizeof(br_string),"(time):_~y~%d~w~seconds_remain...",PlayerHotwireTime[i]);
  170. PlayerTextDrawSetString(i, HotwireTextdraws[i][6], br_string);
  171.  
  172. if(PlayerHotwireTime[i] < 0)
  173. {
  174. GetPlayerPos(i, Pos[0],Pos[1],Pos[2]);
  175.  
  176. if(carid != (-1))
  177. {
  178. if(VehicleData[carid][pAlarmLevel] != 0)
  179. {
  180. SetAlarmStatus(VehicleData[carid][ownableVehicleID], VEHICLE_PARAMS_ON);
  181. ResetHotwireFunctions(i); KillTimer(hotwiretimer[i]);
  182. SendInfoMessage(i, "Niste uspijeli da upalite vozilo na zice, alarm je aktiviran.");
  183. // Dodati da izbaci PDu upozorenje
  184. }
  185. }
  186. }
  187. }
  188. }
  189. return (true);
  190. }
  191. //=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ [HOOKS]
  192.  
  193. hook OnPlayerClickPlayerTD(playerid, PlayerText:playertextid)
  194. {
  195. if(playertextid == HotwireTextdraws[playerid][7])
  196. {
  197. CreateHotwireTextdraws(playerid, false);
  198. return 1;
  199. }
  200.  
  201. // ZICE - SUSTAV
  202. if(playertextid == HotwireTextdraws[playerid][1])
  203. {
  204. if(PlayerHotwireCombination[playerid] == 1)
  205. {
  206. SCM(playerid, COLOR_GREEN,"[INFO]: Uspijesno ste pogodili kombinaciju zica i upalili ste motor na vozilu.");
  207. SetEngineStatus(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON);
  208. CreateHotwireTextdraws(playerid, false); ResetHotwireFunctions(playerid);
  209. return 1;
  210. }
  211.  
  212. if(PlayerHotwireCombination[playerid] != 1)
  213. {
  214. new comb = minrand(1, 4);
  215. SendErrorMessage(playerid, "Pogrijesili ste zicu, pokusajte ponovo (- 5 seconds).");
  216. PlayerHotwireTime[playerid] -= 5; PlayerHotwireCombination[playerid] = comb;
  217. return 1;
  218. }
  219. }
  220. if(playertextid == HotwireTextdraws[playerid][2])
  221. {
  222. if(PlayerHotwireCombination[playerid] == 2)
  223. {
  224. SCM(playerid, COLOR_GREEN,"[INFO]: Uspijesno ste pogodili kombinaciju zica i upalili ste motor na vozilu.");
  225. SetEngineStatus(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON);
  226. CreateHotwireTextdraws(playerid, false); ResetHotwireFunctions(playerid);
  227. return 1;
  228. }
  229.  
  230. if(PlayerHotwireCombination[playerid] != 2)
  231. {
  232. new comb = minrand(1, 4);
  233. SendErrorMessage(playerid, "Pogrijesili ste zicu, pokusajte ponovo (- 5 seconds).");
  234. PlayerHotwireTime[playerid] -= 5; PlayerHotwireCombination[playerid] = comb;
  235. return 1;
  236. }
  237. }
  238. if(playertextid == HotwireTextdraws[playerid][3])
  239. {
  240. if(PlayerHotwireCombination[playerid] == 3)
  241. {
  242. SCM(playerid, COLOR_GREEN,"[INFO]: Uspijesno ste pogodili kombinaciju zica i upalili ste motor na vozilu.");
  243. SetEngineStatus(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON);
  244. CreateHotwireTextdraws(playerid, false); ResetHotwireFunctions(playerid);
  245. return 1;
  246. }
  247.  
  248. if(PlayerHotwireCombination[playerid] != 3)
  249. {
  250. new comb = minrand(1, 4);
  251. SendErrorMessage(playerid, "Pogrijesili ste zicu, pokusajte ponovo (- 5 seconds).");
  252. PlayerHotwireTime[playerid] -= 5; PlayerHotwireCombination[playerid] = comb;
  253. return 1;
  254. }
  255. }
  256. if(playertextid == HotwireTextdraws[playerid][4])
  257. {
  258. if(PlayerHotwireCombination[playerid] == 4)
  259. {
  260. SCM(playerid, COLOR_GREEN,"[INFO]: Uspijesno ste pogodili kombinaciju zica i upalili ste motor na vozilu.");
  261. SetEngineStatus(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON);
  262. CreateHotwireTextdraws(playerid, false); ResetHotwireFunctions(playerid);
  263. return 1;
  264. }
  265.  
  266. if(PlayerHotwireCombination[playerid] != 4)
  267. {
  268. new comb = minrand(1, 4);
  269. SendErrorMessage(playerid, "Pogrijesili ste zicu, pokusajte ponovo (- 5 seconds).");
  270. PlayerHotwireTime[playerid] -= 5; PlayerHotwireCombination[playerid] = comb;
  271. return 1;
  272. }
  273. }
  274. return 1;
  275. }
  276. //=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ [COMMANDS]
  277.  
  278. CMD:hotwire(playerid, params[])
  279. {
  280. new action[25],
  281. vehicleid = GetNearestVehicle(playerid),
  282. carid = isCOSVehicle(vehicleid);
  283.  
  284. if(sscanf(params, "s[25] ", action))
  285. {
  286. SendCOMMANDMessage(playerid, "/hotwire [action].");
  287. SCM(playerid, 0xAFAFAFAA, "[actions] start, stop");
  288. return (true);
  289. }
  290.  
  291. if(strcmp(action,"start",true) == 0)
  292. {
  293. if(carid != (-1))
  294. {
  295. new engineget = GetPlayerVehicleID(playerid), engine,lights,alarm,doors,bonnet,boot,objective,Float:vHealth;
  296. GetVehicleParamsEx(engineget,engine, lights, alarm, doors, bonnet, boot, objective );
  297.  
  298. if(HTCooldownTimer[playerid] != 0)
  299. return va_SCM(playerid, COLOR_LIGHTRED,"[ERROR]: Do sljedeceg paljenja vozila na zice morate sacekati jos %d sekundi.",HTCooldownTimer[playerid]);
  300.  
  301. if(VehicleData[carid][Fuel] <= 1) return SendErrorMessage(playerid, "U ovom vozilu nema goriva, ne mozete ga upaliti.");
  302.  
  303. if(isequal(GetName(playerid), VehicleData[carid][vehicleOwner]))
  304. return SendErrorMessage(playerid,"Ne mozete ovu komandu koristit u vasem vozilu.");
  305.  
  306. if(VehicleIsBike(GetPlayerVehicleID(playerid))) return SendErrorMessage(playerid, "Ne mozete upaliti motor na biciklu.");
  307.  
  308. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Morate biti na vozacevom mjestu.");
  309. if( engine == 1 ) return SendErrorMessage( playerid, "Motor na ovom vozilu je vec upaljen." );
  310.  
  311. GetVehicleHealth( GetPlayerVehicleID( playerid ), vHealth );
  312. if( vHealth < 400 ) return SendErrorMessage( playerid, "Motor na ovom vozilu je previse ostecen, ne mozete ga upaliti!");
  313.  
  314. // Combination
  315. new comb = minrand(1, 5);
  316. if(comb == 5) { comb = 4; }
  317. if(VehicleData[carid][pImmobiliser] == 0) PlayerHotwireTime[playerid] = 90;
  318. else if(VehicleData[carid][pImmobiliser] == 1) PlayerHotwireTime[playerid] = 50;
  319. else if(VehicleData[carid][pImmobiliser] == 2) PlayerHotwireTime[playerid] = 40;
  320. else if(VehicleData[carid][pImmobiliser] == 3) PlayerHotwireTime[playerid] = 30;
  321. else if(VehicleData[carid][pImmobiliser] == 4) PlayerHotwireTime[playerid] = 20;
  322.  
  323. HTCooldownTimer[playerid] = HotwireCooldown;
  324. hotwiretimer[playerid] = SetTimerEx("Hotwire_Timer", 1000, true, "i", playerid);
  325. CreateHotwireTextdraws(playerid, true); PlayerHotwireVehicle[playerid] = 1; PlayerHotwireCombination[playerid] = comb;
  326. SendInfoMessage(playerid, "Poceli ste sa paljenjem vozila na zice, da prekinete radnju kucajte /hotwire stop.");
  327. }
  328. }
  329.  
  330. if(strcmp(action,"stop",true) == 0)
  331. {
  332. if(PlayerHotwireVehicle[playerid] == 1)
  333. {
  334. ResetHotwireFunctions(playerid);
  335. SendInfoMessage(playerid, "Odustali ste od paljenja vozila na zice, alarm je aktiviran.");
  336. SetAlarmStatus(VehicleData[carid][ownableVehicleID], VEHICLE_PARAMS_ON);
  337. // Dodati da izbaci PDu upozorenje
  338. }
  339. }
  340. return (true);
  341. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement