Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. local marker=createMarker(358.59,163.00,1007.38, "cylinder", 1, 255, 255, 255, 155)
  2. setElementInterior(marker, 3)
  3.  
  4. local t=createElement("text")
  5. setElementPosition(t,358.59,163.00,1008.38)
  6. setElementInterior(t,3)
  7. setElementData(t,"name","Zmiana tablic rejestracyjnych")
  8.  
  9. local wm={}
  10. wm.window=guiCreateWindow(0.22, 0.22, 0.59, 0.53, "Zmiana tablic", true)
  11. guiWindowSetSizable(wm.window, false)
  12. guiWindowSetMovable(wm.window, false)
  13. guiSetVisible(wm.window, false)
  14. wm.gridlist=guiCreateGridList(0.03, 0.09, 0.93, 0.72, true, wm.window)
  15. guiGridListAddColumn(wm.gridlist, "ID", 0.2)
  16. guiGridListAddColumn(wm.gridlist, "Nazwa", 0.5)
  17. guiGridListAddColumn(wm.gridlist, "Tablica", 0.2)
  18. wm.edit=guiCreateEdit(0.04, 0.83, 0.27, 0.11, "", true, wm.window)
  19. wm.submit=guiCreateButton(0.35, 0.84, 0.28, 0.11, "Zmień tablicę(5000 PLN)", true, wm.window)
  20. wm.close=guiCreateButton(0.68, 0.84, 0.28, 0.11, "Zamknij", true, wm.window)
  21.  
  22. addEventHandler("onClientGUIClick", root, function(btn,state)
  23. if source == wm.submit then
  24. local selectedRow=guiGridListGetSelectedItem(wm.gridlist)
  25. local new_board=guiGetText(wm.edit)
  26. if selectedRow < 0 then return end
  27. local cost=5000
  28. if string.len(new_board) < 1 then
  29. outputChatBox("* Podaj więcej znaków.", 255, 0, 0)
  30. return
  31. end
  32. if string.len(new_board) > 5 then
  33. outputChatBox("* Podaj mniej znaków.", 255, 0, 0)
  34. return
  35. end
  36. if cost > getPlayerMoney(localPlayer) then
  37. outputChatBox("* Nie posiadasz tyle gotówki.", 255, 0, 0)
  38. return
  39. end
  40. local id=tostring(guiGridListGetItemText(wm.gridlist, selectedRow, 1))
  41. local name=tostring(guiGridListGetItemText(wm.gridlist, selectedRow, 2))
  42. triggerServerEvent("board:new", resourceRoot, id, name, new_board, cost)
  43. end
  44. if source == wm.close then
  45. if guiGetVisible(wm.window) == true then
  46. showCursor(false)
  47. guiSetVisible(wm.window, false)
  48. end
  49. end
  50. end)
  51.  
  52. addEvent("board:refresh", true)
  53. addEventHandler("board:refresh", resourceRoot, function(result)
  54. guiGridListClear(wm.gridlist)
  55. for i,v in pairs(result) do
  56. if string.len(v.plateText) < 1 then v.plateText="Brak" end
  57. local row=guiGridListAddRow(wm.gridlist)
  58. guiGridListSetItemText(wm.gridlist, row, 1, v.id, false, false)
  59. guiGridListSetItemText(wm.gridlist, row, 2, getVehicleNameFromModel(v.model), false, false)
  60. guiGridListSetItemText(wm.gridlist, row, 3, v.plateText or v.id, false, false)
  61. end
  62. end)
  63.  
  64. addEventHandler("onClientMarkerHit", marker, function(el,md)
  65. if el~=localPlayer then return end
  66. if not guiGetVisible(wm.gridlist) then
  67. showCursor(true)
  68. guiSetVisible(wm.window, true)
  69. triggerServerEvent("board:download", resourceRoot, el)
  70. end
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement