Advertisement
Guest User

avtomenitino

a guest
May 18th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.14 KB | None | 0 0
  1. /*
  2. AVTO MENI
  3. */
  4. #include <a_samp>
  5. #include <zcmd>
  6.  
  7. #define MAXIMALNO_PARAMS ( 6 )
  8. #define ZA_DUGME_MENU ( KEY_LOOK_BEHIND ) // na 2ka e staveno mozete da smenite
  9.  
  10. new Text:AvtoPanel[ 10 ], PlayerText:TDavtoto[MAX_PLAYERS];
  11.  
  12. new paramsName[ MAXIMALNO_PARAMS ][ 3 ][] =
  13. {
  14. { "Motor", "On", "Off" },
  15. { "Svetla", "On", "Off" },
  16. { "Alarm", "On", "Off" },
  17. { "", "", "" },// vrata lock
  18. { "Hauba", "Zatvori", "Otvori" },
  19. { "Gepek", "Zatvori", "Otvori" }
  20. };
  21. //----------------------------------------------------------------------------//
  22. public OnFilterScriptInit()
  23. {
  24. AvtoPanel[0] = TextDrawCreate(4.000000, 230.000000, "usebox");
  25. TextDrawBackgroundColor(AvtoPanel[0], 0);
  26. TextDrawFont(AvtoPanel[0], 1);
  27. TextDrawLetterSize(AvtoPanel[0], 0.500000, 9.699998);
  28. TextDrawColor(AvtoPanel[0], 0);
  29. TextDrawSetOutline(AvtoPanel[0], 0);
  30. TextDrawSetProportional(AvtoPanel[0], 1);
  31. TextDrawSetShadow(AvtoPanel[0], 1);
  32. TextDrawUseBox(AvtoPanel[0], 1);
  33. TextDrawBoxColor(AvtoPanel[0], 150);
  34. TextDrawTextSize(AvtoPanel[0], 101.000000, 0.000000);
  35.  
  36. AvtoPanel[1] = TextDrawCreate(5.000000, 232.000000, "ld_dual:white");
  37. TextDrawBackgroundColor(AvtoPanel[1], 255);
  38. TextDrawFont(AvtoPanel[1], 4);
  39. TextDrawLetterSize(AvtoPanel[1], 0.500000, 1.000000);
  40. TextDrawColor(AvtoPanel[1], 252645375);
  41. TextDrawSetOutline(AvtoPanel[1], 0);
  42. TextDrawSetProportional(AvtoPanel[1], 1);
  43. TextDrawSetShadow(AvtoPanel[1], 1);
  44. TextDrawUseBox(AvtoPanel[1], 1);
  45. TextDrawBoxColor(AvtoPanel[1], 255);
  46. TextDrawTextSize(AvtoPanel[1], 95.000000, 12.000000);
  47. TextDrawSetSelectable(AvtoPanel[1], 1);
  48.  
  49. AvtoPanel[2] = TextDrawCreate(5.000000, 246.000000, "ld_dual:white");
  50. TextDrawBackgroundColor(AvtoPanel[2], 255);
  51. TextDrawFont(AvtoPanel[2], 4);
  52. TextDrawLetterSize(AvtoPanel[2], 0.500000, 1.000000);
  53. TextDrawColor(AvtoPanel[2], 252645375);
  54. TextDrawSetOutline(AvtoPanel[2], 0);
  55. TextDrawSetProportional(AvtoPanel[2], 1);
  56. TextDrawSetShadow(AvtoPanel[2], 1);
  57. TextDrawUseBox(AvtoPanel[2], 1);
  58. TextDrawBoxColor(AvtoPanel[2], 255);
  59. TextDrawTextSize(AvtoPanel[2], 95.000000, 12.000000);
  60. TextDrawSetSelectable(AvtoPanel[2], 1);
  61.  
  62. AvtoPanel[3] = TextDrawCreate(5.000000, 260.000000, "ld_dual:white");
  63. TextDrawBackgroundColor(AvtoPanel[3], 255);
  64. TextDrawFont(AvtoPanel[3], 4);
  65. TextDrawLetterSize(AvtoPanel[3], 0.500000, 1.000000);
  66. TextDrawColor(AvtoPanel[3], 252645375);
  67. TextDrawSetOutline(AvtoPanel[3], 0);
  68. TextDrawSetProportional(AvtoPanel[3], 1);
  69. TextDrawSetShadow(AvtoPanel[3], 1);
  70. TextDrawUseBox(AvtoPanel[3], 1);
  71. TextDrawBoxColor(AvtoPanel[3], 255);
  72. TextDrawTextSize(AvtoPanel[3], 95.000000, 12.000000);
  73. TextDrawSetSelectable(AvtoPanel[3], 1);
  74.  
  75. AvtoPanel[5] = TextDrawCreate(5.000000, 288.000000, "ld_dual:white");
  76. TextDrawBackgroundColor(AvtoPanel[5], 255);
  77. TextDrawFont(AvtoPanel[5], 4);
  78. TextDrawLetterSize(AvtoPanel[5], 0.500000, 1.000000);
  79. TextDrawColor(AvtoPanel[5], 252645375);
  80. TextDrawSetOutline(AvtoPanel[5], 0);
  81. TextDrawSetProportional(AvtoPanel[5], 1);
  82. TextDrawSetShadow(AvtoPanel[5], 1);
  83. TextDrawUseBox(AvtoPanel[5], 1);
  84. TextDrawBoxColor(AvtoPanel[5], 255);
  85. TextDrawTextSize(AvtoPanel[5], 95.000000, 12.000000);
  86. TextDrawSetSelectable(AvtoPanel[5], 1);
  87.  
  88. AvtoPanel[6] = TextDrawCreate(5.000000, 302.000000, "ld_dual:white");
  89. TextDrawBackgroundColor(AvtoPanel[6], 255);
  90. TextDrawFont(AvtoPanel[6], 4);
  91. TextDrawLetterSize(AvtoPanel[6], 0.500000, 1.000000);
  92. TextDrawColor(AvtoPanel[6], 252645375);
  93. TextDrawSetOutline(AvtoPanel[6], 0);
  94. TextDrawSetProportional(AvtoPanel[6], 1);
  95. TextDrawSetShadow(AvtoPanel[6], 1);
  96. TextDrawUseBox(AvtoPanel[6], 1);
  97. TextDrawBoxColor(AvtoPanel[6], 255);
  98. TextDrawTextSize(AvtoPanel[6], 95.000000, 12.000000);
  99. TextDrawSetSelectable(AvtoPanel[6], 1);
  100.  
  101. new string[ MAXIMALNO_PARAMS * 25 ];
  102.  
  103. for(new id; id < MAXIMALNO_PARAMS; id++) {
  104. format(string, sizeof string, "%s%s~n~~n~", string, paramsName[ id ][ 0 ]);
  105. }
  106.  
  107. AvtoPanel[7] = TextDrawCreate(7.000000, 234.000000, string);
  108. TextDrawBackgroundColor(AvtoPanel[7], 0);
  109. TextDrawFont(AvtoPanel[7], 1);
  110. TextDrawLetterSize(AvtoPanel[7], 0.189999, 0.783999);
  111. TextDrawColor(AvtoPanel[7], -106);
  112. TextDrawSetOutline(AvtoPanel[7], 0);
  113. TextDrawSetProportional(AvtoPanel[7], 1);
  114. TextDrawSetShadow(AvtoPanel[7], 1);
  115.  
  116. AvtoPanel[8] = TextDrawCreate(104.000000, 228.000000, "ld_dual:white");
  117. TextDrawBackgroundColor(AvtoPanel[8], 255);
  118. TextDrawFont(AvtoPanel[8], 4);
  119. TextDrawLetterSize(AvtoPanel[8], 0.500000, 1.000000);
  120. TextDrawColor(AvtoPanel[8], 252645375);
  121. TextDrawSetOutline(AvtoPanel[8], 0);
  122. TextDrawSetProportional(AvtoPanel[8], 1);
  123. TextDrawSetShadow(AvtoPanel[8], 1);
  124. TextDrawUseBox(AvtoPanel[8], 1);
  125. TextDrawBoxColor(AvtoPanel[8], 255);
  126. TextDrawTextSize(AvtoPanel[8], 9.000000, 91.000000);
  127. TextDrawSetSelectable(AvtoPanel[8], 1);
  128.  
  129. AvtoPanel[9] = TextDrawCreate(104.000000, 268.000000, "~<~");
  130. TextDrawBackgroundColor(AvtoPanel[9], 0);
  131. TextDrawFont(AvtoPanel[9], 2);
  132. TextDrawLetterSize(AvtoPanel[9], 0.159999, 0.983999);
  133. TextDrawColor(AvtoPanel[9], -206);
  134. TextDrawSetOutline(AvtoPanel[9], 0);
  135. TextDrawSetProportional(AvtoPanel[9], 1);
  136. TextDrawSetShadow(AvtoPanel[9], 1);
  137. TextDrawUseBox(AvtoPanel[9], 1);
  138. TextDrawBoxColor(AvtoPanel[9], 0);
  139. TextDrawTextSize(AvtoPanel[9], 101.000000, 10.000000);
  140. return 1;
  141. }
  142. public OnPlayerConnect(playerid)
  143. {
  144. TDavtoto[playerid] = CreatePlayerTextDraw(playerid, 65.000000, 234.000000, "OFF~n~~n~OFF~n~~n~OFF~n~~n~OFF~n~~n~OFF~n~~n~OFF");
  145. PlayerTextDrawBackgroundColor(playerid, TDavtoto[playerid], 0);
  146. PlayerTextDrawFont(playerid, TDavtoto[playerid], 2);
  147. PlayerTextDrawLetterSize(playerid, TDavtoto[playerid], 0.149999, 0.783999);
  148. PlayerTextDrawColor(playerid, TDavtoto[playerid], -206);
  149. PlayerTextDrawSetOutline(playerid, TDavtoto[playerid], 0);
  150. PlayerTextDrawSetProportional(playerid, TDavtoto[playerid], 1);
  151. PlayerTextDrawSetShadow(playerid, TDavtoto[playerid], 1);
  152. return 1;
  153. }
  154. stock ShowTextDrawsPanel(playerid)
  155. {
  156. if (GetPVarInt(playerid, "p_Panel"))
  157. return 0;
  158.  
  159. for(new textdraw; textdraw < sizeof AvtoPanel; textdraw++)
  160. TextDrawShowForPlayer(playerid, AvtoPanel[textdraw]);
  161.  
  162. new
  163. p_vehid = GetPlayerVehicleID(playerid);
  164.  
  165. FixUnsetParameters(p_vehid);
  166.  
  167. UpdatePlayerVehicleParams(playerid);
  168.  
  169. PlayerTextDrawShow(playerid, TDavtoto[playerid]);
  170.  
  171. SelectTextDraw(playerid, 0x222222FF);
  172.  
  173. SetPVarInt(playerid, "p_panel", 1);
  174. return 1;
  175. }
  176. stock HideTextDrawsPanel(playerid)
  177. {
  178. if (!GetPVarInt(playerid, "p_Panel"))
  179. return 0;
  180.  
  181. for(new textdraw; textdraw < sizeof AvtoPanel; textdraw++)
  182. TextDrawHideForPlayer(playerid, AvtoPanel[textdraw]);
  183.  
  184. PlayerTextDrawHide(playerid, TDavtoto[playerid]);
  185.  
  186. CancelSelectTextDraw(playerid);
  187.  
  188. DeletePVar(playerid, "p_panel");
  189. return 1;
  190. }
  191. stock UpdatePlayerVehicleParams(playerid)
  192. {
  193. new p_vehparams[ MAXIMALNO_PARAMS + 1 ];
  194. new p_vehid = GetPlayerVehicleID(playerid);
  195.  
  196. GetVehicleParams(p_vehid, p_vehparams);
  197.  
  198. new string[ MAXIMALNO_PARAMS * 25 ];
  199.  
  200. for(new params; params < MAXIMALNO_PARAMS; params++) {
  201. format(string, sizeof string, "%s%s~n~ ~n~", string, p_vehparams[params] ? paramsName[params][ 1 ] : paramsName[params][ 2 ]);
  202. }
  203. PlayerTextDrawSetString(playerid, TDavtoto[playerid], string);
  204. }
  205. stock UpdateVehicleParams(playerid, param)
  206. {
  207. if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
  208. return 0;
  209.  
  210. new p_vehparams[ MAXIMALNO_PARAMS + 1 ];
  211. new p_vehid = GetPlayerVehicleID(playerid);
  212.  
  213. GetVehicleParams(p_vehid, p_vehparams);
  214.  
  215. p_vehparams[param] = p_vehparams[param] ? 0 : 1;
  216.  
  217. SetVehicleParamsEx(p_vehid, p_vehparams[ 0 ], p_vehparams[ 1 ], p_vehparams[ 2 ], p_vehparams[ 3 ], p_vehparams[ 4 ], p_vehparams[ 5 ], p_vehparams[ 6 ]);
  218.  
  219. UpdatePlayerVehicleParams(playerid);
  220.  
  221. if (param == 3) PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  222. return 1;
  223. }
  224. stock GetVehicleParams(vehicleid, params[ MAXIMALNO_PARAMS + 1 ])
  225. {
  226. GetVehicleParamsEx(vehicleid, params[ 0 ], params[ 1 ], params[ 2 ], params[ 3 ], params[ 4 ], params[ 5 ], params[ 6 ]);
  227. }
  228. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  229. {
  230. if (newkeys & ZA_DUGME_MENU && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  231. {
  232. ShowTextDrawsPanel(playerid);
  233. }
  234. return 1;
  235. }
  236. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  237. {
  238. if (GetPVarInt(playerid, "p_panel"))
  239. {
  240. if (clickedid == AvtoPanel[ 8 ] || clickedid == Text:INVALID_TEXT_DRAW)
  241. {
  242. HideTextDrawsPanel(playerid);
  243. return 1;
  244. }
  245.  
  246. new id = MAXIMALNO_PARAMS;
  247. while(id--)
  248. {
  249. if (clickedid == AvtoPanel[ id + 1 ])
  250. {
  251. UpdateVehicleParams(playerid, id);
  252. break;
  253. }
  254. }
  255. }
  256. return 1;
  257. }
  258. stock FixUnsetParameters(vehicleid)
  259. {
  260. new params[ 7 ];
  261. GetVehicleParamsEx(vehicleid, params[ 0 ], params[ 1 ], params[ 2 ], params[ 3 ], params[ 4 ], params[ 5 ], params[6 ]);
  262. SetVehicleParamsEx(vehicleid,
  263. params[ 0 ] < 0 ? 1 : params[ 0 ], // Motor
  264. params[ 1 ] < 0 ? 0 : params[ 1 ], // Svetla
  265. params[ 2 ] < 0 ? 0 : params[ 2 ], // Alarm
  266. params[ 3 ] < 0 ? 0 : params[ 3 ], // Vrata trgnato
  267. params[ 4 ] < 0 ? 0 : params[ 4 ], // Hauba
  268. params[ 5 ] < 0 ? 0 : params[ 5 ], // Gepek
  269. params[ 6 ]); //
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement