Advertisement
Guest User

sklep_c.lua

a guest
Mar 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1.  
  2.  
  3.  
  4. local I=0
  5. local D=0
  6.  
  7.  
  8. local oferta ={
  9. --broń
  10. { name="Kominiarka", name_biernik="kominiarkę", itemid=105, count=1, cost=2000},
  11. { name="Nóż", name_biernik="nóż", itemid=81, count=1, cost=500},
  12. { name="Kij baseballowy", name_biernik="kij baseballowy", itemid=31, count=1, cost=300},
  13. { name="Glock", name_biernik="Glocka", itemid=30, count=1, cost=3500},
  14. { name="Desert Eagle", name_biernik="Desert Eagle", itemid=110, count=1, cost=5000},
  15. { name="Uzi", name_biernik="Uzi", itemid=112, count=1, cost=15000},
  16. { name="Shotgun", name_biernik="Shotguna", itemid=109, count=1, cost=10000},
  17. --amunicja
  18. { name="Amunicja Glock", name_biernik="amunicję do Glocka", itemid=145, count=50, cost=500},
  19. { name="Amunicja Desert Eagle", name_biernik="amunicję do Desert Eagle", itemid=132, count=50, cost=500},
  20. { name="Amunicja Uzi", name_biernik="amunicję do Uzi", itemid=134, count=50, cost=500},
  21. { name="Amunicja Shotgun", name_biernik="amunicję do Shotguna", itemid=131, count=50, cost=700},
  22. }
  23.  
  24.  
  25. GUI_sklep = guiCreateGridList(0.7713,0.2267,0.2025,0.63,true)
  26. guiGridListSetSelectionMode(GUI_sklep,0)
  27. GUI_sklep_c_nazwa=guiGridListAddColumn(GUI_sklep,"Nazwa",0.5)
  28. GUI_sklep_c_ilosc=guiGridListAddColumn(GUI_sklep,"Ilość",0.2)
  29. GUI_sklep_c_koszt=guiGridListAddColumn(GUI_sklep,"Koszt",0.2)
  30. guiSetVisible(GUI_sklep,false)
  31.  
  32.  
  33.  
  34. function oferta_fill()
  35. guiGridListClear(GUI_sklep)
  36.  
  37. for i,v in pairs(oferta) do
  38. if (v.row and isElement(v.row)) then destroyElement(v.row) end
  39.  
  40. v.row = guiGridListAddRow ( GUI_sklep )
  41. guiGridListSetItemText ( GUI_sklep, v.row, GUI_sklep_c_nazwa, v.name, false, false )
  42. guiGridListSetItemText ( GUI_sklep, v.row, GUI_sklep_c_ilosc, tostring(v.count), false, false)
  43.  
  44. guiGridListSetItemText ( GUI_sklep, v.row, GUI_sklep_c_koszt, v.cost.."$", false, false )
  45. if (v.cost>getPlayerMoney()) then
  46. guiGridListSetItemColor(GUI_sklep, v.row, GUI_sklep_c_koszt, 255,0,0)
  47. else
  48. guiGridListSetItemColor(GUI_sklep, v.row, GUI_sklep_c_koszt, 155,255,155)
  49. end
  50.  
  51. end
  52.  
  53. for i,v in ipairs(oferta) do
  54. end
  55. end
  56.  
  57.  
  58.  
  59. function oferta_wybor()
  60. local selectedRow, selectedCol = guiGridListGetSelectedItem( GUI_sklep );
  61. if (not selectedRow) then return end
  62. for i,v in pairs(oferta) do
  63. if (v.row==selectedRow) then
  64. if (v.cost>getPlayerMoney()) then
  65. outputChatBox("Nie stać Cię na to.", 255,0,0,true)
  66. return
  67. end
  68. -- guiSetVisible(GUI_sklep,false) -- aby nie klikli 2x
  69. -- exports["lss-gui"]:panel_hide()
  70. if (exports["lss-gui"]:eq_giveItem(v.itemid,v.count,v.subtype)) then
  71. triggerServerEvent("takePlayerMoney", localPlayer, v.cost)
  72. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zakupuje " .. v.name_biernik..".", 5, 15, true)
  73. end
  74.  
  75.  
  76. end
  77. end
  78. return
  79. end
  80.  
  81. addEventHandler( "onClientGUIDoubleClick", GUI_sklep, oferta_wybor, false );
  82.  
  83.  
  84. local lada=createColSphere(1675.27,-2113.98,13.55,2)
  85. setElementDimension(lada,D)
  86. setElementInterior(lada,I)
  87.  
  88. local result = exports.DB2:pobierzWyniki("SELECT * FROM lss_character_co WHERE co_id=?")
  89. addEventHandler("onClientColShapeHit", lada, function(hitElement, matchindDimension)
  90. if (hitElement~=localPlayer or not matchindDimension or getElementInterior(localPlayer)~=getElementInterior(source)) then return end
  91. if not (result~=1 and result~=2) then outputChatBox("Nie możesz zakupić broni!") return end
  92. oferta_fill()
  93. guiSetVisible(GUI_sklep,true)
  94. end)
  95.  
  96. addEventHandler("onClientColShapeLeave", lada, function(hitElement, matchindDimension)
  97. if (hitElement~=localPlayer or not matchindDimension or getElementInterior(localPlayer)~=getElementInterior(source)) then return end
  98. guiSetVisible(GUI_sklep,false)
  99. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement