Guest User

Untitled

a guest
Dec 5th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. teams = {"Liberation Army", "Imperial Forces"}
  2.  
  3. function getPos()
  4. local x, y ,z = getElementPosition(localPlayer)
  5. local pos = tostring(x..", "..y..", "..z)
  6. outputChatBox(pos, 255, 100, 100, false)
  7. setClipboard(pos)
  8. end
  9. addCommandHandler("pos", getPos)
  10.  
  11. ---- GUI Creation
  12. addEventHandler("onClientResourceStart", resourceRoot,
  13. function()
  14. window = guiCreateWindow(0.57, 0.25, 0.19, 0.37, "Spawn Menu", true)
  15. guiWindowSetMovable(window, false)
  16. guiWindowSetSizable(window, false)
  17. guiSetAlpha(window, 1.00)
  18. team_gridlist = guiCreateGridList(10, 32, 284, 98, false, window)
  19. column = guiGridListAddColumn(team_gridlist, "Team", 0.9)
  20. for i, teamtext in pairs(teams) do
  21. local row = guiGridListAddRow(team_gridlist, teamtext)
  22. end
  23. skin_label = guiCreateLabel(58, 248, 71, 15, "Select a skin", false, window)
  24. skin_btn_next = guiCreateButton(96, 273, 33, 16, ">", false, window)
  25. skin_btn_previous = guiCreateButton(58, 273, 33, 16, "<", false, window)
  26. location_gridlist = guiCreateGridList(10, 140, 284, 98, false, window)
  27. location_col = guiGridListAddColumn(location_gridlist, "Location", 0.9)
  28. weapon_label = guiCreateLabel(155, 248, 96, 15, "Select a weapon", false, window)
  29. weapon_btn_next = guiCreateButton(165, 273, 33, 16, ">", false, window)
  30. weapon_btn_previous = guiCreateButton(204, 273, 33, 16, "<", false, window)
  31. spawn_btn = guiCreateButton(114, 299, 67, 24, "Spawn", false, window)
  32. guiSetVisible(window, false)
  33. end
  34. )
  35.  
  36. ---- GUI functions
  37. function isGUIVisible(gui)
  38. return (guiGetVisible(gui) == true)
  39. end
  40.  
  41. function getSelectedTeam()
  42. local row, col = guiGridListGetSelectedItem(team_gridlist)
  43. if row and col and row ~= -1 and col ~= -1 then
  44. return guiGridListGetItemText(team_gridlist, row, col)
  45. else
  46. return false
  47. end
  48. end
  49.  
  50. function isSkinValid(skinid)
  51. local allSkins = getValidPedModels()
  52. for _, skin in ipairs(allSkins) do
  53. if skin == tonumber(skinid) then
  54. return true
  55. else
  56. return false
  57. end
  58. end
  59. end
  60.  
  61. -- Make the GUI appear on login.
  62. addEvent("onClientPlayerLoginn", true)
  63. addEventHandler("onClientPlayerLoginn", root, function()
  64. if isGUIVisible(window) then
  65. return
  66. end
  67. guiSetVisible(window, true)
  68.  
  69. -- Set the camera to the desired location.
  70. setCameraMatrix(-2610.9792480469, 1445.4840087891, 7.1875, -2610.9792480469, 1445.4840087891, 7.1875)
  71.  
  72. -- Make a ped with default skin (0).
  73. ped = createPed(0, -2614.0212402344, 1451.1651611328, 7.1875, 180)
  74. end)
  75.  
  76. -- Set team
  77. addEventHandler("onClientGUIClick", resourceRoot, function()
  78. if (source == spawn_btn) then
  79. local team = getSelectedTeam()
  80. if team then
  81. triggerServerEvent("setTeam", localPlayer, team)
  82. end
  83. end
  84. end)
  85.  
  86. local LALocations = {"LA Test 1", "LA Test 2", "LA Test 3"}
  87. local IFLocations = {"IF Test 1", "IF Test 2", "IF Test 3"}
  88.  
  89. -- Location (according to the team)
  90. addEventHandler("onClientGUIClick", resourceRoot, function()
  91. if source == team_gridlist then
  92. local team = getSelectedTeam()
  93. if team then
  94. guiGridListClear(location_gridlist)
  95. if team == "Liberation Army" then
  96. for _, locations_LA in ipairs(LALocations) do
  97. local location_row_LA = guiGridListAddRow(location_gridlist, locations_LA)
  98. end
  99. elseif team == "Imperial Forces" then
  100. for _, locations_IF in ipairs(IFLocations) do
  101. local location_row_IF = guiGridListAddRow(location_gridlist, locations_IF)
  102. end
  103. end
  104. end
  105. end
  106.  
  107. -- Skin
  108.  
  109. local skin = getElementModel(ped)
  110. local new_skin = skin + 1
  111. local previous_skin = new_skin - 1
  112.  
  113. if source == skin_btn_next then
  114. if isSkinValid(new_skin) then
  115. setElementModel(ped, new_skin)
  116. else
  117. setElementModel(ped, new_skin + 1)
  118. end
  119. end
  120. if source == skin_btn_previous then
  121. setElementModel(ped, previous_skin)
  122. end
  123.  
  124. end)
  125. -- Skin
  126. -- Weapon
Add Comment
Please, Sign In to add comment