Facebook
From Mature Motmot, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 283
  1. stock ListPlayerGroundItems(playerid)
  2. {
  3.     new list_items[512], main_query[2048], query[256],
  4.         ground_item_uid, ground_item_name[40];
  5.  
  6.     format(main_query, sizeof(main_query), "SELECT `item_uid`, `item_name` FROM `ipb_items` WHERE ");
  7.  
  8.     DynamicGui_Init(playerid);
  9.  
  10.     if(!IsPlayerInAnyVehicle(playerid))
  11.     {
  12.         new object_id = INVALID_OBJECT_ID, Float:distance,
  13.             Float:PosX, Float:PosY, Float:PosZ;
  14.  
  15.         GetPlayerPos(playerid, PosX, PosY, PosZ);
  16.         for (new player_object = 0; player_object <= MAX_VISIBLE_OBJECTS; player_object++)
  17.         {
  18.             if(IsValidPlayerObject(playerid, player_object))
  19.             {
  20.                 object_id = Streamer_GetItemStreamerID(playerid, STREAMER_TYPE_OBJECT, player_object);
  21.                 Streamer_GetDistanceToItem(PosX, PosY, PosZ, STREAMER_TYPE_OBJECT, object_id, distance);
  22.  
  23.                 if(distance <= 3.0 && Object[object_id][object_uid] == 0)
  24.                 {
  25.                     ground_item_uid = (Streamer_GetIntData(STREAMER_TYPE_OBJECT, object_id, E_STREAMER_EXTRA_ID) * -1);
  26.                     format(query, sizeof(query), "item_uid = %d", ground_item_uid);
  27.  
  28.                                         if(strlen(main_query) > 64)
  29.                                         {
  30.                                         if(strlen(main_query) + strlen(query) < sizeof(main_query))
  31.                                         {
  32.                                                         strcat(main_query, " OR ", sizeof(main_query));
  33.                                                 }
  34.                                                 else
  35.                                                 {
  36.                                                 strcat(main_query, ";", sizeof(main_query));
  37.                                                 }
  38.                                         }
  39.                                         strcat(main_query, query, sizeof(main_query));
  40.                 }
  41.             }
  42.         }
  43.  
  44.         if(!ground_item_uid)
  45.         {
  46.                 SendPlayerInformation(playerid, "Nie odnaleziono zadnych przedmiotow w poblizu.", 3000);
  47.                 return 1;
  48.         }
  49.        
  50.         new rows, fields;
  51.        
  52.         mysql_query(mySQLconnection, main_query);
  53.         cache_get_data(rows, fields);
  54.        
  55.                 for(new row = 0; row != rows; row++)
  56.                 {
  57.                         ground_item_uid = cache_get_row_int(row, 0);
  58.                         cache_get_row(row, 1, ground_item_name, mySQLconnection, 40);
  59.  
  60.                         format(list_items, sizeof(list_items), "%s\n%d\t%s", list_items, ground_item_uid, ground_item_name);
  61.                         DynamicGui_AddRow(playerid, DG_ITEMS_PICKUP_ROW, ground_item_uid);
  62.                 }
  63.                
  64.                 if(strlen(list_items) > 0)
  65.                 {
  66.                         ShowPlayerDialog(playerid, DIALOG_ITEMS_PICKUP, DIALOG_STYLE_LIST, "Przedmioty w pobliżu:", list_items, "Podnieś", "Anuluj");
  67.         }
  68.         else
  69.         {
  70.                 SendPlayerInformation(playerid, "~w~Brak przedmiotow w poblizu.", 3000);
  71.                 }
  72.     }
  73.     else
  74.     {
  75.         new vid = GetPlayerVehicleID(playerid), rows, fields;
  76.  
  77.         new gid = pInfo[playerid][player_duty_gid];
  78.         if(gid != -1)
  79.         {
  80.                 if(!GroupHasFlag(gid, GROUP_FLAG_TAKE))
  81.                 {
  82.                         if(!CanPlayerUseVehicle(playerid, vid))
  83.                         {
  84.                                 SendGuiInformation(playerid, "Informacja", "Nie posiadasz uprawnień do przeszukiwania tego pojazdu.");
  85.                                 return 1;
  86.                         }
  87.                     }
  88.             }
  89.             else
  90.             {
  91.                 if(!CanPlayerUseVehicle(playerid, vid))
  92.                 {
  93.                         SendGuiInformation(playerid, "Informacja", "Nie posiadasz uprawnień do przeszukiwania tego pojazdu.");
  94.                         return 1;
  95.                 }
  96.             }
  97.  
  98.         mysql_query(mySQLconnection, sprintf("SELECT item_uid, item_name FROM ipb_items WHERE item_owner = %d AND item_ownertype = %d", Vehicle[vid][vehicle_uid], ITEM_OWNER_TYPE_VEHICLE));
  99.         cache_get_data(rows, fields);
  100.  
  101.         for(new row = 0; row != rows; row++)
  102.                 {
  103.                     ground_item_uid = cache_get_row_int(row, 0);
  104.                         cache_get_row(row, 1, ground_item_name, mySQLconnection, 40);
  105.  
  106.                         format(list_items, sizeof(list_items), "%s\n%d\t%s", list_items, ground_item_uid, ground_item_name);
  107.                         DynamicGui_AddRow(playerid, DG_ITEMS_PICKUP_ROW, ground_item_uid);
  108.                 }
  109.  
  110.                 if(strlen(list_items) > 0)
  111.                 {
  112.                         ShowPlayerDialog(playerid, DIALOG_ITEMS_PICKUP, DIALOG_STYLE_LIST, "Przedmioty w pojeździe:", list_items, "Podnieś", "Anuluj");
  113.         }
  114.         else
  115.         {
  116.                 SendPlayerInformation(playerid, "Nie odnaleziono zadnych przedmiotow ~y~w pojezdzie~w~.", 3000);
  117.                 }
  118.     }
  119.     return 1;
  120. }