Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. local window, gridlist, btn_close, btn_accept
  2. local sw, sh = guiGetScreenSize()
  3. local mw, mh = 800,600
  4.  
  5. local tp = {}
  6. tp.window = guiCreateWindow(269/mw*sw, 115/mh*sh, 263/mw*sw, 371/mh*sh, "Panel teleportów", false)
  7. guiWindowSetSizable(tp.window, false)
  8. tp.gridlist = guiCreateGridList(9/mw*sw, 22/mh*sh, 244/mw*sw, 305/mh*sh, false, tp.window)
  9. tp.gridlist_c_cmd = guiGridListAddColumn(tp.gridlist, "Komenda", 0.3)
  10. tp.gridlist_c_opis = guiGridListAddColumn(tp.gridlist, "Opis", 0.5)
  11. tp.btn_close = guiCreateButton(10/mw*sw, 333/mh*sh, 101/mw*sw, 28/mh*sh, "Anuluj", false, tp.window)
  12. tp.btn_accept = guiCreateButton(142/mw*sw, 333/mh*sh, 101/mw*sw, 28/mh*sh, "Teleportuj", false, tp.window)
  13. guiSetVisible(tp.window, false)
  14.  
  15. function drawWindow()
  16.     if getElementData(localPlayer, "auth:level") < 1 then return end
  17.     guiGridListClear(tp.gridlist)
  18.     guiSetVisible(tp.window, true)
  19.     guiSetEnabled(tp.btn_close, false)
  20.     guiSetEnabled(tp.btn_accept, false)
  21.     showCursor(true)
  22.     triggerServerEvent("pobierzTeleporty",localPlayer)
  23. end
  24. addCommandHandler("teleporty", drawWindow, false)  
  25.  
  26. addEventHandler( "onClientGUIClick", tp.btn_close, function()
  27.     guiSetVisible(tp.window, false)
  28.     showCursor(false)
  29. end,false)
  30.  
  31. local teleportsy
  32.  
  33. addEventHandler( "onClientGUIClick", tp.btn_accept, function()
  34.     if guiGridListGetSelectedItem(tp.gridlist) then
  35.         local item = guiGridListGetSelectedItem(tp.gridlist) + 1
  36.         for i,v in ipairs(teleportsy) do
  37.             local pos = split(v.position,",")
  38.             if i == item then
  39.                 setElementPosition(localPlayer,pos[1],pos[2],pos[3])
  40.                 setElementDimension(localPlayer,v.dim or 0)
  41.                 setElementInterior(localPlayer,v.i or 0)
  42.                 local loc_name = string.format("TP_%s> ",string.upper(v.command))
  43.                 outputChatBox("Przeteleportowano do: "..v.description)
  44.                 guiSetVisible(tp.window, false)
  45.                 showCursor(false)
  46.                 triggerServerEvent("showAdmin", root, loc_name, getPlayerName(localPlayer))
  47.             end
  48.         end
  49.     else
  50.         outputChatBox("Nie wybrano teleportu.", 255, 0, 0)
  51.         return
  52.     end
  53. end,false)
  54.  
  55. addEvent("odbierzTeleporty",true)
  56. addEventHandler("odbierzTeleporty",root,function(success, tps)
  57.     if success == false then
  58.         outputChatBox("Nie udało się pobrać teleportów.")
  59.         return
  60.     end
  61.     for i,v in ipairs(tps) do
  62.         local row = guiGridListAddRow(tp.gridlist)
  63.         guiGridListSetItemText(tp.gridlist, row, tp.gridlist_c_cmd, "/"..v.command,false,false) --element gridList, int rowIndex, int columnIndex, string text, bool section, bool number )
  64.         guiGridListSetItemText(tp.gridlist, row, tp.gridlist_c_opis, v.description,false,false)
  65.     end
  66.     teleportsy = tps
  67.     guiSetEnabled(tp.btn_close, true)
  68.     guiSetEnabled(tp.btn_accept, true)
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement