Advertisement
Guest User

Инвентарь

a guest
May 31st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.35 KB | None | 0 0
  1. local items =
  2. {
  3. {"AK47", 4.8},
  4. {"Магазин AK47",0.3},
  5. {"Полицейская форма", 1},
  6. {"Аптечка", 1},
  7. {"Бинт", 1},
  8. {"Хлеб",1},
  9. {"Вода",1}
  10. }
  11.  
  12. local playerDataTable =
  13. {
  14.     "dayz.save_x",
  15.     "dayz.save_y",
  16.     "dayz.save_z",
  17.     "dayz.primary_weapon_slot",
  18.     "dayz.second_weapon_slot",
  19.     "dayz.fast_slot1",
  20.     "dayz.fast_slot2",
  21.     "dayz.fast_slot3",
  22.     "dayz.mask_slot",
  23.     "dayz.armor_slot"
  24. }
  25. GUIEditor = {
  26.     gridlist = {},
  27.     window = {},
  28.     button = {},
  29.     label = {}
  30. }
  31. addEventHandler("onClientResourceStart", resourceRoot,
  32.     function()
  33.                 local screenW, screenH = guiGetScreenSize()
  34.         GUIEditor.window[1] = guiCreateWindow((screenW - 528) / 2, (screenH - 600) / 2, 528, 600, "Статистика", false)
  35.         guiWindowSetSizable(GUIEditor.window[1], false)
  36.         guiSetAlpha(GUIEditor.window[1], 0.59)
  37.  
  38.         GUIEditor.gridlist[1] = guiCreateGridList(232, 24, 286, 552, false, GUIEditor.window[1])
  39.         guiGridListAddColumn(GUIEditor.gridlist[1], "название", 0.3)
  40.         guiGridListAddColumn(GUIEditor.gridlist[1], "количество", 0.3)
  41.         guiGridListAddColumn(GUIEditor.gridlist[1], "вес", 0.3)
  42.         guiGridListAddRow(GUIEditor.gridlist[1])
  43.         guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "AK47", false, false)
  44.         guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "1", false, false)
  45.         guiGridListSetItemText(GUIEditor.gridlist[1], 0, 3, "4.8", false, false)
  46.  
  47.         GUIEditor.button[1] = guiCreateButton(-230, 7, 107, 97, "", false, GUIEditor.gridlist[1])
  48.  
  49.         GUIEditor.label[1] = guiCreateLabel(232, 576, 286, 14, "Слоты: 1/8шт. Вес 4.8/50 кг", false, GUIEditor.window[1])
  50.         guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
  51.         GUIEditor.button[2] = guiCreateButton(84, 98, 64, 138, "armor", false, GUIEditor.window[1])
  52.         GUIEditor.button[3] = guiCreateButton(10, 24, 64, 286, "second weapon", false, GUIEditor.window[1])
  53.         GUIEditor.button[4] = guiCreateButton(84, 24, 64, 64, "mask", false, GUIEditor.window[1])
  54.         GUIEditor.button[5] = guiCreateButton(158, 24, 64, 286, "primary weapon", false, GUIEditor.window[1])
  55.         GUIEditor.button[6] = guiCreateButton(84, 246, 64, 64, "special", false, GUIEditor.window[1])
  56.         GUIEditor.button[7] = guiCreateButton(10, 320, 64, 64, "F1", false, GUIEditor.window[1])
  57.         GUIEditor.button[8] = guiCreateButton(84, 320, 64, 64, "F2", false, GUIEditor.window[1])
  58.         GUIEditor.button[9] = guiCreateButton(158, 320, 64, 64, "F3", false, GUIEditor.window[1])  
  59.         guiSetVisible ( GUIEditor.window[1], false )
  60.     end
  61. )
  62.  
  63. function refreshInventory ( source )
  64.         local weight = 0
  65.         guiSetText ( GUIEditor.window[1], "Инвентарь: " .. getPlayerName(getLocalPlayer()))
  66.         if getElementData(getLocalPlayer(), "dayz.primary_weapon_slot") then
  67.                 guiSetText ( GUIEditor.button[5], items[getElementData(source, "dayz.primary_weapon_slot")][1] )
  68.                 weight = weight +  items[getElementData(getLocalPlayer(), "dayz.primary_weapon_slot")][2]
  69.         else
  70.                 guiSetText ( GUIEditor.button[5], "пусто" )
  71.         end
  72.         --[[
  73.         if getElementData(source, "dayz.second_weapon_slot") then
  74.                 guiSetText ( GUIEditor.button[3], items[getElementData(source, "dayz.second_weapon_slot")][1] )
  75.                 weight = weight +  items[getElementData(source, "dayz.second_weapon_slot")][2]
  76.         else
  77.                 guiSetText ( GUIEditor.button[3], "пусто" )
  78.         end
  79.        
  80.         if getElementData(source, "dayz.special_weapon_slot") then
  81.                 guiSetText ( GUIEditor.button[6], items[getElementData(source, "dayz.special_weapon_slot")][1] )
  82.                 weight = weight +  items[getElementData(source, "dayz.special_weapon_slot")][2]
  83.         else
  84.                 guiSetText ( GUIEditor.button[6], "пусто" )
  85.         end
  86.        
  87.         if getElementData(source, "dayz.fast_slot1") then
  88.                 guiSetText ( GUIEditor.button[7], items[getElementData(source, "dayz.fast_slot1")][1] )
  89.                 weight = weight +  items[getElementData(source, "dayz.fast_slot1")][2]
  90.         else
  91.                 guiSetText ( GUIEditor.button[7], "пусто" )
  92.         end
  93.        
  94.         if getElementData(source, "dayz.fast_slot2") then
  95.                 guiSetText ( GUIEditor.button[8], items[getElementData(source, "dayz.fast_slot2")][1] )
  96.                 weight = weight +  items[getElementData(source, "dayz.fast_slot2")][2]
  97.         else
  98.                 guiSetText ( GUIEditor.button[8], "пусто" )
  99.         end
  100.        
  101.         if getElementData(source, "dayz.fast_slot3") then
  102.                 guiSetText ( GUIEditor.button[9], items[getElementData(source, "dayz.fast_slot3")][1] )
  103.                 weight = weight +  items[getElementData(source, "dayz.fast_slot3")][2]
  104.         else
  105.                 guiSetText ( GUIEditor.button[9], "пусто" )
  106.         end
  107.        
  108.         if getElementData(source, "dayz.mask_slot") then
  109.                 guiSetText ( GUIEditor.button[4], items[getElementData(source, "dayz.mask_slot")][1] )
  110.                 weight = weight +  items[getElementData(source, "dayz.mask_slot")][2]
  111.         else
  112.                 guiSetText ( GUIEditor.button[4], "пусто" )
  113.         end
  114.        
  115.         if getElementData(source, "dayz.armor_slot") then
  116.                 guiSetText ( GUIEditor.button[2], items[getElementData(source, "dayz.armor_slot")][1] )
  117.                 weight = weight +  items[getElementData(source, "dayz.armor_slot")][2]
  118.         else
  119.                 guiSetText ( GUIEditor.button[2], "пусто" )
  120.         end
  121.        ]]--
  122.         guiSetText ( GUIEditor.label[1], "Вес: " .. weight .."/ 228кг." )
  123. end
  124.  
  125. function showInventory ( )        
  126.         if ( guiGetVisible ( GUIEditor.window[1] ) == true ) then -- check if the gui element is visible              
  127.                 guiSetVisible ( GUIEditor.window[1], false ) -- if it is, we hide it
  128.                                 showCursor(false)  
  129.         else              
  130.                 guiSetVisible ( GUIEditor.window[1], true ) -- if not, we make it visible
  131.                                 showCursor(true)  
  132.                                 refreshInventory(source)
  133.         end
  134. end
  135.  
  136. bindKey ( "i", "down", showInventory, getLocalPlayer() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement