LoriYagami

H-Pickup 1.3

Jan 30th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.94 KB | None | 0 0
  1. //===============================================================================
  2. //|                 This Script Originaly Made by Haikal Bintang                |
  3. //===============================================================================
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <mSelection>
  8. #include <sscanf2>
  9.  
  10. #define DIALOG_PICKUP_TEXT 9999
  11. #define DIALOG_PICKUP_ID 10000
  12.  
  13. new pickuptext[256];
  14. new pickuplist = mS_INVALID_LISTID;
  15. new bool:pickupidmode = false;
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     pickuplist = LoadModelSelectionMenu("pickup.txt");
  20.     print("H-Pickup created by Haikal Bintang.");
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerModelSelection(playerid, response, listid, modelid)
  25. {
  26.     new string[256], Float:X, Float:Y, Float:Z;
  27.     if((listid == pickuplist) && response)
  28.     {
  29.         GetPlayerPos(playerid, X, Y, Z);
  30.  
  31.         new File:pos=fopen("createdpickup.txt", io_append);
  32.         format(string, 256, "CreatePickup(%i, 23, %f, %f, %f, %i)\r\n",  modelid, X, Y, Z, GetPlayerVirtualWorld(playerid));
  33.         fwrite(pos, string);
  34.         format(string, 256, "Create3DTextLabel(%s, 0xFFFFFFAA, %f, %f, %f, 5.0, %i)\r\n", pickuptext, X, Y, Z+0.50, GetPlayerVirtualWorld(playerid));
  35.         fwrite(pos, string);
  36.         fclose(pos);
  37.         CreatePickup(modelid, 23, X, Y, Z, GetPlayerVirtualWorld(playerid));
  38.         Create3DTextLabel(pickuptext, 0xFFFFFFAA, X, Y, Z+0.50, 5.0, GetPlayerVirtualWorld(playerid));
  39.         SendClientMessage(playerid, -1, "{FFFFFF}Pickup telah dibuat, ketik /createpickup untuk membuat lagi.");
  40.     }
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerSpawn(playerid)
  45. {
  46.     SendClientMessage(playerid, -1, "{FFFFFF}Ketik /createpickup untuk membuat sebuah pickup.");
  47.     return 1;
  48. }
  49.  
  50. CMD:createpickup(playerid, params[])
  51. {
  52.     new pickupmetode;
  53.     if(sscanf(params, "i", pickupmetode))
  54.     {
  55.         SendClientMessage(playerid, -1, "[USAGE]: /createpickup [metode]");
  56.         SendClientMessage(playerid, -1, "[1] Dengan Model | [2] Dengan ID");
  57.         return 1;
  58.     }
  59.     if(pickupmetode < 1 || pickupmetode > 2) return SendClientMessage(playerid, -1, "Hanya ada 1 dan 2.");
  60.     if(pickupmetode == 1)
  61.     {
  62.         ShowPlayerDialog(playerid, DIALOG_PICKUP_TEXT, DIALOG_STYLE_INPUT, "Pickup Text", "Masukan text pickup di bawah ini :\nContoh di In-Game [Tekan [ENTER] untuk masuk]", "Create", "Cancel");
  63.     }
  64.     else if(pickupmetode == 2)
  65.     {
  66.         ShowPlayerDialog(playerid, DIALOG_PICKUP_TEXT, DIALOG_STYLE_INPUT, "Pickup Text", "Masukan text pickup di bawah ini :\nContoh di In-Game [Tekan [ENTER] untuk masuk]", "Create", "Cancel");
  67.         pickupidmode = true;
  68.     }
  69.     return 1;
  70. }
  71.  
  72. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  73. {
  74.     if(dialogid == DIALOG_PICKUP_TEXT)
  75.     {
  76.         if(response)
  77.         {
  78.             if(pickupidmode == false)
  79.             {
  80.                 format(pickuptext, sizeof(pickuptext), "%s", inputtext);
  81.                 ShowModelSelectionMenu(playerid, pickuplist, "Pilih Jenis Pickup");
  82.             }
  83.             else
  84.             {
  85.                 format(pickuptext, sizeof(pickuptext), "%s", inputtext);
  86.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_ID, DIALOG_STYLE_INPUT, "Pickup ID", "Masukan id pickup di bawan ini :", "Create", "Cancel");
  87.             }
  88.         }
  89.         else
  90.         {
  91.             pickupidmode = false;
  92.         }
  93.     }
  94.     if(dialogid == DIALOG_PICKUP_ID)
  95.     {
  96.         if(response)
  97.         {
  98.             new string[256], Float:X, Float:Y, Float:Z;
  99.             if(IsNumeric(inputtext))
  100.             {
  101.                 GetPlayerPos(playerid, X, Y, Z);
  102.  
  103.                 new File:pos=fopen("createdpickup.txt", io_append);
  104.                 format(string, 256, "CreatePickup(%i, 23, %f, %f, %f, %i)\r\n", inputtext, X, Y, Z, GetPlayerVirtualWorld(playerid));
  105.                 fwrite(pos, string);
  106.                 format(string, 256, "Create3DTextLabel(%s, 0xFFFFFFAA, %f, %f, %f, 5.0, %i)\r\n", pickuptext, X, Y, Z+0.50, GetPlayerVirtualWorld(playerid));
  107.                 fwrite(pos, string);
  108.                 fclose(pos);
  109.                 CreatePickup(strval(inputtext), 23, X, Y, Z, GetPlayerVirtualWorld(playerid));
  110.                 Create3DTextLabel(pickuptext, 0xFFFFFFAA, X, Y, Z+0.50, 5.0, GetPlayerVirtualWorld(playerid));
  111.                 SendClientMessage(playerid, -1, "{FFFFFF}Pickup telah dibuat, ketik /createpickup untuk membuat lagi.");
  112.                 pickupidmode = false;
  113.             }
  114.             else
  115.             {
  116.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_ID, DIALOG_STYLE_INPUT, "Pickup ID", "Masukan id pickup di bawan ini :", "Create", "Cancel");
  117.                 SendClientMessage(playerid, -1, "ID tidak diketahui.");
  118.             }
  119.         }
  120.         else
  121.         {
  122.             pickupidmode = false;
  123.         }
  124.     }
  125.     return 0;
  126. }
  127.  
  128. stock IsNumeric(const string[])
  129. {
  130.     for (new i = 0, j = strlen(string); i < j; i++)
  131.     {
  132.         if (string[i] > '9' || string[i] < '0') return 0;
  133.     }
  134.     return 1;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment