Advertisement
Hiddos

h_input v1.0.5

Mar 30th, 2012
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 22.40 KB | None | 0 0
  1. #if defined H_INPUT_INCLUDED
  2.     #endinput
  3. #else
  4.     #define H_INPUT_INCLUDED
  5. #endif
  6. #tryinclude <a_samp>
  7. #pragma deprecated
  8. native InputInit();
  9.  
  10. #define HID_INPUT_PLAYLIST 1
  11. #define HID_INPUT_KEYPAD 2
  12. #define HID_INPUT_VEHCOL 3
  13. #define HID_INPUT_KEYBOARD 4
  14.  
  15. forward OnPlayerSelectPlayer(playerid, targetid, event);
  16. forward OnPlayerKeypadInput(playerid, input[], event);
  17.  
  18. /*      native time
  19. native InputFromPlayerList(playerid, event, bool:allowcancel);
  20. native InputFromKeypad(playerid, event, len, bool:allowcancel);
  21. native CancelInput(playerid);
  22. */
  23.  
  24. stock InputFromPlayerList(playerid, event, bool:allowcancel)
  25. {
  26.         //process init
  27.     SetPVarInt(playerid, "hid_input_event", event);
  28.     switch(GetPVarInt(playerid, "hid_input_active"))
  29.     {
  30.         case HID_INPUT_PLAYLIST:
  31.         {
  32.             DeletePVar(playerid, "hid_input_playlist_list");
  33.             Hid_Input_SetUpList(playerid);
  34.             return;
  35.         }
  36.         case HID_INPUT_KEYPAD:
  37.         {
  38.        
  39.         }
  40.     }
  41.     SetPVarInt(playerid, "hid_input_active", HID_INPUT_PLAYLIST);
  42.    
  43.         //actual init
  44.     new PlayerText:td;
  45.     new str[30];
  46.    
  47.     td = CreatePlayerTextDraw(playerid, 320.000000, 90.000000, "~n~Player List~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
  48.     PlayerTextDrawAlignment(playerid, td, 2);
  49.     PlayerTextDrawBackgroundColor(playerid, td, 0xFF);
  50.     PlayerTextDrawFont(playerid, td, 2);
  51.     PlayerTextDrawLetterSize(playerid, td, 0.500000, 1.000000);
  52.     PlayerTextDrawColor(playerid, td, -1);
  53.     PlayerTextDrawSetOutline(playerid, td, 0);
  54.     PlayerTextDrawSetProportional(playerid, td, 1);
  55.     PlayerTextDrawSetShadow(playerid, td, 1);
  56.     PlayerTextDrawUseBox(playerid, td, true);
  57.     PlayerTextDrawBoxColor(playerid, td, 150);
  58.     PlayerTextDrawTextSize(playerid, td, 10.000000, 250.000000);
  59.     PlayerTextDrawShow(playerid, td);
  60.     SetPVarInt(playerid, "hid_input_playlist_td_box", _:td);
  61.    
  62.     for(new b; b != 20; b++)
  63.     {
  64.         td = CreatePlayerTextDraw(playerid, 220.0, 120.0 + b * 10.0, "");
  65.         PlayerTextDrawBackgroundColor(playerid, td, 0xFF);
  66.         PlayerTextDrawFont(playerid, td, 2);
  67.         PlayerTextDrawLetterSize(playerid, td, 0.239999, 1.000000);
  68.         PlayerTextDrawSetOutline(playerid, td, 0);
  69.         PlayerTextDrawSetProportional(playerid, td, 1);
  70.         PlayerTextDrawSetShadow(playerid, td, 1);
  71.         PlayerTextDrawTextSize(playerid, td, 420.000000, 11.00000);
  72.         format(str, sizeof str, "hid_input_playlist_td_%i", b);
  73.         SetPVarInt(playerid, str, _:td);
  74.     }
  75.  
  76.     td = CreatePlayerTextDraw(playerid, 320.000000, 330.000000, "_");
  77.     PlayerTextDrawAlignment(playerid, td, 2);
  78.     PlayerTextDrawBackgroundColor(playerid, td, 0xFF);
  79.     PlayerTextDrawFont(playerid, td, 2);
  80.     PlayerTextDrawLetterSize(playerid, td, 0.500000, 1.000000);
  81.     PlayerTextDrawColor(playerid, td, -1);
  82.     PlayerTextDrawSetOutline(playerid, td, 0);
  83.     PlayerTextDrawSetProportional(playerid, td, 1);
  84.     PlayerTextDrawSetShadow(playerid, td, 1);
  85.     PlayerTextDrawShow(playerid, td);
  86.     SetPVarInt(playerid, "hid_input_playlist_td_mid", _:td);
  87.  
  88.     td = CreatePlayerTextDraw(playerid, 240.000000, 330.000000, "Previous 20");
  89.     PlayerTextDrawAlignment(playerid, td, 2);
  90.     PlayerTextDrawBackgroundColor(playerid, td, 0xFF);
  91.     PlayerTextDrawFont(playerid, td, 2);
  92.     PlayerTextDrawLetterSize(playerid, td, 0.200000, 1.000000);
  93.     PlayerTextDrawSetOutline(playerid, td, 0);
  94.     PlayerTextDrawSetProportional(playerid, td, 1);
  95.     PlayerTextDrawSetShadow(playerid, td, 1);
  96.     PlayerTextDrawTextSize(playerid, td, 18.0, 100.0);
  97.     PlayerTextDrawShow(playerid, td);
  98.     SetPVarInt(playerid, "hid_input_playlist_td_prev", _:td);
  99.  
  100.     td = CreatePlayerTextDraw(playerid, 400.000000, 330.000000, "Next 20");
  101.     PlayerTextDrawAlignment(playerid, td, 2);
  102.     PlayerTextDrawBackgroundColor(playerid, td, 0xFF);
  103.     PlayerTextDrawFont(playerid, td, 2);
  104.     PlayerTextDrawLetterSize(playerid, td, 0.200000, 1.000000);
  105.     PlayerTextDrawSetOutline(playerid, td, 0);
  106.     PlayerTextDrawSetProportional(playerid, td, 1);
  107.     PlayerTextDrawSetShadow(playerid, td, 1);
  108.     PlayerTextDrawTextSize(playerid, td, 18.0, 55.0);
  109.     PlayerTextDrawShow(playerid, td);
  110.     SetPVarInt(playerid, "hid_input_playlist_td_next", _:td);
  111.  
  112.     if(allowcancel == true)
  113.     {
  114.         td = CreatePlayerTextDraw(playerid, 435.000000, 93.000000, "X");
  115.         PlayerTextDrawAlignment(playerid, td, 2);
  116.         PlayerTextDrawBackgroundColor(playerid, td, 255);
  117.         PlayerTextDrawFont(playerid, td, 2);
  118.         PlayerTextDrawLetterSize(playerid, td, 0.500000, 1.000000);
  119.         PlayerTextDrawColor(playerid, td, 0x707070FF);
  120.         PlayerTextDrawSetOutline(playerid, td, 0);
  121.         PlayerTextDrawSetProportional(playerid, td, 1);
  122.         PlayerTextDrawSetShadow(playerid, td, 0);
  123.         PlayerTextDrawUseBox(playerid, td, 1);
  124.         PlayerTextDrawBoxColor(playerid, td, 842150655);
  125.         PlayerTextDrawTextSize(playerid, td, 11.000000, 11.000000);
  126.         PlayerTextDrawSetSelectable(playerid, td, true);
  127.         PlayerTextDrawShow(playerid, td);
  128.         SetPVarInt(playerid, "hid_input_td_close", _:td);
  129.     }
  130.  
  131.     SelectTextDraw(playerid, 0xFFFFFFFF);
  132.     Hid_Input_SetUpList(playerid);
  133. }
  134.  
  135. stock InputFromKeypad(playerid, event, minlen, maxlen, bool:allowcancel)
  136. {
  137.         //process init
  138.     SetPVarInt(playerid, "hid_input_event", event);
  139.     if(minlen > maxlen)
  140.     {
  141.         new temp = minlen;
  142.         minlen = maxlen;
  143.         maxlen = temp;
  144.     }
  145.     if(minlen <= 0 || maxlen > 16) minlen = 1;
  146.     if(maxlen > 0 && maxlen <= 16) SetPVarInt(playerid, "hid_input_keypad_maxlen", maxlen);
  147.     else SetPVarInt(playerid, "hid_input_keypad_maxlen", 16);
  148.     SetPVarInt(playerid, "hid_input_keypad_minlen", minlen);
  149.     new PlayerText:td;
  150.     new str[30];
  151.     switch(GetPVarInt(playerid, "hid_input_active"))
  152.     {
  153.         case HID_INPUT_PLAYLIST:
  154.         {
  155.             CancelInput(playerid);
  156.  
  157.         }
  158.         case HID_INPUT_KEYPAD:
  159.         {
  160.             DeletePVar(playerid, "hid_input_keypad_input");
  161.             PlayerTextDrawSetString(playerid, PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_input"), "-");
  162.             return;
  163.         }
  164.     }
  165.    
  166.         //actual init
  167.     SetPVarInt(playerid, "hid_input_active", HID_INPUT_KEYPAD);
  168.    
  169.     td = CreatePlayerTextDraw(playerid, 320.000000, 90.000000, "~n~Keypad~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
  170.     PlayerTextDrawAlignment(playerid, td, 2);
  171.     PlayerTextDrawBackgroundColor(playerid, td, 255);
  172.     PlayerTextDrawFont(playerid, td, 2);
  173.     PlayerTextDrawLetterSize(playerid, td, 0.500000, 1.000000);
  174.     PlayerTextDrawColor(playerid, td, -1);
  175.     PlayerTextDrawSetOutline(playerid, td, 0);
  176.     PlayerTextDrawSetProportional(playerid, td, 1);
  177.     PlayerTextDrawSetShadow(playerid, td, 1);
  178.     PlayerTextDrawUseBox(playerid, td, 1);
  179.     PlayerTextDrawBoxColor(playerid, td, 150);
  180.     PlayerTextDrawTextSize(playerid, td, 10.000000, 250.000000);
  181.     PlayerTextDrawShow(playerid, td);
  182.     SetPVarInt(playerid, "hid_input_keypad_td_box", _:td);
  183.  
  184.     for(new b = 0; b != 10; b++)
  185.     {
  186.         switch(b)
  187.         {
  188.             case 0: td = CreatePlayerTextDraw(playerid, 250.000000, 235.000000, "0");
  189.             case 1: td = CreatePlayerTextDraw(playerid, 250.000000, 205.000000, "1");
  190.             case 2: td = CreatePlayerTextDraw(playerid, 295.000000, 205.000000, "2");
  191.             case 3: td = CreatePlayerTextDraw(playerid, 340.000000, 205.000000, "3");
  192.             case 4: td = CreatePlayerTextDraw(playerid, 250.000000, 175.000000, "4");
  193.             case 5: td = CreatePlayerTextDraw(playerid, 295.000000, 175.000000, "5");
  194.             case 6: td = CreatePlayerTextDraw(playerid, 340.000000, 175.000000, "6");
  195.             case 7: td = CreatePlayerTextDraw(playerid, 250.000000, 145.000000, "7");
  196.             case 8: td = CreatePlayerTextDraw(playerid, 295.000000, 145.000000, "8");
  197.             case 9: td = CreatePlayerTextDraw(playerid, 340.000000, 145.000000, "9");
  198.         }
  199.         PlayerTextDrawAlignment(playerid, td, 2);
  200.         PlayerTextDrawBackgroundColor(playerid, td, 255);
  201.         PlayerTextDrawFont(playerid, td, 2);
  202.         PlayerTextDrawLetterSize(playerid, td, 0.659999, 2.599999);
  203.         PlayerTextDrawColor(playerid, td, 0x808080FF);
  204.         PlayerTextDrawSetOutline(playerid, td, 0);
  205.         PlayerTextDrawSetProportional(playerid, td, 1);
  206.         PlayerTextDrawSetShadow(playerid, td, 1);
  207.         PlayerTextDrawUseBox(playerid, td, 1);
  208.         PlayerTextDrawBoxColor(playerid, td, 255);
  209.         PlayerTextDrawTextSize(playerid, td, 34.000000, 34.000000);
  210.         PlayerTextDrawSetSelectable(playerid, td, true);
  211.         PlayerTextDrawShow(playerid, td);
  212.         format(str, sizeof str, "hid_input_keypad_td_%i", b);
  213.         SetPVarInt(playerid, str, _:td);
  214.     }
  215.  
  216.     td = CreatePlayerTextDraw(playerid, 405.000000, 165.000000, "C");
  217.     PlayerTextDrawAlignment(playerid, td, 2);
  218.     PlayerTextDrawBackgroundColor(playerid, td, 255);
  219.     PlayerTextDrawFont(playerid, td, 2);
  220.     PlayerTextDrawLetterSize(playerid, td, 1.059999, 2.599999);
  221.     PlayerTextDrawColor(playerid, td, -16776961);
  222.     PlayerTextDrawSetOutline(playerid, td, 0);
  223.     PlayerTextDrawSetProportional(playerid, td, 1);
  224.     PlayerTextDrawSetShadow(playerid, td, 1);
  225.     PlayerTextDrawUseBox(playerid, td, 1);
  226.     PlayerTextDrawBoxColor(playerid, td, 255);
  227.     PlayerTextDrawTextSize(playerid, td, 34.000000, 34.000000);
  228.     PlayerTextDrawSetSelectable(playerid, td, true);
  229.     PlayerTextDrawShow(playerid, td);
  230.     SetPVarInt(playerid, "hid_input_keypad_td_clear", _:td);
  231.  
  232.     td = CreatePlayerTextDraw(playerid, 405.000000, 214.000000, "Ok");
  233.     PlayerTextDrawAlignment(playerid, td, 2);
  234.     PlayerTextDrawBackgroundColor(playerid, td, 255);
  235.     PlayerTextDrawFont(playerid, td, 2);
  236.     PlayerTextDrawLetterSize(playerid, td, 0.570000, 2.899999);
  237.     PlayerTextDrawColor(playerid, td, 16711935);
  238.     PlayerTextDrawSetOutline(playerid, td, 0);
  239.     PlayerTextDrawSetProportional(playerid, td, 1);
  240.     PlayerTextDrawSetShadow(playerid, td, 1);
  241.     PlayerTextDrawUseBox(playerid, td, 1);
  242.     PlayerTextDrawBoxColor(playerid, td, 255);
  243.     PlayerTextDrawTextSize(playerid, td, 34.000000, 34.000000);
  244.     PlayerTextDrawSetSelectable(playerid, td, true);
  245.     PlayerTextDrawShow(playerid, td);
  246.     SetPVarInt(playerid, "hid_input_keypad_td_confirm", _:td);
  247.  
  248.     td = CreatePlayerTextDraw(playerid, 320.000000, 120.000000, "-");
  249.     PlayerTextDrawAlignment(playerid, td, 2);
  250.     PlayerTextDrawBackgroundColor(playerid, td, 255);
  251.     PlayerTextDrawFont(playerid, td, 2);
  252.     PlayerTextDrawLetterSize(playerid, td, 0.450000, 1.800000);
  253.     PlayerTextDrawColor(playerid, td, -1);
  254.     PlayerTextDrawSetOutline(playerid, td, 0);
  255.     PlayerTextDrawSetProportional(playerid, td, 1);
  256.     PlayerTextDrawSetShadow(playerid, td, 1);
  257.     PlayerTextDrawUseBox(playerid, td, 1);
  258.     PlayerTextDrawBoxColor(playerid, td, 255);
  259.     PlayerTextDrawTextSize(playerid, td, 420.000000, 230.000000);
  260.     PlayerTextDrawShow(playerid, td);
  261.     SetPVarInt(playerid, "hid_input_keypad_td_input", _:td);
  262.  
  263.     if(allowcancel == true)
  264.     {
  265.         td = CreatePlayerTextDraw(playerid, 435.000000, 93.000000, "X");
  266.         PlayerTextDrawAlignment(playerid, td, 2);
  267.         PlayerTextDrawBackgroundColor(playerid, td, 255);
  268.         PlayerTextDrawFont(playerid, td, 2);
  269.         PlayerTextDrawLetterSize(playerid, td, 0.500000, 1.000000);
  270.         PlayerTextDrawColor(playerid, td, 0x707070FF);
  271.         PlayerTextDrawSetOutline(playerid, td, 0);
  272.         PlayerTextDrawSetProportional(playerid, td, 1);
  273.         PlayerTextDrawSetShadow(playerid, td, 0);
  274.         PlayerTextDrawUseBox(playerid, td, 1);
  275.         PlayerTextDrawBoxColor(playerid, td, 842150655);
  276.         PlayerTextDrawTextSize(playerid, td, 11.000000, 11.000000);
  277.         PlayerTextDrawSetSelectable(playerid, td, true);
  278.         PlayerTextDrawShow(playerid, td);
  279.         SetPVarInt(playerid, "hid_input_td_close", _:td);
  280.     }
  281.     SelectTextDraw(playerid, 0xFFFFFFFF);
  282.     GetPVarString(playerid, "hid_input_keypad_input", str, 16);
  283.        
  284. }
  285.  
  286. stock Hid_Input_SetUpList(playerid)
  287. {
  288.     new list = GetPVarInt(playerid, "hid_input_playlist_list");
  289.     new str[30];
  290.     new PlayerText:td;
  291.     for(new b = list; b != list + 20; b++)
  292.     {
  293.         format(str, sizeof str, "hid_input_playlist_td_%i", b % 20);
  294.         td = PlayerText:GetPVarInt(playerid, str);
  295.         if(b >= MAX_PLAYERS)
  296.         {
  297.             PlayerTextDrawHide(playerid, td);
  298.             continue;
  299.         }
  300.         if(IsPlayerConnected(b))
  301.         {
  302.             GetPlayerName(b, str, MAX_PLAYER_NAME);
  303.             format(str, sizeof str, "%i. %s", b, str);
  304.             PlayerTextDrawSetString(playerid, td, str);
  305.             PlayerTextDrawColor(playerid, td, 0xA3B4C5FF);
  306.             PlayerTextDrawSetSelectable(playerid, td, true);
  307.         }
  308.         else
  309.         {
  310.             format(str, sizeof str, "%i. Not connected", b);
  311.             PlayerTextDrawSetString(playerid, td, str);
  312.             PlayerTextDrawColor(playerid, td, 0x505050FF);
  313.             PlayerTextDrawSetSelectable(playerid, td, false);
  314.         }
  315.         PlayerTextDrawShow(playerid, td);
  316.     }
  317.         //navback
  318.     td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_prev");
  319.     if(list != 0)
  320.     {
  321.         PlayerTextDrawSetSelectable(playerid, td, true);
  322.         PlayerTextDrawColor(playerid, td, 0xA3B4C5FF);
  323.         PlayerTextDrawShow(playerid, td);
  324.     }
  325.     else
  326.     {
  327.         PlayerTextDrawSetSelectable(playerid, td, false);
  328.         PlayerTextDrawColor(playerid, td, 0x505050FF);
  329.         PlayerTextDrawShow(playerid, td);
  330.     }
  331.         //navfront
  332.     td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_next");
  333.     if((list + 20) < MAX_PLAYERS)
  334.     {
  335.         PlayerTextDrawSetSelectable(playerid, td, true);
  336.         PlayerTextDrawColor(playerid, td, 0xA3B4C5FF);
  337.         PlayerTextDrawShow(playerid, td);
  338.     }
  339.     else
  340.     {
  341.         PlayerTextDrawSetSelectable(playerid, td, false);
  342.         PlayerTextDrawColor(playerid, td, 0x505050FF);
  343.         PlayerTextDrawShow(playerid, td);
  344.     }
  345.         //  mid (0-19)
  346.     td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_mid");
  347.     format(str, sizeof str, "%i-%i", list, list + 19);
  348.     PlayerTextDrawSetString(playerid, td, str);
  349.     PlayerTextDrawShow(playerid, td);
  350. }
  351.  
  352. stock CancelInput(playerid)
  353. {
  354.     switch(GetPVarInt(playerid, "hid_input_active"))
  355.     {
  356.         case 0: return;
  357.         case HID_INPUT_PLAYLIST:
  358.         {
  359.             new str[30], PlayerText:td;
  360.             td = PlayerText:GetPVarInt(playerid, "hid_input_td_close");
  361.             if(_:td != 0)
  362.             {
  363.                 PlayerTextDrawDestroy(playerid, td);
  364.                 DeletePVar(playerid, "hid_input_td_close");
  365.             }
  366.             for(new c; c != 20; c++)
  367.             {
  368.                 format(str, sizeof str, "hid_input_playlist_td_%i", c);
  369.                 td = PlayerText:GetPVarInt(playerid, str);
  370.                 PlayerTextDrawDestroy(playerid, td);
  371.                 DeletePVar(playerid, str);
  372.             }
  373.             td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_next");
  374.             PlayerTextDrawDestroy(playerid, td);
  375.             DeletePVar(playerid, "hid_input_playlist_td_next");
  376.             td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_prev");
  377.             PlayerTextDrawDestroy(playerid, td);
  378.             DeletePVar(playerid, "hid_input_playlist_td_prev");
  379.             td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_right");
  380.             PlayerTextDrawDestroy(playerid, td);
  381.             DeletePVar(playerid, "hid_input_playlist_td_right");
  382.             td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_mid");
  383.             PlayerTextDrawDestroy(playerid, td);
  384.             DeletePVar(playerid, "hid_input_playlist_td_mid");
  385.             td = PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_box");
  386.             PlayerTextDrawDestroy(playerid, td);
  387.             DeletePVar(playerid, "hid_input_playlist_td_box");
  388.             DeletePVar(playerid, "hid_input_playlist_list");
  389.             DeletePVar(playerid, "hid_input_event");
  390.             DeletePVar(playerid, "hid_input_active");
  391.             CancelSelectTextDraw(playerid);
  392.         }
  393.         case HID_INPUT_KEYPAD:
  394.         {
  395.             new str[30], PlayerText:td;
  396.             td = PlayerText:GetPVarInt(playerid, "hid_input_td_close");
  397.             if(_:td != 0)
  398.             {
  399.                 PlayerTextDrawDestroy(playerid, td);
  400.                 DeletePVar(playerid, "hid_input_td_close");
  401.             }
  402.             for(new c; c != 10; c++)
  403.             {
  404.                 format(str, sizeof str, "hid_input_keypad_td_%i", c);
  405.                 td = PlayerText:GetPVarInt(playerid, str);
  406.                 PlayerTextDrawDestroy(playerid, td);
  407.                 DeletePVar(playerid, str);
  408.             }
  409.             td = PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_box");
  410.             PlayerTextDrawDestroy(playerid, td);
  411.             DeletePVar(playerid, "hid_input_keypad_td_box");
  412.             td = PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_clear");
  413.             PlayerTextDrawDestroy(playerid, td);
  414.             DeletePVar(playerid, "hid_input_keypad_td_clear");
  415.             td = PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_confirm");
  416.             PlayerTextDrawDestroy(playerid, td);
  417.             DeletePVar(playerid, "hid_input_keypad_td_confirm");
  418.             td = PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_input");
  419.             PlayerTextDrawDestroy(playerid, td);
  420.             DeletePVar(playerid, "hid_input_keypad_input");
  421.             DeletePVar(playerid, "hid_input_keypad_maxlen");
  422.             DeletePVar(playerid, "hid_input_keypad_minlen");
  423.             DeletePVar(playerid, "hid_input_event");
  424.             DeletePVar(playerid, "hid_input_active");
  425.             CancelSelectTextDraw(playerid);
  426.         }
  427.     }
  428. }
  429.  
  430. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  431. {
  432.     switch(GetPVarInt(playerid, "hid_input_active"))
  433.     {
  434.         case HID_INPUT_PLAYLIST:
  435.         {
  436.             if(PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_prev") == playertextid)
  437.             {
  438.                 new list = GetPVarInt(playerid, "hid_input_playlist_list");
  439.                 if(list != 0) list -= 20;
  440.                 SetPVarInt(playerid, "hid_input_playlist_list", list);
  441.                 Hid_Input_SetUpList(playerid);
  442.                 return 1;
  443.             }
  444.             else if(PlayerText:GetPVarInt(playerid, "hid_input_playlist_td_next") == playertextid)
  445.             {
  446.                 new list = GetPVarInt(playerid, "hid_input_playlist_list");
  447.                 if((list + 20) < MAX_PLAYERS) list += 20;
  448.                 SetPVarInt(playerid, "hid_input_playlist_list", list);
  449.                 Hid_Input_SetUpList(playerid);
  450.                 return 1;
  451.             }
  452.             else if(PlayerText:GetPVarInt(playerid, "hid_input_td_close") == playertextid)
  453.             {
  454.                 CallRemoteFunction("OnPlayerSelectPlayer", "iii", playerid, INVALID_PLAYER_ID, GetPVarInt(playerid, "hid_input_event"));
  455.                 CancelInput(playerid);
  456.                 return 1;
  457.             }
  458.             else
  459.             {
  460.                 new str[30], PlayerText:td;
  461.                 for(new b; b != 20; b++)
  462.                 {
  463.                     format(str, sizeof str, "hid_input_playlist_td_%i", b);
  464.                     td = PlayerText:GetPVarInt(playerid, str);
  465.                     if(td == playertextid)
  466.                     {
  467.                         CallRemoteFunction("OnPlayerSelectPlayer", "iii", playerid, b + GetPVarInt(playerid, "hid_input_playlist_list"), GetPVarInt(playerid, "hid_input_event"));
  468.                         CancelInput(playerid);
  469.                         return 1;
  470.                     }
  471.                 }
  472.             }
  473.            
  474.         }
  475.         case HID_INPUT_KEYPAD:
  476.         {
  477.             if(PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_confirm") == playertextid)
  478.             {
  479.                 new str[16];
  480.                 GetPVarString(playerid, "hid_input_keypad_input", str, 16);
  481.                 if(strlen(str) < GetPVarInt(playerid, "hid_input_keypad_minlen")) return 1;
  482.                 CallRemoteFunction("OnPlayerKeypadInput", "isi", playerid, str, GetPVarInt(playerid, "hid_input_event"));
  483.                 CancelInput(playerid);
  484.                 return 1;
  485.             }
  486.             else if(PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_clear") == playertextid)
  487.             {
  488.                 DeletePVar(playerid, "hid_input_keypad_input");
  489.                 PlayerTextDrawSetString(playerid, PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_input"), "-");
  490.                 return 1;
  491.             }
  492.             else if(PlayerText:GetPVarInt(playerid, "hid_input_td_close") == playertextid)
  493.             {
  494.                 CallRemoteFunction("OnPlayerKeypadInput", "iii", playerid, -1, GetPVarInt(playerid, "hid_input_event"));
  495.                 CancelInput(playerid);
  496.                 return 1;
  497.             }
  498.             else
  499.             {
  500.                 new str[30], PlayerText:td;
  501.                 for(new b; b != 10; b++)
  502.                 {
  503.                     format(str, sizeof str, "hid_input_keypad_td_%i", b);
  504.                     td = PlayerText:GetPVarInt(playerid, str);
  505.                     if(td == playertextid)
  506.                     {
  507.                         for(new i; i != 30; i++) str[i] = '\0';
  508.                         GetPVarString(playerid, "hid_input_keypad_input", str, 16);
  509.                         if(strlen(str) >= GetPVarInt(playerid, "hid_input_keypad_maxlen")) return 1;
  510.                         str[strlen(str)] = b + 48;
  511.                         SetPVarString(playerid, "hid_input_keypad_input", str);
  512.                         td = PlayerText:GetPVarInt(playerid, "hid_input_keypad_td_input");
  513.                         PlayerTextDrawSetString(playerid, td, str);
  514.                         PlayerTextDrawShow(playerid, td);
  515.                         return 1;
  516.                     }
  517.                 }
  518.             }
  519.        
  520.         }
  521.         default: return CallLocalFunction("S@@_OnPlayerClickPlayerTextDraw", "ii", playerid, _:playertextid);
  522.     }
  523.     return CallLocalFunction("S@@_OnPlayerClickPlayerTextDraw", "ii", playerid, _:playertextid);
  524. }
  525.  
  526. #if defined ALS_OnPlayerClickPlayerTextDraw
  527.     #undef OnPlayerClickPlayerTextDraw
  528. #else
  529.     #define ALS_OnPlayerClickPlayerTextDraw
  530. #endif
  531. #define OnPlayerClickPlayerTextDraw S@@_OnPlayerClickPlayerTextDraw
  532. forward OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
  533.  
  534. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  535. {
  536.     if(_:clickedid == 65535 && GetPVarInt(playerid, "hid_input_active") != 0)
  537.     {
  538.         if(GetPVarInt(playerid, "hid_input_td_close") != 0) CancelInput(playerid);
  539.         else SelectTextDraw(playerid, 0xFFFFFFFF);
  540.         return 1;
  541.     }
  542.     return CallLocalFunction("S@@_OnPlayerClickTextDraw", "ii", playerid, _:clickedid);
  543. }
  544.  
  545. #if defined ALS_OnPlayerClickTextDraw
  546.     #undef OnPlayerClickTextDraw
  547. #else
  548.     #define ALS_OnPlayerClickTextDraw
  549. #endif
  550. #define OnPlayerClickTextDraw S@@_OnPlayerClickTextDraw
  551. forward OnPlayerClickTextDraw(playerid, Text:clickedid);
  552.  
  553. public OnPlayerDisconnect(playerid, reason)
  554. {
  555.     new list, str[30], substr[30], PlayerText:td;
  556.     format(str, sizeof str, "%i. Not connected", playerid);
  557.     format(substr, sizeof substr, "hid_input_playlist_td_%i", playerid % 20);
  558.     for(new i; i != MAX_PLAYERS; i++)
  559.     {
  560.         if(GetPVarInt(i, "hid_input_active") != HID_INPUT_PLAYLIST) continue;
  561.         list = GetPVarInt(i, "hid_input_playlist_list");
  562.         if(playerid >= list && playerid < (list + 19))
  563.         {
  564.             td = PlayerText:GetPVarInt(i, substr);
  565.             PlayerTextDrawSetString(i, td, str);
  566.             PlayerTextDrawColor(i, td, 0x505050FF);
  567.             PlayerTextDrawSetSelectable(i, td, false);
  568.             PlayerTextDrawShow(i, td);
  569.         }
  570.     }
  571.     return CallLocalFunction("S@@_OnPlayerDisconnect", "ii", playerid, reason);
  572. }
  573.  
  574. #if defined ALS_OnPlayerDisconnect
  575.     #undef OnPlayerDisconnect
  576. #else
  577.     #define ALS_OnPlayerDisconnect
  578. #endif
  579. #define OnPlayerDisconnect S@@_OnPlayerDisconnect
  580. forward OnPlayerDisconnect(playerid, reason);
  581.  
  582. public OnPlayerConnect(playerid)
  583. {
  584.     new list, str[30], substr[30], PlayerText:td;
  585.     GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  586.     format(substr, sizeof substr, "hid_input_playlist_td_%i", playerid % 20);
  587.     for(new i; i != MAX_PLAYERS; i++)
  588.     {
  589.         if(GetPVarInt(i, "hid_input_active") != HID_INPUT_PLAYLIST) continue;
  590.         list = GetPVarInt(i, "hid_input_playlist_list");
  591.         if(playerid >= list && playerid < (list + 19))
  592.         {
  593.             td = PlayerText:GetPVarInt(i, substr);
  594.             PlayerTextDrawSetString(i, td, str);
  595.             PlayerTextDrawColor(i, td, 0xA3B4C5FF);
  596.             PlayerTextDrawSetSelectable(i, td, true);
  597.             PlayerTextDrawShow(i, td);
  598.         }
  599.     }
  600.     return CallLocalFunction("S@@_OnPlayerConnect", "i", playerid);
  601. }
  602.  
  603. #if defined ALS_OnPlayerConnect
  604.     #undef OnPlayerConnect
  605. #else
  606.     #define ALS_OnPlayerConnect
  607. #endif
  608. #define OnPlayerConnect S@@_OnPlayerConnect
  609. forward OnPlayerConnect(playerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement