Advertisement
Guest User

ColorPicker v1.1

a guest
Jan 25th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.56 KB | None | 0 0
  1. /*
  2. [INC] ColorPicker v 1.1 by Maku
  3. Created at 30-04-2013
  4. Last modify: 1-05-2013
  5. */
  6. /*
  7. native ShowPlayerColorPicker(playerid, pickerid, bool:showalpha = false, bool:showcancel = true);
  8. native HidePlayerColorPicker(playerid, bool:call_callback = false, call_response = 0);
  9. native
  10. native OnColorPickerResponse(playerid, pickerid, color, response);
  11. */
  12.  
  13. #if defined _colorpicker_included
  14. #endinput
  15. #endif
  16. #define _colorpicker_included
  17.  
  18. #include a_samp.inc
  19.  
  20. static Text:cp_Draw[16];
  21. static PlayerText:cp_playerDraw[MAX_PLAYERS][5];
  22. static ChooseColor[MAX_PLAYERS][8];
  23.  
  24. forward OnColorPickerResponse(playerid, pickerid, color, response);
  25.  
  26. #define COLOR_PICKER_RED 0
  27. #define COLOR_PICKER_GREEN 1
  28. #define COLOR_PICKER_BLUE 2
  29. #define COLOR_PICKER_ALPHA 3
  30. #define COLOR_PICKER_ID 4
  31. #define COLOR_PICKER_ALPHA_ENABLE 5
  32. #define COLOR_PICKER_DIALOG_OPTION 6
  33. #define COLOR_PICKER_DIALOG_SHOW 7
  34.  
  35. #if !defined COLOR_PICKER_DIALOG_ID
  36. #define COLOR_PICKER_DIALOG_ID (32766)
  37. #endif
  38.  
  39. #define RGBAToHex(%0,%1,%2,%3) (%0<<24 | %1<<16 | %2<<8 | %3)
  40.  
  41. LoadColorPicker()
  42. {
  43. print("\n+-----------------------------------------+");
  44. print( "| [INC] ColorPicker v1.0 by Maku - Loaded |");
  45. print( "+-----------------------------------------+\n");
  46.  
  47. for(new i = GetMaxPlayers(); i >= 0; --i)
  48. {
  49. if(IsPlayerConnected(i))
  50. {
  51. LoadColorPickerForPlayer(i);
  52. }
  53. }
  54.  
  55. cp_Draw[0] = TextDrawCreate(310.000000, 150.000000, "_");
  56. TextDrawAlignment(cp_Draw[0], 2);
  57. TextDrawBackgroundColor(cp_Draw[0], 255);
  58. TextDrawFont(cp_Draw[0], 1);
  59. TextDrawLetterSize(cp_Draw[0], 0.500000, 13.000000);
  60. TextDrawColor(cp_Draw[0], -1);
  61. TextDrawSetOutline(cp_Draw[0], 0);
  62. TextDrawSetProportional(cp_Draw[0], 1);
  63. TextDrawSetShadow(cp_Draw[0], 1);
  64. TextDrawUseBox(cp_Draw[0], 1);
  65. TextDrawBoxColor(cp_Draw[0], 68);
  66. TextDrawTextSize(cp_Draw[0], 30.000000, 250.000000);
  67.  
  68. cp_Draw[1] = TextDrawCreate(259.000000, 149.000000, "Color~h~Picker");
  69. TextDrawBackgroundColor(cp_Draw[1], 85);
  70. TextDrawFont(cp_Draw[1], 3);
  71. TextDrawLetterSize(cp_Draw[1], 0.500000, 1.799998);
  72. TextDrawColor(cp_Draw[1], -5635858);
  73. TextDrawSetOutline(cp_Draw[1], 1);
  74. TextDrawSetProportional(cp_Draw[1], 1);
  75.  
  76. cp_Draw[2] = TextDrawCreate(363.000000, 174.000000, "Created color:");
  77. TextDrawBackgroundColor(cp_Draw[2], 68);
  78. TextDrawFont(cp_Draw[2], 1);
  79. TextDrawLetterSize(cp_Draw[2], 0.200000, 1.000000);
  80. TextDrawColor(cp_Draw[2], -1);
  81. TextDrawSetOutline(cp_Draw[2], 1);
  82. TextDrawSetProportional(cp_Draw[2], 1);
  83.  
  84. cp_Draw[3] = TextDrawCreate(225.000000, 180.000000, "~r~~h~RED~n~_~n~~g~~h~GREEN~n~_~n~~b~~h~BLUE~n~_~n~~w~ALPHA~n~_");
  85. TextDrawAlignment(cp_Draw[3], 3);
  86. TextDrawBackgroundColor(cp_Draw[3], 255);
  87. TextDrawFont(cp_Draw[3], 3);
  88. TextDrawLetterSize(cp_Draw[3], 0.429998, 1.100000);
  89. TextDrawColor(cp_Draw[3], -1);
  90. TextDrawSetOutline(cp_Draw[3], 0);
  91. TextDrawSetProportional(cp_Draw[3], 1);
  92. TextDrawSetShadow(cp_Draw[3], 1);
  93.  
  94. cp_Draw[4] = TextDrawCreate(146.000000, 195.000000, "'~n~~n~~n~~n~'~n~~n~~n~~n~'");
  95. TextDrawBackgroundColor(cp_Draw[4], 255);
  96. TextDrawFont(cp_Draw[4], 0);
  97. TextDrawLetterSize(cp_Draw[4], 25.000000, 0.500000);
  98. TextDrawColor(cp_Draw[4], -5635858);
  99. TextDrawSetOutline(cp_Draw[4], 0);
  100. TextDrawSetProportional(cp_Draw[4], 1);
  101. TextDrawSetShadow(cp_Draw[4], 1);
  102.  
  103. cp_Draw[5] = TextDrawCreate(259.000000, 175.000000, "<-");
  104. TextDrawAlignment(cp_Draw[5], 2);
  105. TextDrawBackgroundColor(cp_Draw[5], 255);
  106. TextDrawFont(cp_Draw[5], 0);
  107. TextDrawLetterSize(cp_Draw[5], 0.319999, 1.799998);
  108. TextDrawColor(cp_Draw[5], -1);
  109. TextDrawSetOutline(cp_Draw[5], 0);
  110. TextDrawSetProportional(cp_Draw[5], 1);
  111. TextDrawSetShadow(cp_Draw[5], 1);
  112. TextDrawUseBox(cp_Draw[5], 1);
  113. TextDrawBoxColor(cp_Draw[5], 85);
  114. TextDrawTextSize(cp_Draw[5], 15.000000, 15.000000);
  115. TextDrawSetSelectable(cp_Draw[5], true);
  116.  
  117. cp_Draw[6] = TextDrawCreate(259.000000, 196.000000, "<-");
  118. TextDrawAlignment(cp_Draw[6], 2);
  119. TextDrawBackgroundColor(cp_Draw[6], 255);
  120. TextDrawFont(cp_Draw[6], 0);
  121. TextDrawLetterSize(cp_Draw[6], 0.319999, 1.799998);
  122. TextDrawColor(cp_Draw[6], -1);
  123. TextDrawSetOutline(cp_Draw[6], 0);
  124. TextDrawSetProportional(cp_Draw[6], 1);
  125. TextDrawSetShadow(cp_Draw[6], 1);
  126. TextDrawUseBox(cp_Draw[6], 1);
  127. TextDrawBoxColor(cp_Draw[6], 85);
  128. TextDrawTextSize(cp_Draw[6], 15.000000, 15.000000);
  129. TextDrawSetSelectable(cp_Draw[6], true);
  130.  
  131. cp_Draw[7] = TextDrawCreate(259.000000, 216.000000, "<-");
  132. TextDrawAlignment(cp_Draw[7], 2);
  133. TextDrawBackgroundColor(cp_Draw[7], 255);
  134. TextDrawFont(cp_Draw[7], 0);
  135. TextDrawLetterSize(cp_Draw[7], 0.319999, 1.799998);
  136. TextDrawColor(cp_Draw[7], -1);
  137. TextDrawSetOutline(cp_Draw[7], 0);
  138. TextDrawSetProportional(cp_Draw[7], 1);
  139. TextDrawSetShadow(cp_Draw[7], 1);
  140. TextDrawUseBox(cp_Draw[7], 1);
  141. TextDrawBoxColor(cp_Draw[7], 85);
  142. TextDrawTextSize(cp_Draw[7], 15.000000, 15.000000);
  143. TextDrawSetSelectable(cp_Draw[7], true);
  144.  
  145. cp_Draw[8] = TextDrawCreate(259.000000, 237.000000, "<-");
  146. TextDrawAlignment(cp_Draw[8], 2);
  147. TextDrawBackgroundColor(cp_Draw[8], 255);
  148. TextDrawFont(cp_Draw[8], 0);
  149. TextDrawLetterSize(cp_Draw[8], 0.319999, 1.799998);
  150. TextDrawColor(cp_Draw[8], -1);
  151. TextDrawSetOutline(cp_Draw[8], 0);
  152. TextDrawSetProportional(cp_Draw[8], 1);
  153. TextDrawSetShadow(cp_Draw[8], 1);
  154. TextDrawUseBox(cp_Draw[8], 1);
  155. TextDrawBoxColor(cp_Draw[8], 85);
  156. TextDrawTextSize(cp_Draw[8], 15.000000, 15.000000);
  157. TextDrawSetSelectable(cp_Draw[8], true);
  158.  
  159. cp_Draw[9] = TextDrawCreate(316.000000, 175.000000, "->");
  160. TextDrawAlignment(cp_Draw[9], 2);
  161. TextDrawBackgroundColor(cp_Draw[9], 255);
  162. TextDrawFont(cp_Draw[9], 0);
  163. TextDrawLetterSize(cp_Draw[9], 0.319999, 1.799998);
  164. TextDrawColor(cp_Draw[9], -1);
  165. TextDrawSetOutline(cp_Draw[9], 0);
  166. TextDrawSetProportional(cp_Draw[9], 1);
  167. TextDrawSetShadow(cp_Draw[9], 1);
  168. TextDrawUseBox(cp_Draw[9], 1);
  169. TextDrawBoxColor(cp_Draw[9], 85);
  170. TextDrawTextSize(cp_Draw[9], 15.000000, 15.000000);
  171. TextDrawSetSelectable(cp_Draw[9], true);
  172.  
  173. cp_Draw[10] = TextDrawCreate(316.000000, 195.000000, "->");
  174. TextDrawAlignment(cp_Draw[10], 2);
  175. TextDrawBackgroundColor(cp_Draw[10], 255);
  176. TextDrawFont(cp_Draw[10], 0);
  177. TextDrawLetterSize(cp_Draw[10], 0.319999, 1.799998);
  178. TextDrawColor(cp_Draw[10], -1);
  179. TextDrawSetOutline(cp_Draw[10], 0);
  180. TextDrawSetProportional(cp_Draw[10], 1);
  181. TextDrawSetShadow(cp_Draw[10], 1);
  182. TextDrawUseBox(cp_Draw[10], 1);
  183. TextDrawBoxColor(cp_Draw[10], 85);
  184. TextDrawTextSize(cp_Draw[10], 15.000000, 15.000000);
  185. TextDrawSetSelectable(cp_Draw[10], true);
  186.  
  187. cp_Draw[11] = TextDrawCreate(316.000000, 216.000000, "->");
  188. TextDrawAlignment(cp_Draw[11], 2);
  189. TextDrawBackgroundColor(cp_Draw[11], 255);
  190. TextDrawFont(cp_Draw[11], 0);
  191. TextDrawLetterSize(cp_Draw[11], 0.319999, 1.799998);
  192. TextDrawColor(cp_Draw[11], -1);
  193. TextDrawSetOutline(cp_Draw[11], 0);
  194. TextDrawSetProportional(cp_Draw[11], 1);
  195. TextDrawSetShadow(cp_Draw[11], 1);
  196. TextDrawUseBox(cp_Draw[11], 1);
  197. TextDrawBoxColor(cp_Draw[11], 85);
  198. TextDrawTextSize(cp_Draw[11], 15.000000, 15.000000);
  199. TextDrawSetSelectable(cp_Draw[11], true);
  200.  
  201. cp_Draw[12] = TextDrawCreate(316.000000, 237.000000, "->");
  202. TextDrawAlignment(cp_Draw[12], 2);
  203. TextDrawBackgroundColor(cp_Draw[12], 255);
  204. TextDrawFont(cp_Draw[12], 0);
  205. TextDrawLetterSize(cp_Draw[12], 0.319999, 1.799998);
  206. TextDrawColor(cp_Draw[12], -1);
  207. TextDrawSetOutline(cp_Draw[12], 0);
  208. TextDrawSetProportional(cp_Draw[12], 1);
  209. TextDrawSetShadow(cp_Draw[12], 1);
  210. TextDrawUseBox(cp_Draw[12], 1);
  211. TextDrawBoxColor(cp_Draw[12], 85);
  212. TextDrawTextSize(cp_Draw[12], 15.000000, 15.000000);
  213. TextDrawSetSelectable(cp_Draw[12], true);
  214.  
  215. cp_Draw[13] = TextDrawCreate(414.000000, 255.000000, "OK");
  216. TextDrawAlignment(cp_Draw[13], 2);
  217. TextDrawBackgroundColor(cp_Draw[13], 85);
  218. TextDrawFont(cp_Draw[13], 1);
  219. TextDrawLetterSize(cp_Draw[13], 0.310000, 1.000000);
  220. TextDrawColor(cp_Draw[13], -1);
  221. TextDrawSetOutline(cp_Draw[13], 1);
  222. TextDrawSetProportional(cp_Draw[13], 1);
  223. TextDrawUseBox(cp_Draw[13], 1);
  224. TextDrawBoxColor(cp_Draw[13], 85);
  225. TextDrawTextSize(cp_Draw[13], 15.000000, 34.000000);
  226. TextDrawSetSelectable(cp_Draw[13], true);
  227.  
  228. cp_Draw[14] = TextDrawCreate(429.000000, 150.000000, "X");
  229. TextDrawAlignment(cp_Draw[14], 2);
  230. TextDrawBackgroundColor(cp_Draw[14], 51);
  231. TextDrawFont(cp_Draw[14], 2);
  232. TextDrawLetterSize(cp_Draw[14], 0.270000, 0.899999);
  233. TextDrawColor(cp_Draw[14], -1);
  234. TextDrawSetOutline(cp_Draw[14], 1);
  235. TextDrawSetProportional(cp_Draw[14], 1);
  236. TextDrawUseBox(cp_Draw[14], 1);
  237. TextDrawBoxColor(cp_Draw[14], 102);
  238. TextDrawTextSize(cp_Draw[14], 10.000000, 10.000000);
  239. TextDrawSetSelectable(cp_Draw[14], true);
  240.  
  241. cp_Draw[15] = TextDrawCreate(225.000000, 180.000000, "~r~~h~RED~n~_~n~~g~~h~GREEN~n~_~n~~b~~h~BLUE~n~_");
  242. TextDrawAlignment(cp_Draw[15], 3);
  243. TextDrawBackgroundColor(cp_Draw[15], 255);
  244. TextDrawFont(cp_Draw[15], 3);
  245. TextDrawLetterSize(cp_Draw[15], 0.429998, 1.100000);
  246. TextDrawColor(cp_Draw[15], -1);
  247. TextDrawSetOutline(cp_Draw[15], 0);
  248. TextDrawSetProportional(cp_Draw[15], 1);
  249. TextDrawSetShadow(cp_Draw[15], 1);
  250. return 1;
  251. }
  252.  
  253. UnLoadColorPicker()
  254. {
  255. for(new i = GetMaxPlayers(); i >= 0; --i)
  256. {
  257. if(IsPlayerConnected(i))
  258. {
  259. HidePlayerColorPicker(i);
  260. PlayerTextDrawDestroy(i, cp_playerDraw[i][0]);
  261. PlayerTextDrawDestroy(i, cp_playerDraw[i][1]);
  262. PlayerTextDrawDestroy(i, cp_playerDraw[i][2]);
  263. PlayerTextDrawDestroy(i, cp_playerDraw[i][3]);
  264. PlayerTextDrawDestroy(i, cp_playerDraw[i][4]);
  265. }
  266. }
  267.  
  268. for(new i; i < sizeof cp_Draw; i++)
  269. {
  270. TextDrawDestroy(cp_Draw[i]);
  271. }
  272. return 1;
  273. }
  274.  
  275. LoadColorPickerForPlayer(playerid)
  276. {
  277. ChooseColor[playerid][COLOR_PICKER_ID] = -1;
  278.  
  279. cp_playerDraw[playerid][0] = CreatePlayerTextDraw(playerid, 393.000000, 189.000000, "_");
  280. PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][0], 2);
  281. PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][0], 255);
  282. PlayerTextDrawFont(playerid, cp_playerDraw[playerid][0], 1);
  283. PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][0], 0.500000, 6.000000);
  284. PlayerTextDrawColor(playerid, cp_playerDraw[playerid][0], -1);
  285. PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][0], 0);
  286. PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][0], 1);
  287. PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][0], 1);
  288. PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][0], 1);
  289. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][0], 11206655);
  290. PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][0], 0.000000, 61.000000);
  291.  
  292. cp_playerDraw[playerid][1] = CreatePlayerTextDraw(playerid, 288.000000, 179.000000, "255");
  293. PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][1], 2);
  294. PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][1], 255);
  295. PlayerTextDrawFont(playerid, cp_playerDraw[playerid][1], 3);
  296. PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][1], 0.500000, 1.100000);
  297. PlayerTextDrawColor(playerid, cp_playerDraw[playerid][1], -1);
  298. PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][1], 0);
  299. PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][1], 1);
  300. PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][1], 1);
  301. PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][1], 1);
  302. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][1], 17);
  303. PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][1], 10.000000, 30.000000);
  304. PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][1], 1);
  305.  
  306. cp_playerDraw[playerid][2] = CreatePlayerTextDraw(playerid, 288.000000, 200.000000, "255");
  307. PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][2], 2);
  308. PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][2], 255);
  309. PlayerTextDrawFont(playerid, cp_playerDraw[playerid][2], 3);
  310. PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][2], 0.500000, 1.100000);
  311. PlayerTextDrawColor(playerid, cp_playerDraw[playerid][2], -1);
  312. PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][2], 0);
  313. PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][2], 1);
  314. PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][2], 1);
  315. PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][2], 1);
  316. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][2], 17);
  317. PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][2], 10.000000, 30.000000);
  318. PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][2], 1);
  319.  
  320. cp_playerDraw[playerid][3] = CreatePlayerTextDraw(playerid, 288.000000, 218.000000, "255");
  321. PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][3], 2);
  322. PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][3], 255);
  323. PlayerTextDrawFont(playerid, cp_playerDraw[playerid][3], 3);
  324. PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][3], 0.500000, 1.100000);
  325. PlayerTextDrawColor(playerid, cp_playerDraw[playerid][3], -1);
  326. PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][3], 0);
  327. PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][3], 1);
  328. PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][3], 1);
  329. PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][3], 1);
  330. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][3], 17);
  331. PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][3], 10.000000, 30.000000);
  332. PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][3], 1);
  333.  
  334. cp_playerDraw[playerid][4] = CreatePlayerTextDraw(playerid, 288.000000, 240.000000, "255");
  335. PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][4], 2);
  336. PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][4], 255);
  337. PlayerTextDrawFont(playerid, cp_playerDraw[playerid][4], 3);
  338. PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][4], 0.500000, 1.100000);
  339. PlayerTextDrawColor(playerid, cp_playerDraw[playerid][4], -1);
  340. PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][4], 0);
  341. PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][4], 1);
  342. PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][4], 1);
  343. PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][4], 1);
  344. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][4], 17);
  345. PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][4], 10.000000, 30.000000);
  346. PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][4], 1);
  347. return 1;
  348. }
  349.  
  350. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  351. {
  352. if((newkeys & 16) && ChooseColor[playerid][COLOR_PICKER_ID] != -1)
  353. {
  354. HidePlayerColorPicker(playerid, true, 1);
  355. }
  356. CallLocalFunction("CP_OnPlayerKeyStateChange", "ddd", playerid, newkeys, oldkeys);
  357. return 1;
  358. }
  359. #if defined _ALS_OnPlayerKeyStateChange
  360. #undef OnPlayerKeyStateChange
  361. #else
  362. #define _ALS_OnPlayerKeyStateChange
  363. #endif
  364. #define OnPlayerKeyStateChange CP_OnPlayerKeyStateChange
  365. forward CP_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  366.  
  367. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  368. {
  369. if(dialogid == COLOR_PICKER_DIALOG_ID && ChooseColor[playerid][COLOR_PICKER_ID] != -1)
  370. {
  371. if(response)
  372. {
  373. if(strlen(inputtext) > 0 && strval(inputtext) >= 0 && strval(inputtext) <= 255)
  374. {
  375. switch(ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION])
  376. {
  377. case 0: ChooseColor[playerid][COLOR_PICKER_RED] = strval(inputtext);
  378. case 1: ChooseColor[playerid][COLOR_PICKER_GREEN] = strval(inputtext);
  379. case 2: ChooseColor[playerid][COLOR_PICKER_BLUE] = strval(inputtext);
  380. case 3: ChooseColor[playerid][COLOR_PICKER_ALPHA] = strval(inputtext);
  381. }
  382. ColorPicker_RefreshColor(playerid, ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE]);
  383. ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
  384. SelectTextDraw(playerid, 0x00AAFFFF);
  385. }
  386. else
  387. {
  388. ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 1;
  389. CancelSelectTextDraw(playerid);
  390. ShowPlayerDialog(playerid, COLOR_PICKER_DIALOG_ID, DIALOG_STYLE_INPUT, "ColorPicker v1.1 by Maku", "{FFFFFF}Wpisz wartość tego parametru:\n\n{CCCCCC}Od 0 do 255\n\n{FF0000}Wprowadzono nieprawidłową liczbe", "OK", "Anuluj");
  391. }
  392. }
  393. else
  394. {
  395. ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
  396. SelectTextDraw(playerid, 0x00AAFFFF);
  397. }
  398. }
  399. CallLocalFunction("CP_OnDialogResponse", "dddds", playerid, dialogid, response, listitem, inputtext);
  400. return 1;
  401. }
  402.  
  403. #if defined _ALS_OnDialogResponse
  404. #undef OnDialogResponse
  405. #else
  406. #define _ALS_OnDialogResponse
  407. #endif
  408. #define OnDialogResponse CP_OnDialogResponse
  409. forward CP_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
  410.  
  411.  
  412. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  413. {
  414. if(ChooseColor[playerid][COLOR_PICKER_ID] != -1 && ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] == 0)
  415. {
  416. if(playertextid == cp_playerDraw[playerid][1]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 0;
  417. if(playertextid == cp_playerDraw[playerid][2]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 1;
  418. if(playertextid == cp_playerDraw[playerid][3]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 2;
  419. if(playertextid == cp_playerDraw[playerid][4]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 3;
  420.  
  421. ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 1;
  422. CancelSelectTextDraw(playerid);
  423. ShowPlayerDialog(playerid, COLOR_PICKER_DIALOG_ID, DIALOG_STYLE_INPUT, "ColorPicker v1.1 by Maku", "{FFFFFF}Wpisz wartość tego parametru:\n\n{CCCCCC}Od 0 do 255", "Wprowadz", "Anuluj");
  424. }
  425. CallLocalFunction("CP_OnPlayerClickPlayerTextDraw", "dd", playerid, _:playertextid);
  426. return 1;
  427. }
  428. #if defined _H_OnPlayerClickPlayerTextDraw
  429. #undef OnPlayerClickPlayerTextDraw
  430. #else
  431. #define _H_OnPlayerClickPlayerTextDraw
  432. #endif
  433. #define OnPlayerClickPlayerTextDraw CP_OnPlayerClickPlayerTextDraw
  434. forward CP_OnPlayerClickPlayerTextDraw(playerid, _:playertextid);
  435.  
  436. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  437. {
  438. if(ChooseColor[playerid][COLOR_PICKER_ID] != -1)
  439. {
  440. if(clickedid == cp_Draw[14] || clickedid == Text:INVALID_TEXT_DRAW && ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] == 0) //Anuluj
  441. {
  442. HidePlayerColorPicker(playerid, true, 0);
  443. }
  444. else if(clickedid == cp_Draw[13]) //Ok
  445. {
  446. HidePlayerColorPicker(playerid, true, 1);
  447. }
  448. else
  449. {
  450. if(clickedid == cp_Draw[5]) ChooseColor[playerid][COLOR_PICKER_RED] -= 5;
  451. if(clickedid == cp_Draw[6]) ChooseColor[playerid][COLOR_PICKER_GREEN] -= 5;
  452. if(clickedid == cp_Draw[7]) ChooseColor[playerid][COLOR_PICKER_BLUE] -= 5;
  453. if(clickedid == cp_Draw[8]) ChooseColor[playerid][COLOR_PICKER_ALPHA] -= 5;
  454. if(clickedid == cp_Draw[9]) ChooseColor[playerid][COLOR_PICKER_RED] += 5;
  455. if(clickedid == cp_Draw[10]) ChooseColor[playerid][COLOR_PICKER_GREEN] += 5;
  456. if(clickedid == cp_Draw[11]) ChooseColor[playerid][COLOR_PICKER_BLUE] += 5;
  457. if(clickedid == cp_Draw[12]) ChooseColor[playerid][COLOR_PICKER_ALPHA] += 5;
  458.  
  459. ColorPicker_RefreshColor(playerid, ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE]);
  460. }
  461. }
  462. CallLocalFunction("CP_OnPlayerClickTextDraw", "dd", playerid, _:clickedid);
  463. return 1;
  464. }
  465. #if defined _ALS_OnPlayerClickTextDraw
  466. #undef OnPlayerClickTextDraw
  467. #else
  468. #define _ALS_OnPlayerClickTextDraw
  469. #endif
  470. #define OnPlayerClickTextDraw CP_OnPlayerClickTextDraw
  471. forward CP_OnPlayerClickTextDraw(playerid, _:clickedid);
  472.  
  473.  
  474. stock HidePlayerColorPicker(playerid, bool:call_callback = false, call_response = 0)
  475. {
  476. for(new i; i < sizeof cp_Draw; i++)
  477. {
  478. TextDrawHideForPlayer(playerid, cp_Draw[i]);
  479. }
  480. if(call_callback == true)
  481. {
  482. new color = RGBAToHex(ChooseColor[playerid][COLOR_PICKER_RED],ChooseColor[playerid][COLOR_PICKER_GREEN],ChooseColor[playerid][COLOR_PICKER_BLUE],ChooseColor[playerid][COLOR_PICKER_ALPHA]);
  483. CallRemoteFunction("OnColorPickerResponse", "dddd", playerid, ChooseColor[playerid][COLOR_PICKER_ID], color, call_response);
  484. }
  485. ChooseColor[playerid][COLOR_PICKER_ID] = -1;
  486. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][0]);
  487. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][1]);
  488. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][2]);
  489. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][3]);
  490. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][4]);
  491. CancelSelectTextDraw(playerid);
  492. return 1;
  493. }
  494.  
  495. stock ShowPlayerColorPicker(playerid, pickerid, bool:showalpha = false, bool:showcancel = true)
  496. {
  497. ChooseColor[playerid][COLOR_PICKER_ID] = pickerid;
  498. ChooseColor[playerid][COLOR_PICKER_RED] = 155;
  499. ChooseColor[playerid][COLOR_PICKER_GREEN] = 155;
  500. ChooseColor[playerid][COLOR_PICKER_BLUE] = 155;
  501. ChooseColor[playerid][COLOR_PICKER_ALPHA] = 255;
  502. ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE] = showalpha;
  503. ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
  504.  
  505. for(new i; i < sizeof cp_Draw; i++)
  506. {
  507. if(i == 15 && showalpha == true) continue;
  508. if(i == 3 && showalpha == false) continue;
  509. if(i == 8 && showalpha == false) continue;
  510. if(i == 12 && showalpha == false) continue;
  511. if(i == 14 && showcancel == false) continue;
  512.  
  513. TextDrawShowForPlayer(playerid, cp_Draw[i]);
  514. }
  515.  
  516. ColorPicker_RefreshColor(playerid, showalpha);
  517. SelectTextDraw(playerid, 0x00AAFFFF);
  518. return 1;
  519. }
  520.  
  521. stock ColorPicker_RefreshColor(playerid, showalpha)
  522. {
  523. if(ChooseColor[playerid][COLOR_PICKER_RED] > 255) ChooseColor[playerid][COLOR_PICKER_RED] = 0;
  524. if(ChooseColor[playerid][COLOR_PICKER_RED] < 0) ChooseColor[playerid][COLOR_PICKER_RED] = 255;
  525.  
  526. if(ChooseColor[playerid][COLOR_PICKER_GREEN] > 255) ChooseColor[playerid][COLOR_PICKER_GREEN] = 0;
  527. if(ChooseColor[playerid][COLOR_PICKER_GREEN] < 0) ChooseColor[playerid][COLOR_PICKER_GREEN] = 255;
  528.  
  529. if(ChooseColor[playerid][COLOR_PICKER_BLUE] > 255) ChooseColor[playerid][COLOR_PICKER_BLUE] = 0;
  530. if(ChooseColor[playerid][COLOR_PICKER_BLUE] < 0) ChooseColor[playerid][COLOR_PICKER_BLUE] = 255;
  531.  
  532. if(ChooseColor[playerid][COLOR_PICKER_ALPHA] > 255) ChooseColor[playerid][COLOR_PICKER_ALPHA] = 0;
  533. if(ChooseColor[playerid][COLOR_PICKER_ALPHA] < 0) ChooseColor[playerid][COLOR_PICKER_ALPHA] = 255;
  534.  
  535. new color = RGBAToHex(ChooseColor[playerid][COLOR_PICKER_RED],ChooseColor[playerid][COLOR_PICKER_GREEN],ChooseColor[playerid][COLOR_PICKER_BLUE],ChooseColor[playerid][COLOR_PICKER_ALPHA]);
  536. PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][0], color);
  537. PlayerTextDrawShow(playerid, cp_playerDraw[playerid][0]);
  538.  
  539. new cp_str[8];
  540. valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_RED]);
  541. PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][1], cp_str);
  542. PlayerTextDrawShow(playerid, cp_playerDraw[playerid][1]);
  543.  
  544. valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_GREEN]);
  545. PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][2], cp_str);
  546. PlayerTextDrawShow(playerid, cp_playerDraw[playerid][2]);
  547.  
  548. valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_BLUE]);
  549. PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][3], cp_str);
  550. PlayerTextDrawShow(playerid, cp_playerDraw[playerid][3]);
  551. if(showalpha)
  552. {
  553. valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_ALPHA]);
  554. PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][4], cp_str);
  555. PlayerTextDrawShow(playerid, cp_playerDraw[playerid][4]);
  556. }
  557. else
  558. {
  559. PlayerTextDrawHide(playerid, cp_playerDraw[playerid][4]);
  560. }
  561. return 1;
  562. }
  563.  
  564. public OnPlayerConnect(playerid)
  565. {
  566. LoadColorPickerForPlayer(playerid);
  567. CallLocalFunction("ColorPicker_OnPlayerConnect", "d", playerid);
  568. return 1;
  569. }
  570. #if defined _ALS_OnPlayerConnect
  571. #undef OnPlayerConnect
  572. #else
  573. #define _ALS_OnPlayerConnect
  574. #endif
  575. #define OnPlayerConnect ColorPicker_OnPlayerConnect
  576. forward ColorPicker_OnPlayerConnect(playerid);
  577.  
  578. public OnPlayerDisconnect(playerid, reason)
  579. {
  580. PlayerTextDrawDestroy(playerid, cp_playerDraw[playerid][0]);
  581. PlayerTextDrawDestroy(playerid, cp_playerDraw[playerid][1]);
  582. CallLocalFunction("ColorPicker_OnPlayerDisconnect", "dd", playerid, reason);
  583. return 1;
  584. }
  585. #if defined _ALS_OnPlayerDisconnect
  586. #undef OnPlayerDisconnect
  587. #else
  588. #define _ALS_OnPlayerDisconnect
  589. #endif
  590. #define OnPlayerDisconnect ColorPicker_OnPlayerDisconnect
  591. forward ColorPicker_OnPlayerDisconnect(playerid, reason);
  592.  
  593. #if defined FILTERSCRIPT
  594.  
  595. public OnFilterScriptInit()
  596. {
  597. LoadColorPicker();
  598. print("ColorPicker zaladowano dla: FILTERSCRIPT");
  599. CallLocalFunction("ColorPicker_OnFilterScriptInit", "");
  600. return 1;
  601. }
  602. #if defined _ALS_OnFilterScriptInit
  603. #undef OnFilterScriptInit
  604. #else
  605. #define _ALS_OnFilterScriptInit
  606. #endif
  607. #define OnFilterScriptInit ColorPicker_OnFilterScriptInit
  608. forward ColorPicker_OnFilterScriptInit();
  609.  
  610. public OnFilterScriptExit()
  611. {
  612. UnLoadColorPicker();
  613. CallLocalFunction("ColorPicker_OnFilterScriptExit", "");
  614. return 1;
  615. }
  616. #if defined _ALS_OnFilterScriptExit
  617. #undef OnFilterScriptExit
  618. #else
  619. #define _ALS_OnFilterScriptExit
  620. #endif
  621. #define OnFilterScriptExit ColorPicker_OnFilterScriptExit
  622. forward ColorPicker_OnFilterScriptExit();
  623. #else
  624.  
  625. public OnGameModeInit()
  626. {
  627. LoadColorPicker();
  628. print("ColorPicker zaladowano dla: GAMEMODE");
  629. CallLocalFunction("ColorPicker_OnGameModeInit", "");
  630. return 1;
  631. }
  632. #if defined _ALS_OnGameModeInit
  633. #undef OnGameModeInit
  634. #else
  635. #define _ALS_OnGameModeInit
  636. #endif
  637. #define OnGameModeInit ColorPicker_OnGameModeInit
  638. forward ColorPicker_OnGameModeInit();
  639.  
  640. public OnGameModeExit()
  641. {
  642. UnLoadColorPicker();
  643. CallLocalFunction("ColorPicker_OnGameModeExit", "");
  644. return 1;
  645. }
  646. #if defined _ALS_OnGameModeExit
  647. #undef OnGameModeExit
  648. #else
  649. #define _ALS_OnGameModeExit
  650. #endif
  651. #define OnGameModeExit ColorPicker_OnGameModeExit
  652. forward ColorPicker_OnGameModeExit();
  653.  
  654. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement