Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- [INC] ColorPicker v 1.1 by Maku
- Created at 30-04-2013
- Last modify: 1-05-2013
- */
- /*
- native ShowPlayerColorPicker(playerid, pickerid, bool:showalpha = false, bool:showcancel = true);
- native HidePlayerColorPicker(playerid, bool:call_callback = false, call_response = 0);
- native
- native OnColorPickerResponse(playerid, pickerid, color, response);
- */
- #if defined _colorpicker_included
- #endinput
- #endif
- #define _colorpicker_included
- #include a_samp.inc
- static Text:cp_Draw[16];
- static PlayerText:cp_playerDraw[MAX_PLAYERS][5];
- static ChooseColor[MAX_PLAYERS][8];
- forward OnColorPickerResponse(playerid, pickerid, color, response);
- #define COLOR_PICKER_RED 0
- #define COLOR_PICKER_GREEN 1
- #define COLOR_PICKER_BLUE 2
- #define COLOR_PICKER_ALPHA 3
- #define COLOR_PICKER_ID 4
- #define COLOR_PICKER_ALPHA_ENABLE 5
- #define COLOR_PICKER_DIALOG_OPTION 6
- #define COLOR_PICKER_DIALOG_SHOW 7
- #if !defined COLOR_PICKER_DIALOG_ID
- #define COLOR_PICKER_DIALOG_ID (32766)
- #endif
- #define RGBAToHex(%0,%1,%2,%3) (%0<<24 | %1<<16 | %2<<8 | %3)
- LoadColorPicker()
- {
- print("\n+-----------------------------------------+");
- print( "| [INC] ColorPicker v1.0 by Maku - Loaded |");
- print( "+-----------------------------------------+\n");
- for(new i = GetMaxPlayers(); i >= 0; --i)
- {
- if(IsPlayerConnected(i))
- {
- LoadColorPickerForPlayer(i);
- }
- }
- cp_Draw[0] = TextDrawCreate(310.000000, 150.000000, "_");
- TextDrawAlignment(cp_Draw[0], 2);
- TextDrawBackgroundColor(cp_Draw[0], 255);
- TextDrawFont(cp_Draw[0], 1);
- TextDrawLetterSize(cp_Draw[0], 0.500000, 13.000000);
- TextDrawColor(cp_Draw[0], -1);
- TextDrawSetOutline(cp_Draw[0], 0);
- TextDrawSetProportional(cp_Draw[0], 1);
- TextDrawSetShadow(cp_Draw[0], 1);
- TextDrawUseBox(cp_Draw[0], 1);
- TextDrawBoxColor(cp_Draw[0], 68);
- TextDrawTextSize(cp_Draw[0], 30.000000, 250.000000);
- cp_Draw[1] = TextDrawCreate(259.000000, 149.000000, "Color~h~Picker");
- TextDrawBackgroundColor(cp_Draw[1], 85);
- TextDrawFont(cp_Draw[1], 3);
- TextDrawLetterSize(cp_Draw[1], 0.500000, 1.799998);
- TextDrawColor(cp_Draw[1], -5635858);
- TextDrawSetOutline(cp_Draw[1], 1);
- TextDrawSetProportional(cp_Draw[1], 1);
- cp_Draw[2] = TextDrawCreate(363.000000, 174.000000, "Created color:");
- TextDrawBackgroundColor(cp_Draw[2], 68);
- TextDrawFont(cp_Draw[2], 1);
- TextDrawLetterSize(cp_Draw[2], 0.200000, 1.000000);
- TextDrawColor(cp_Draw[2], -1);
- TextDrawSetOutline(cp_Draw[2], 1);
- TextDrawSetProportional(cp_Draw[2], 1);
- 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~_");
- TextDrawAlignment(cp_Draw[3], 3);
- TextDrawBackgroundColor(cp_Draw[3], 255);
- TextDrawFont(cp_Draw[3], 3);
- TextDrawLetterSize(cp_Draw[3], 0.429998, 1.100000);
- TextDrawColor(cp_Draw[3], -1);
- TextDrawSetOutline(cp_Draw[3], 0);
- TextDrawSetProportional(cp_Draw[3], 1);
- TextDrawSetShadow(cp_Draw[3], 1);
- cp_Draw[4] = TextDrawCreate(146.000000, 195.000000, "'~n~~n~~n~~n~'~n~~n~~n~~n~'");
- TextDrawBackgroundColor(cp_Draw[4], 255);
- TextDrawFont(cp_Draw[4], 0);
- TextDrawLetterSize(cp_Draw[4], 25.000000, 0.500000);
- TextDrawColor(cp_Draw[4], -5635858);
- TextDrawSetOutline(cp_Draw[4], 0);
- TextDrawSetProportional(cp_Draw[4], 1);
- TextDrawSetShadow(cp_Draw[4], 1);
- cp_Draw[5] = TextDrawCreate(259.000000, 175.000000, "<-");
- TextDrawAlignment(cp_Draw[5], 2);
- TextDrawBackgroundColor(cp_Draw[5], 255);
- TextDrawFont(cp_Draw[5], 0);
- TextDrawLetterSize(cp_Draw[5], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[5], -1);
- TextDrawSetOutline(cp_Draw[5], 0);
- TextDrawSetProportional(cp_Draw[5], 1);
- TextDrawSetShadow(cp_Draw[5], 1);
- TextDrawUseBox(cp_Draw[5], 1);
- TextDrawBoxColor(cp_Draw[5], 85);
- TextDrawTextSize(cp_Draw[5], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[5], true);
- cp_Draw[6] = TextDrawCreate(259.000000, 196.000000, "<-");
- TextDrawAlignment(cp_Draw[6], 2);
- TextDrawBackgroundColor(cp_Draw[6], 255);
- TextDrawFont(cp_Draw[6], 0);
- TextDrawLetterSize(cp_Draw[6], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[6], -1);
- TextDrawSetOutline(cp_Draw[6], 0);
- TextDrawSetProportional(cp_Draw[6], 1);
- TextDrawSetShadow(cp_Draw[6], 1);
- TextDrawUseBox(cp_Draw[6], 1);
- TextDrawBoxColor(cp_Draw[6], 85);
- TextDrawTextSize(cp_Draw[6], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[6], true);
- cp_Draw[7] = TextDrawCreate(259.000000, 216.000000, "<-");
- TextDrawAlignment(cp_Draw[7], 2);
- TextDrawBackgroundColor(cp_Draw[7], 255);
- TextDrawFont(cp_Draw[7], 0);
- TextDrawLetterSize(cp_Draw[7], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[7], -1);
- TextDrawSetOutline(cp_Draw[7], 0);
- TextDrawSetProportional(cp_Draw[7], 1);
- TextDrawSetShadow(cp_Draw[7], 1);
- TextDrawUseBox(cp_Draw[7], 1);
- TextDrawBoxColor(cp_Draw[7], 85);
- TextDrawTextSize(cp_Draw[7], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[7], true);
- cp_Draw[8] = TextDrawCreate(259.000000, 237.000000, "<-");
- TextDrawAlignment(cp_Draw[8], 2);
- TextDrawBackgroundColor(cp_Draw[8], 255);
- TextDrawFont(cp_Draw[8], 0);
- TextDrawLetterSize(cp_Draw[8], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[8], -1);
- TextDrawSetOutline(cp_Draw[8], 0);
- TextDrawSetProportional(cp_Draw[8], 1);
- TextDrawSetShadow(cp_Draw[8], 1);
- TextDrawUseBox(cp_Draw[8], 1);
- TextDrawBoxColor(cp_Draw[8], 85);
- TextDrawTextSize(cp_Draw[8], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[8], true);
- cp_Draw[9] = TextDrawCreate(316.000000, 175.000000, "->");
- TextDrawAlignment(cp_Draw[9], 2);
- TextDrawBackgroundColor(cp_Draw[9], 255);
- TextDrawFont(cp_Draw[9], 0);
- TextDrawLetterSize(cp_Draw[9], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[9], -1);
- TextDrawSetOutline(cp_Draw[9], 0);
- TextDrawSetProportional(cp_Draw[9], 1);
- TextDrawSetShadow(cp_Draw[9], 1);
- TextDrawUseBox(cp_Draw[9], 1);
- TextDrawBoxColor(cp_Draw[9], 85);
- TextDrawTextSize(cp_Draw[9], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[9], true);
- cp_Draw[10] = TextDrawCreate(316.000000, 195.000000, "->");
- TextDrawAlignment(cp_Draw[10], 2);
- TextDrawBackgroundColor(cp_Draw[10], 255);
- TextDrawFont(cp_Draw[10], 0);
- TextDrawLetterSize(cp_Draw[10], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[10], -1);
- TextDrawSetOutline(cp_Draw[10], 0);
- TextDrawSetProportional(cp_Draw[10], 1);
- TextDrawSetShadow(cp_Draw[10], 1);
- TextDrawUseBox(cp_Draw[10], 1);
- TextDrawBoxColor(cp_Draw[10], 85);
- TextDrawTextSize(cp_Draw[10], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[10], true);
- cp_Draw[11] = TextDrawCreate(316.000000, 216.000000, "->");
- TextDrawAlignment(cp_Draw[11], 2);
- TextDrawBackgroundColor(cp_Draw[11], 255);
- TextDrawFont(cp_Draw[11], 0);
- TextDrawLetterSize(cp_Draw[11], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[11], -1);
- TextDrawSetOutline(cp_Draw[11], 0);
- TextDrawSetProportional(cp_Draw[11], 1);
- TextDrawSetShadow(cp_Draw[11], 1);
- TextDrawUseBox(cp_Draw[11], 1);
- TextDrawBoxColor(cp_Draw[11], 85);
- TextDrawTextSize(cp_Draw[11], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[11], true);
- cp_Draw[12] = TextDrawCreate(316.000000, 237.000000, "->");
- TextDrawAlignment(cp_Draw[12], 2);
- TextDrawBackgroundColor(cp_Draw[12], 255);
- TextDrawFont(cp_Draw[12], 0);
- TextDrawLetterSize(cp_Draw[12], 0.319999, 1.799998);
- TextDrawColor(cp_Draw[12], -1);
- TextDrawSetOutline(cp_Draw[12], 0);
- TextDrawSetProportional(cp_Draw[12], 1);
- TextDrawSetShadow(cp_Draw[12], 1);
- TextDrawUseBox(cp_Draw[12], 1);
- TextDrawBoxColor(cp_Draw[12], 85);
- TextDrawTextSize(cp_Draw[12], 15.000000, 15.000000);
- TextDrawSetSelectable(cp_Draw[12], true);
- cp_Draw[13] = TextDrawCreate(414.000000, 255.000000, "OK");
- TextDrawAlignment(cp_Draw[13], 2);
- TextDrawBackgroundColor(cp_Draw[13], 85);
- TextDrawFont(cp_Draw[13], 1);
- TextDrawLetterSize(cp_Draw[13], 0.310000, 1.000000);
- TextDrawColor(cp_Draw[13], -1);
- TextDrawSetOutline(cp_Draw[13], 1);
- TextDrawSetProportional(cp_Draw[13], 1);
- TextDrawUseBox(cp_Draw[13], 1);
- TextDrawBoxColor(cp_Draw[13], 85);
- TextDrawTextSize(cp_Draw[13], 15.000000, 34.000000);
- TextDrawSetSelectable(cp_Draw[13], true);
- cp_Draw[14] = TextDrawCreate(429.000000, 150.000000, "X");
- TextDrawAlignment(cp_Draw[14], 2);
- TextDrawBackgroundColor(cp_Draw[14], 51);
- TextDrawFont(cp_Draw[14], 2);
- TextDrawLetterSize(cp_Draw[14], 0.270000, 0.899999);
- TextDrawColor(cp_Draw[14], -1);
- TextDrawSetOutline(cp_Draw[14], 1);
- TextDrawSetProportional(cp_Draw[14], 1);
- TextDrawUseBox(cp_Draw[14], 1);
- TextDrawBoxColor(cp_Draw[14], 102);
- TextDrawTextSize(cp_Draw[14], 10.000000, 10.000000);
- TextDrawSetSelectable(cp_Draw[14], true);
- cp_Draw[15] = TextDrawCreate(225.000000, 180.000000, "~r~~h~RED~n~_~n~~g~~h~GREEN~n~_~n~~b~~h~BLUE~n~_");
- TextDrawAlignment(cp_Draw[15], 3);
- TextDrawBackgroundColor(cp_Draw[15], 255);
- TextDrawFont(cp_Draw[15], 3);
- TextDrawLetterSize(cp_Draw[15], 0.429998, 1.100000);
- TextDrawColor(cp_Draw[15], -1);
- TextDrawSetOutline(cp_Draw[15], 0);
- TextDrawSetProportional(cp_Draw[15], 1);
- TextDrawSetShadow(cp_Draw[15], 1);
- return 1;
- }
- UnLoadColorPicker()
- {
- for(new i = GetMaxPlayers(); i >= 0; --i)
- {
- if(IsPlayerConnected(i))
- {
- HidePlayerColorPicker(i);
- PlayerTextDrawDestroy(i, cp_playerDraw[i][0]);
- PlayerTextDrawDestroy(i, cp_playerDraw[i][1]);
- PlayerTextDrawDestroy(i, cp_playerDraw[i][2]);
- PlayerTextDrawDestroy(i, cp_playerDraw[i][3]);
- PlayerTextDrawDestroy(i, cp_playerDraw[i][4]);
- }
- }
- for(new i; i < sizeof cp_Draw; i++)
- {
- TextDrawDestroy(cp_Draw[i]);
- }
- return 1;
- }
- LoadColorPickerForPlayer(playerid)
- {
- ChooseColor[playerid][COLOR_PICKER_ID] = -1;
- cp_playerDraw[playerid][0] = CreatePlayerTextDraw(playerid, 393.000000, 189.000000, "_");
- PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][0], 2);
- PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][0], 255);
- PlayerTextDrawFont(playerid, cp_playerDraw[playerid][0], 1);
- PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][0], 0.500000, 6.000000);
- PlayerTextDrawColor(playerid, cp_playerDraw[playerid][0], -1);
- PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][0], 0);
- PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][0], 1);
- PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][0], 1);
- PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][0], 1);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][0], 11206655);
- PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][0], 0.000000, 61.000000);
- cp_playerDraw[playerid][1] = CreatePlayerTextDraw(playerid, 288.000000, 179.000000, "255");
- PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][1], 2);
- PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][1], 255);
- PlayerTextDrawFont(playerid, cp_playerDraw[playerid][1], 3);
- PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][1], 0.500000, 1.100000);
- PlayerTextDrawColor(playerid, cp_playerDraw[playerid][1], -1);
- PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][1], 0);
- PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][1], 1);
- PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][1], 1);
- PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][1], 1);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][1], 17);
- PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][1], 10.000000, 30.000000);
- PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][1], 1);
- cp_playerDraw[playerid][2] = CreatePlayerTextDraw(playerid, 288.000000, 200.000000, "255");
- PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][2], 2);
- PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][2], 255);
- PlayerTextDrawFont(playerid, cp_playerDraw[playerid][2], 3);
- PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][2], 0.500000, 1.100000);
- PlayerTextDrawColor(playerid, cp_playerDraw[playerid][2], -1);
- PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][2], 0);
- PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][2], 1);
- PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][2], 1);
- PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][2], 1);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][2], 17);
- PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][2], 10.000000, 30.000000);
- PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][2], 1);
- cp_playerDraw[playerid][3] = CreatePlayerTextDraw(playerid, 288.000000, 218.000000, "255");
- PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][3], 2);
- PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][3], 255);
- PlayerTextDrawFont(playerid, cp_playerDraw[playerid][3], 3);
- PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][3], 0.500000, 1.100000);
- PlayerTextDrawColor(playerid, cp_playerDraw[playerid][3], -1);
- PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][3], 0);
- PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][3], 1);
- PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][3], 1);
- PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][3], 1);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][3], 17);
- PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][3], 10.000000, 30.000000);
- PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][3], 1);
- cp_playerDraw[playerid][4] = CreatePlayerTextDraw(playerid, 288.000000, 240.000000, "255");
- PlayerTextDrawAlignment(playerid, cp_playerDraw[playerid][4], 2);
- PlayerTextDrawBackgroundColor(playerid, cp_playerDraw[playerid][4], 255);
- PlayerTextDrawFont(playerid, cp_playerDraw[playerid][4], 3);
- PlayerTextDrawLetterSize(playerid, cp_playerDraw[playerid][4], 0.500000, 1.100000);
- PlayerTextDrawColor(playerid, cp_playerDraw[playerid][4], -1);
- PlayerTextDrawSetOutline(playerid, cp_playerDraw[playerid][4], 0);
- PlayerTextDrawSetProportional(playerid, cp_playerDraw[playerid][4], 1);
- PlayerTextDrawSetShadow(playerid, cp_playerDraw[playerid][4], 1);
- PlayerTextDrawUseBox(playerid, cp_playerDraw[playerid][4], 1);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][4], 17);
- PlayerTextDrawTextSize(playerid, cp_playerDraw[playerid][4], 10.000000, 30.000000);
- PlayerTextDrawSetSelectable(playerid, cp_playerDraw[playerid][4], 1);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if((newkeys & 16) && ChooseColor[playerid][COLOR_PICKER_ID] != -1)
- {
- HidePlayerColorPicker(playerid, true, 1);
- }
- CallLocalFunction("CP_OnPlayerKeyStateChange", "ddd", playerid, newkeys, oldkeys);
- return 1;
- }
- #if defined _ALS_OnPlayerKeyStateChange
- #undef OnPlayerKeyStateChange
- #else
- #define _ALS_OnPlayerKeyStateChange
- #endif
- #define OnPlayerKeyStateChange CP_OnPlayerKeyStateChange
- forward CP_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == COLOR_PICKER_DIALOG_ID && ChooseColor[playerid][COLOR_PICKER_ID] != -1)
- {
- if(response)
- {
- if(strlen(inputtext) > 0 && strval(inputtext) >= 0 && strval(inputtext) <= 255)
- {
- switch(ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION])
- {
- case 0: ChooseColor[playerid][COLOR_PICKER_RED] = strval(inputtext);
- case 1: ChooseColor[playerid][COLOR_PICKER_GREEN] = strval(inputtext);
- case 2: ChooseColor[playerid][COLOR_PICKER_BLUE] = strval(inputtext);
- case 3: ChooseColor[playerid][COLOR_PICKER_ALPHA] = strval(inputtext);
- }
- ColorPicker_RefreshColor(playerid, ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE]);
- ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
- SelectTextDraw(playerid, 0x00AAFFFF);
- }
- else
- {
- ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 1;
- CancelSelectTextDraw(playerid);
- 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");
- }
- }
- else
- {
- ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
- SelectTextDraw(playerid, 0x00AAFFFF);
- }
- }
- CallLocalFunction("CP_OnDialogResponse", "dddds", playerid, dialogid, response, listitem, inputtext);
- return 1;
- }
- #if defined _ALS_OnDialogResponse
- #undef OnDialogResponse
- #else
- #define _ALS_OnDialogResponse
- #endif
- #define OnDialogResponse CP_OnDialogResponse
- forward CP_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- if(ChooseColor[playerid][COLOR_PICKER_ID] != -1 && ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] == 0)
- {
- if(playertextid == cp_playerDraw[playerid][1]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 0;
- if(playertextid == cp_playerDraw[playerid][2]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 1;
- if(playertextid == cp_playerDraw[playerid][3]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 2;
- if(playertextid == cp_playerDraw[playerid][4]) ChooseColor[playerid][COLOR_PICKER_DIALOG_OPTION] = 3;
- ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 1;
- CancelSelectTextDraw(playerid);
- 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");
- }
- CallLocalFunction("CP_OnPlayerClickPlayerTextDraw", "dd", playerid, _:playertextid);
- return 1;
- }
- #if defined _H_OnPlayerClickPlayerTextDraw
- #undef OnPlayerClickPlayerTextDraw
- #else
- #define _H_OnPlayerClickPlayerTextDraw
- #endif
- #define OnPlayerClickPlayerTextDraw CP_OnPlayerClickPlayerTextDraw
- forward CP_OnPlayerClickPlayerTextDraw(playerid, _:playertextid);
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(ChooseColor[playerid][COLOR_PICKER_ID] != -1)
- {
- if(clickedid == cp_Draw[14] || clickedid == Text:INVALID_TEXT_DRAW && ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] == 0) //Anuluj
- {
- HidePlayerColorPicker(playerid, true, 0);
- }
- else if(clickedid == cp_Draw[13]) //Ok
- {
- HidePlayerColorPicker(playerid, true, 1);
- }
- else
- {
- if(clickedid == cp_Draw[5]) ChooseColor[playerid][COLOR_PICKER_RED] -= 5;
- if(clickedid == cp_Draw[6]) ChooseColor[playerid][COLOR_PICKER_GREEN] -= 5;
- if(clickedid == cp_Draw[7]) ChooseColor[playerid][COLOR_PICKER_BLUE] -= 5;
- if(clickedid == cp_Draw[8]) ChooseColor[playerid][COLOR_PICKER_ALPHA] -= 5;
- if(clickedid == cp_Draw[9]) ChooseColor[playerid][COLOR_PICKER_RED] += 5;
- if(clickedid == cp_Draw[10]) ChooseColor[playerid][COLOR_PICKER_GREEN] += 5;
- if(clickedid == cp_Draw[11]) ChooseColor[playerid][COLOR_PICKER_BLUE] += 5;
- if(clickedid == cp_Draw[12]) ChooseColor[playerid][COLOR_PICKER_ALPHA] += 5;
- ColorPicker_RefreshColor(playerid, ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE]);
- }
- }
- CallLocalFunction("CP_OnPlayerClickTextDraw", "dd", playerid, _:clickedid);
- return 1;
- }
- #if defined _ALS_OnPlayerClickTextDraw
- #undef OnPlayerClickTextDraw
- #else
- #define _ALS_OnPlayerClickTextDraw
- #endif
- #define OnPlayerClickTextDraw CP_OnPlayerClickTextDraw
- forward CP_OnPlayerClickTextDraw(playerid, _:clickedid);
- stock HidePlayerColorPicker(playerid, bool:call_callback = false, call_response = 0)
- {
- for(new i; i < sizeof cp_Draw; i++)
- {
- TextDrawHideForPlayer(playerid, cp_Draw[i]);
- }
- if(call_callback == true)
- {
- new color = RGBAToHex(ChooseColor[playerid][COLOR_PICKER_RED],ChooseColor[playerid][COLOR_PICKER_GREEN],ChooseColor[playerid][COLOR_PICKER_BLUE],ChooseColor[playerid][COLOR_PICKER_ALPHA]);
- CallRemoteFunction("OnColorPickerResponse", "dddd", playerid, ChooseColor[playerid][COLOR_PICKER_ID], color, call_response);
- }
- ChooseColor[playerid][COLOR_PICKER_ID] = -1;
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][0]);
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][1]);
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][2]);
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][3]);
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][4]);
- CancelSelectTextDraw(playerid);
- return 1;
- }
- stock ShowPlayerColorPicker(playerid, pickerid, bool:showalpha = false, bool:showcancel = true)
- {
- ChooseColor[playerid][COLOR_PICKER_ID] = pickerid;
- ChooseColor[playerid][COLOR_PICKER_RED] = 155;
- ChooseColor[playerid][COLOR_PICKER_GREEN] = 155;
- ChooseColor[playerid][COLOR_PICKER_BLUE] = 155;
- ChooseColor[playerid][COLOR_PICKER_ALPHA] = 255;
- ChooseColor[playerid][COLOR_PICKER_ALPHA_ENABLE] = showalpha;
- ChooseColor[playerid][COLOR_PICKER_DIALOG_SHOW] = 0;
- for(new i; i < sizeof cp_Draw; i++)
- {
- if(i == 15 && showalpha == true) continue;
- if(i == 3 && showalpha == false) continue;
- if(i == 8 && showalpha == false) continue;
- if(i == 12 && showalpha == false) continue;
- if(i == 14 && showcancel == false) continue;
- TextDrawShowForPlayer(playerid, cp_Draw[i]);
- }
- ColorPicker_RefreshColor(playerid, showalpha);
- SelectTextDraw(playerid, 0x00AAFFFF);
- return 1;
- }
- stock ColorPicker_RefreshColor(playerid, showalpha)
- {
- if(ChooseColor[playerid][COLOR_PICKER_RED] > 255) ChooseColor[playerid][COLOR_PICKER_RED] = 0;
- if(ChooseColor[playerid][COLOR_PICKER_RED] < 0) ChooseColor[playerid][COLOR_PICKER_RED] = 255;
- if(ChooseColor[playerid][COLOR_PICKER_GREEN] > 255) ChooseColor[playerid][COLOR_PICKER_GREEN] = 0;
- if(ChooseColor[playerid][COLOR_PICKER_GREEN] < 0) ChooseColor[playerid][COLOR_PICKER_GREEN] = 255;
- if(ChooseColor[playerid][COLOR_PICKER_BLUE] > 255) ChooseColor[playerid][COLOR_PICKER_BLUE] = 0;
- if(ChooseColor[playerid][COLOR_PICKER_BLUE] < 0) ChooseColor[playerid][COLOR_PICKER_BLUE] = 255;
- if(ChooseColor[playerid][COLOR_PICKER_ALPHA] > 255) ChooseColor[playerid][COLOR_PICKER_ALPHA] = 0;
- if(ChooseColor[playerid][COLOR_PICKER_ALPHA] < 0) ChooseColor[playerid][COLOR_PICKER_ALPHA] = 255;
- new color = RGBAToHex(ChooseColor[playerid][COLOR_PICKER_RED],ChooseColor[playerid][COLOR_PICKER_GREEN],ChooseColor[playerid][COLOR_PICKER_BLUE],ChooseColor[playerid][COLOR_PICKER_ALPHA]);
- PlayerTextDrawBoxColor(playerid, cp_playerDraw[playerid][0], color);
- PlayerTextDrawShow(playerid, cp_playerDraw[playerid][0]);
- new cp_str[8];
- valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_RED]);
- PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][1], cp_str);
- PlayerTextDrawShow(playerid, cp_playerDraw[playerid][1]);
- valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_GREEN]);
- PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][2], cp_str);
- PlayerTextDrawShow(playerid, cp_playerDraw[playerid][2]);
- valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_BLUE]);
- PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][3], cp_str);
- PlayerTextDrawShow(playerid, cp_playerDraw[playerid][3]);
- if(showalpha)
- {
- valstr(cp_str, ChooseColor[playerid][COLOR_PICKER_ALPHA]);
- PlayerTextDrawSetString(playerid, cp_playerDraw[playerid][4], cp_str);
- PlayerTextDrawShow(playerid, cp_playerDraw[playerid][4]);
- }
- else
- {
- PlayerTextDrawHide(playerid, cp_playerDraw[playerid][4]);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- LoadColorPickerForPlayer(playerid);
- CallLocalFunction("ColorPicker_OnPlayerConnect", "d", playerid);
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect ColorPicker_OnPlayerConnect
- forward ColorPicker_OnPlayerConnect(playerid);
- public OnPlayerDisconnect(playerid, reason)
- {
- PlayerTextDrawDestroy(playerid, cp_playerDraw[playerid][0]);
- PlayerTextDrawDestroy(playerid, cp_playerDraw[playerid][1]);
- CallLocalFunction("ColorPicker_OnPlayerDisconnect", "dd", playerid, reason);
- return 1;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect ColorPicker_OnPlayerDisconnect
- forward ColorPicker_OnPlayerDisconnect(playerid, reason);
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- LoadColorPicker();
- print("ColorPicker zaladowano dla: FILTERSCRIPT");
- CallLocalFunction("ColorPicker_OnFilterScriptInit", "");
- return 1;
- }
- #if defined _ALS_OnFilterScriptInit
- #undef OnFilterScriptInit
- #else
- #define _ALS_OnFilterScriptInit
- #endif
- #define OnFilterScriptInit ColorPicker_OnFilterScriptInit
- forward ColorPicker_OnFilterScriptInit();
- public OnFilterScriptExit()
- {
- UnLoadColorPicker();
- CallLocalFunction("ColorPicker_OnFilterScriptExit", "");
- return 1;
- }
- #if defined _ALS_OnFilterScriptExit
- #undef OnFilterScriptExit
- #else
- #define _ALS_OnFilterScriptExit
- #endif
- #define OnFilterScriptExit ColorPicker_OnFilterScriptExit
- forward ColorPicker_OnFilterScriptExit();
- #else
- public OnGameModeInit()
- {
- LoadColorPicker();
- print("ColorPicker zaladowano dla: GAMEMODE");
- CallLocalFunction("ColorPicker_OnGameModeInit", "");
- return 1;
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit ColorPicker_OnGameModeInit
- forward ColorPicker_OnGameModeInit();
- public OnGameModeExit()
- {
- UnLoadColorPicker();
- CallLocalFunction("ColorPicker_OnGameModeExit", "");
- return 1;
- }
- #if defined _ALS_OnGameModeExit
- #undef OnGameModeExit
- #else
- #define _ALS_OnGameModeExit
- #endif
- #define OnGameModeExit ColorPicker_OnGameModeExit
- forward ColorPicker_OnGameModeExit();
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement