1
0

speedo.pwn 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Speedo System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. stock UpdateVehicleHUDForPlayer(p, fuel, speed)
  34. {
  35. new str[128], vehicleid = GetPlayerVehicleID(p), szColor[4];
  36. new engine,lights,alarm,doors,bonnet,boot,objective;
  37. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  38. switch(speed)
  39. {
  40. case 0..40: szColor = "~w~";
  41. case 41..60: szColor = "~y~";
  42. default: szColor = "~r~";
  43. }
  44. if (IsVIPcar(vehicleid) || IsAdminSpawnedVehicle(vehicleid) || IsFamedVeh(vehicleid) || GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
  45. format(str, sizeof(str), "~b~Fuel: ~w~U");
  46. else
  47. format(str, sizeof(str), "~b~Fuel: ~w~%i",fuel);
  48. PlayerTextDrawSetString(p, _vhudTextFuel[p], str);
  49. format(str, sizeof(str), "~b~MPH: %s%i",szColor, speed);
  50. PlayerTextDrawSetString(p, _vhudTextSpeed[p], str);
  51. if(Seatbelt[p] == 0)
  52. {
  53. format(str, sizeof(str), "~b~%s: ~r~OFF", IsABike(vehicleid) ? ("HM"):("SB"));
  54. PlayerTextDrawSetString(p, _vhudSeatBelt[p], str);
  55. }
  56. else if(Seatbelt[p] == 2) {
  57. format(str, sizeof(str), "~b~HM: ~g~ON");
  58. PlayerTextDrawSetString(p, _vhudSeatBelt[p], str);
  59. }
  60. else {
  61. format(str, sizeof(str), "~b~SB: ~g~ON");
  62. PlayerTextDrawSetString(p, _vhudSeatBelt[p], str);
  63. }
  64. if(lights != VEHICLE_PARAMS_ON) {
  65. format(str, sizeof(str), "~b~Lights: ~r~OFF");
  66. PlayerTextDrawSetString(p, _vhudLights[p], str);
  67. }
  68. else {
  69. format(str, sizeof(str), "~b~Lights: ~g~ON");
  70. PlayerTextDrawSetString(p, _vhudLights[p], str);
  71. }
  72. }
  73. stock ShowVehicleHUDForPlayer(playerid)
  74. {
  75. PlayerTextDrawShow(playerid, _vhudTextFuel[playerid]);
  76. PlayerTextDrawShow(playerid, _vhudTextSpeed[playerid]);
  77. PlayerTextDrawShow(playerid, _vhudSeatBelt[playerid]);
  78. PlayerTextDrawShow(playerid, _vhudLights[playerid]);
  79. _vhudVisible[playerid] = 1;
  80. }
  81. stock HideVehicleHUDForPlayer(playerid)
  82. {
  83. PlayerTextDrawHide(playerid, _vhudTextFuel[playerid]);
  84. PlayerTextDrawHide(playerid, _vhudTextSpeed[playerid]);
  85. PlayerTextDrawHide(playerid, _vhudSeatBelt[playerid]);
  86. PlayerTextDrawHide(playerid, _vhudLights[playerid]);
  87. _vhudVisible[playerid] = 0;
  88. }
  89. /*CMD:speedo(playerid, params[]) {
  90. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) {
  91. SendClientMessageEx(playerid, COLOR_GREY, "You're not driving a vehicle.");
  92. }
  93. else if(!PlayerInfo[playerid][pSpeedo]) {
  94. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled your speedometer.");
  95. PlayerInfo[playerid][pSpeedo] = 1;
  96. if(!FindTimePoints[playerid] && arr_Engine{GetPlayerVehicleID(playerid)} != 0) {
  97. new
  98. szSpeed[42];
  99. format(szSpeed, sizeof(szSpeed),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~%.0f MPH", player_get_speed(playerid));
  100. GameTextForPlayer(playerid, szSpeed, 1500, 3);
  101. }
  102. }
  103. else {
  104. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled your speedometer.");
  105. PlayerInfo[playerid][pSpeedo] = 0;
  106. if(!FindTimePoints[playerid] && arr_Engine{GetPlayerVehicleID(playerid)} != 0) GameTextForPlayer(playerid, " ", 1500, 3);
  107. }
  108. return 1;
  109. } // old speedometer */
  110. CMD:speedopos(playerid, params[])
  111. {
  112. if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER )
  113. {
  114. return SendClientMessageEx(playerid, COLOR_GREY, "You're not driving a vehicle.");
  115. }
  116. if (PlayerInfo[playerid][pSpeedo])
  117. {
  118. new Float: TPosX[2], Float:TPosY[2];
  119. if(!sscanf(params, "ff", TPosX[0], TPosY[0]))
  120. {
  121. if(TPosX[0] < 0 || TPosX[0] > 640)
  122. {
  123. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /speedopos (optional) [X] [Y]");
  124. return SendClientMessageEx(playerid, COLOR_GREY, "X must be above 0 and below 640");
  125. }
  126. if(TPosY[0] < 0 || TPosY[0] > 640)
  127. {
  128. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /speedopos (optional) [X] [Y]");
  129. return SendClientMessageEx(playerid, COLOR_GREY, "Y must be above 0 and below 480");
  130. }
  131. TPosX[1] = TPosX[0] + 60.0;
  132. TPosY[1] = TPosY[0] + 17.0;
  133. }
  134. else
  135. {
  136. switch(GetPVarInt(playerid, "SpeedoPos"))
  137. {
  138. case 0:
  139. {
  140. TPosX[0] = 495.0;
  141. TPosY[0] = 20.0;
  142. TPosX[1] = 555.0;
  143. TPosY[1] = 37.0;
  144. SetPVarInt(playerid, "SpeedoPos", 1);
  145. }
  146. case 1:
  147. {
  148. TPosX[0] = 495.0;
  149. TPosY[0] = 367.0;
  150. TPosX[1] = 555.0;
  151. TPosY[1] = 384.0;
  152. SetPVarInt(playerid, "SpeedoPos", 2);
  153. }
  154. case 2:
  155. {
  156. TPosX[0] = 495.0;
  157. TPosY[0] = 133.0;
  158. TPosX[1] = 555.0;
  159. TPosY[1] = 150.0;
  160. SetPVarInt(playerid, "SpeedoPos", 0);
  161. }
  162. }
  163. }
  164. PlayerTextDrawDestroy(playerid, _vhudTextFuel[playerid]);
  165. _vhudTextFuel[playerid] = CreatePlayerTextDraw(playerid, TPosX[0], TPosY[0], "~b~Fuel: N/A");
  166. PlayerTextDrawBackgroundColor(playerid, _vhudTextFuel[playerid], 255);
  167. PlayerTextDrawFont(playerid, _vhudTextFuel[playerid], 1);
  168. PlayerTextDrawLetterSize(playerid, _vhudTextFuel[playerid], 0.270000, 2.000000);
  169. PlayerTextDrawColor(playerid, _vhudTextFuel[playerid], -1);
  170. PlayerTextDrawSetOutline(playerid, _vhudTextFuel[playerid], 1);
  171. PlayerTextDrawSetProportional(playerid, _vhudTextFuel[playerid], 1);
  172. PlayerTextDrawDestroy(playerid, _vhudTextSpeed[playerid]);
  173. _vhudTextSpeed[playerid] = CreatePlayerTextDraw(playerid, TPosX[1], TPosY[0], "~b~MPH: N/A");
  174. PlayerTextDrawBackgroundColor(playerid, _vhudTextSpeed[playerid], 255);
  175. PlayerTextDrawFont(playerid, _vhudTextSpeed[playerid], 1);
  176. PlayerTextDrawLetterSize(playerid, _vhudTextSpeed[playerid], 0.270000, 2.000000);
  177. PlayerTextDrawColor(playerid, _vhudTextSpeed[playerid], -1);
  178. PlayerTextDrawSetOutline(playerid, _vhudTextSpeed[playerid], 1);
  179. PlayerTextDrawSetProportional(playerid, _vhudTextSpeed[playerid], 1);
  180. PlayerTextDrawDestroy(playerid, _vhudSeatBelt[playerid]);
  181. _vhudSeatBelt[playerid] = CreatePlayerTextDraw(playerid, TPosX[1], TPosY[1], "~b~SB: ~r~OFF");
  182. PlayerTextDrawBackgroundColor(playerid, _vhudSeatBelt[playerid], 255);
  183. PlayerTextDrawFont(playerid, _vhudSeatBelt[playerid], 1);
  184. PlayerTextDrawLetterSize(playerid, _vhudSeatBelt[playerid], 0.270000, 2.000000);
  185. PlayerTextDrawColor(playerid, _vhudSeatBelt[playerid], -1);
  186. PlayerTextDrawSetOutline(playerid, _vhudSeatBelt[playerid], 1);
  187. PlayerTextDrawSetProportional(playerid, _vhudSeatBelt[playerid], 1);
  188. PlayerTextDrawDestroy(playerid, _vhudLights[playerid]);
  189. _vhudLights[playerid] = CreatePlayerTextDraw(playerid, TPosX[0], TPosY[1], "~b~Lights: ~r~OFF");
  190. PlayerTextDrawBackgroundColor(playerid, _vhudLights[playerid], 255);
  191. PlayerTextDrawFont(playerid, _vhudLights[playerid], 1);
  192. PlayerTextDrawLetterSize(playerid, _vhudLights[playerid], 0.270000, 2.000000);
  193. PlayerTextDrawColor(playerid, _vhudLights[playerid], -1);
  194. PlayerTextDrawSetOutline(playerid, _vhudLights[playerid], 1);
  195. PlayerTextDrawSetProportional(playerid, _vhudLights[playerid], 1);
  196. ShowVehicleHUDForPlayer(playerid);
  197. SendClientMessageEx(playerid, COLOR_WHITE, "You have moved the position of your speedometer.");
  198. }
  199. return 1;
  200. }
  201. CMD:speedo(playerid, params[])
  202. {
  203. if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER )
  204. {
  205. SendClientMessageEx(playerid, COLOR_GREY, "You're not driving a vehicle.");
  206. }
  207. else if (!PlayerInfo[playerid][pSpeedo])
  208. {
  209. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled your speedometer.");
  210. PlayerInfo[playerid][pSpeedo] = 1;
  211. ShowVehicleHUDForPlayer(playerid);
  212. }
  213. else
  214. {
  215. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled your speedometer.");
  216. PlayerInfo[playerid][pSpeedo] = 0;
  217. HideVehicleHUDForPlayer(playerid);
  218. }
  219. return 1;
  220. } // new speedometer