Guest User

Untitled

a guest
Nov 16th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. local bike_stands = {
  2. {name="Bike Rental", id=376, x=103.675, y=-1074.48, z=29.192},
  3. {name="Bike Rental", id=376, x=-899.22, y=-153.433, z=41.884},
  4. {name="Bike Rental", id=376, x=1034.23, y=-767.52, z=58.00},
  5. {name="Bike Rental", id=376, x=120.412, y=6625.959, z=31.953}
  6. }
  7.  
  8. local bikes = {
  9. {name="Bmx Bike", desc="Rent a Bmx Bike.", h="bmx", price=75},
  10. {name="Cruiser", desc="Rent a Cruiser.", h="cruiser", price=90},
  11. {name="Scorcher", desc="Rent a Scorcher.", h="scorcher", price=125}
  12. }
  13.  
  14.  
  15.  
  16. menuOpen = false
  17. _menuPool = NativeUI.CreatePool()
  18. mainMenu = NativeUI.CreateMenu("Bike Stand", "~b~Bike Rentals")
  19.  
  20. function spawnBike(bike)
  21. local px,py,pz = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
  22. local tbike = GetHashKey(bike)
  23. RequestModel(tbike)
  24. Citizen.Wait(100)
  25. nbike = CreateVehicle(tbike, px, py, pz, GetEntityHeading(PlayerPedId())+90, 1, 0)
  26. SetPedIntoVehicle(GetPlayerPed(-1), nbike, -1)
  27. end
  28.  
  29. for n,i in pairs(bikes) do
  30. local bike = NativeUI.CreateItem(i.name,i.desc)
  31. mainMenu:AddItem(bike)
  32. bike.Activated = function(ParentMenu,SelectedItem)
  33. -- Add money IF statement to test if they have enough
  34. spawnBike(i.h)
  35. _menuPool:CloseAllMenus()
  36. --TriggerServerEvent("pay", i.price)
  37. end
  38. end
  39.  
  40. _menuPool:Add(mainMenu)
  41. _menuPool:RefreshIndex()
  42. Citizen.CreateThread(function()
  43. for _, item in pairs(bike_stands) do
  44. item.blip = AddBlipForCoord(item.x, item.y, item.z)
  45. SetBlipSprite(item.blip, item.id)
  46. SetBlipScale(item.blip, 0.5)
  47. SetBlipColour(item.blip, 24)
  48. SetBlipAsShortRange(item.blip, true)
  49. BeginTextCommandSetBlipName("STRING")
  50. AddTextComponentString(item.name)
  51. EndTextCommandSetBlipName(item.blip)
  52. end
  53. while true do
  54. Citizen.Wait(0)
  55. _menuPool:ProcessMenus()
  56. _menuPool:ControlDisablingEnabled(false)
  57. _menuPool:MouseControlsEnabled(false)
  58. local pos = GetEntityCoords(GetPlayerPed(-1), true)
  59. for k,v in ipairs(bike_stands) do
  60. if(Vdist(pos.x, pos.y, pos.z, v.x, v.y, v.z) < 15.0)then
  61. DrawMarker(1, v.x, v.y, v.z - 1, 0, 0, 0, 0, 0, 0, 2.0001, 2.0001, 0.5001, 1555, 0, 0,165, 0, 0, 0,0)
  62. if(Vdist(pos.x, pos.y, pos.z, v.x, v.y, v.z) < 2.0)then
  63. if (menuOpen == false) then
  64. showHelpText("Press ~INPUT_CONTEXT~ to rent a bicycle")
  65. end
  66. if IsControlJustPressed(1, 51) then
  67. mainMenu:Visible(not mainMenu:Visible())
  68. TriggerServerEvent("checkCash")
  69. end
  70. else
  71. _menuPool:CloseAllMenus()
  72. end
  73. end
  74. end
  75. end
  76. end)
  77.  
  78.  
  79.  
  80. function showHelpText(str)
  81. SetTextComponentFormat("STRING")
  82. AddTextComponentString(str)
  83. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  84. end
Add Comment
Please, Sign In to add comment