Advertisement
Guest User

truckerjob.lua

a guest
Jun 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.31 KB | None | 0 0
  1. -- v0.3
  2. -- misspellings fixed
  3. -- Blip fixed
  4. -- added testingmission
  5. -- better button selection (slower)
  6. local Keys = {
  7. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  8. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  9. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  10. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  11. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  12. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  13. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  14. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  15. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  16. }
  17.  
  18. --use this for debugging
  19. function Chat(t)
  20. TriggerEvent("chatMessage", 'TRUCKER', { 0, 255, 255}, "" .. tostring(t))
  21. end
  22.  
  23. --locations
  24. --arrays
  25. local TruckingCompany = {}
  26. TruckingCompany[0] = {["x"] = 1145.352,["y"] = -3284.845, ["z"] = 5.900}
  27. local TruckingTrailer = {}
  28. TruckingTrailer[0] = {["x"] = 1139.186, ["y"] = -3284.835, ["z"] = 5.899}
  29.  
  30. local Truck = {"HAULER", "PACKER", "PHANTOM"}
  31. local Trailer = {"TANKER", "TRAILERS", "TRAILERS2", "TRAILERLOGS", "TR4", "DOCKTRAILER"}
  32.  
  33. local MissionData = {
  34. [0] = {1748.2829, -1497.9902, 112.8044, 4400}, --x,y,z,money - change prices at 347 aswell - add anymore missions to 350 aswell - 103 to make useable
  35. [1] = {-1065.0643, -2436.2802, 13.9445, 4840},
  36. [2] = {2574.5144, 328.5554, 108.45, 6710},
  37. [3] = {1212.4463, 2667.4351, 38.79, 9350},
  38. [4] = {-2565.0894, 2345.8904, 33.06, 12100},
  39. [5] = {1706.7966, 4943.9897, 42.16, 14300},
  40. [6] = {-572.7017, 5336.4072, 70.2144, 14960},
  41. [7] = {196.5617, 6631.0967, 31.53, 17160}
  42. }
  43. local MISSION = {}
  44. MISSION.start = false
  45. MISSION.tailer = false
  46. MISSION.truck = false
  47.  
  48. MISSION.hashTruck = 0
  49. MISSION.hashTrailer = 0
  50.  
  51. local currentMission = -1
  52.  
  53. local playerCoords
  54. local playerPed
  55.  
  56. local GUI = {}
  57. GUI.loaded = false
  58. GUI.showStartText = false
  59. GUI.showMenu = false
  60. GUI.selected = {}
  61. GUI.menu = -1 --current menu
  62.  
  63. GUI.title = {}
  64. GUI.titleCount = 0
  65.  
  66. GUI.desc = {}
  67. GUI.descCount = 0
  68.  
  69. GUI.button = {}
  70. GUI.buttonCount = 0
  71.  
  72. GUI.time = 0
  73.  
  74. --text for mission
  75. local text1 = false
  76. local text2 = false
  77.  
  78. --blips
  79. local BLIP = {}
  80.  
  81. BLIP.company = 0
  82.  
  83. BLIP.trailer = {}
  84. BLIP.trailer.i = 0
  85.  
  86. BLIP.destination = {}
  87. BLIP.destination.i = 0
  88.  
  89. --focus button color
  90. local r = 0
  91. local g= 128
  92. local b = 192
  93. local alpha = 200
  94.  
  95. function clear()
  96. MISSION.start = false
  97. SetBlipRoute(BLIP.destination[BLIP.destination.i], false)
  98. SetEntityAsNoLongerNeeded(BLIP.destination[BLIP.destination.i])
  99.  
  100. if ( DoesEntityExist(MISSION.trailer) ) then
  101. SetEntityAsNoLongerNeeded(MISSION.trailer)
  102. end
  103. if ( DoesEntityExist(MISSION.truck) ) then
  104. SetEntityAsNoLongerNeeded(MISSION.truck)
  105. SetVehicleDoorsLocked(MISSION.truck, 2)
  106. SetVehicleUndriveable(MISSION.truck, false)
  107. end
  108. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(MISSION.trailer))
  109. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(MISSION.truck))
  110.  
  111. MISSION.trailer = 0
  112. MISSION.truck = 0
  113. MISSION.hashTruck = 0
  114. MISSION.hashTrailer = 0
  115. currentMission = -1
  116. end
  117.  
  118. local initload = false
  119. Citizen.CreateThread(function()
  120. while true do
  121. Wait(0)
  122. playerPed = GetPlayerPed(-1)
  123. playerCoords = GetEntityCoords(playerPed, 0)
  124. if (not initload) then
  125. init()
  126. initload = true
  127. end
  128. tick()
  129. end
  130.  
  131. end)
  132.  
  133. function init()
  134. BLIP.company = AddBlipForCoord(TruckingCompany[0]["x"], TruckingCompany[0]["y"], TruckingCompany[0]["z"])
  135. SetBlipSprite(BLIP.company, 67)
  136. SetBlipDisplay(BLIP.company, 3)
  137. SetBlipScale(BLIP.company, 1.0)
  138. SetBlipAsMissionCreatorBlip(blip,true)
  139. SetBlipAsShortRange(blip,true)
  140. Citizen.Trace("")
  141. -- GUI.loaded = true
  142. end
  143.  
  144. --Draw Text / Menus
  145. function tick()
  146.  
  147. --debugging stange things
  148. if ( type(BLIP.trailer[BLIP.trailer.i]) == "boolean" ) then
  149. --Citizen.Trace("-FAIL!-")
  150. elseif( BLIP.trailer[BLIP.trailer.i] == nil ) then
  151. --Citizen.Trace("-nil-")
  152. else
  153. BLIP.trailer[BLIP.trailer.i] = BLIP.trailer[BLIP.trailer.i]
  154. BLIP.destination[BLIP.destination.i] = BLIP.destination[BLIP.destination.i]
  155. end
  156.  
  157.  
  158. --Show menu, when player is near
  159. if( MISSION.start == false) then
  160. if( GetDistanceBetweenCoords( playerCoords, TruckingCompany[0]["x"], TruckingCompany[0]["y"], TruckingCompany[0]["z"] ) < 10) then
  161. if(GUI.showStartText == false) then
  162. GUI.drawStartText()
  163. end
  164. --key controlling
  165. if(IsControlPressed(1, Keys["N+"]) and GUI.showMenu == false) then
  166. --clear()
  167. GUI.showMenu = true
  168. GUI.menu = 0
  169. end
  170. if(IsControlPressed(1, Keys["N-"]) and GUI.showMenu == true) then
  171. GUI.showMenu = false
  172. end
  173. else
  174. GUI.showStartText = false
  175. end --if GetDistanceBetweenCoords ...
  176.  
  177. --menu
  178. if( GUI.loaded == false ) then
  179. GUI.init()
  180. end
  181.  
  182. if( GUI.showMenu == true and GUI.menu ~= -1) then
  183. if( GUI.time == 0) then
  184. GUI.time = GetGameTimer()
  185. end
  186. if( (GetGameTimer() - GUI.time) > 10) then
  187. GUI.updateSelectionMenu(GUI.menu)
  188. GUI.time = 0
  189. end
  190. GUI.renderMenu(GUI.menu)
  191. end --if GUI.loaded == false
  192. elseif( MISSION.start == true ) then
  193.  
  194. MISSION.markerUpdate(IsEntityAttached(MISSION.trailer))
  195. if( IsEntityAttached(MISSION.trailer) and text1 == false) then
  196. TriggerEvent("mt:missiontext", "Drive to the marked ~g~destination~w~.", 10000)
  197. text1 = true
  198. elseif( not IsEntityAttached(MISSION.trailer) and text2 == false ) then
  199. TriggerEvent("mt:missiontext", "Attach the ~o~trailer~w~.", 15000)
  200. text2 = true
  201. end
  202. Wait(2000)
  203. local trailerCoords = GetEntityCoords(MISSION.trailer, 0)
  204. if ( GetDistanceBetweenCoords(currentMission[1], currentMission[2], currentMission[3], trailerCoords ) < 25 and not IsEntityAttached(MISSION.trailer)) then
  205. TriggerEvent("mt:missiontext", "You gained $"..currentMission[4], 5000)
  206. MISSION.removeMarker()
  207. TriggerServerEvent('truckerJob:success',currentMission[4])
  208. clear()
  209. elseif ( GetDistanceBetweenCoords(currentMission[1], currentMission[2], currentMission[3], trailerCoords ) < 25 and IsEntityAttached(MISSION.trailer) ) then
  210. TriggerEvent("mt:missiontext", "Arrived. Detach your ~o~trailer~w~ with ~r~H~w~", 15000)
  211. end
  212.  
  213. if ( IsEntityDead(MISSION.trailer) or IsEntityDead(MISSION.truck) ) then
  214. MISSION.removeMarker()
  215. clear()
  216. end
  217. end --if MISSION.start == false
  218. end
  219.  
  220.  
  221.  
  222. ---------------------------------------
  223. ---------------------------------------
  224. ---------------------------------------
  225. ----------------MISSON-----------------
  226. ---------------------------------------
  227. ---------------------------------------
  228. ---------------------------------------
  229. function GUI.optionMisson(trailerN)
  230.  
  231. --select trailer
  232. MISSION.hashTrailer = GetHashKey(Trailer[trailerN + 1])
  233. RequestModel(MISSION.hashTrailer)
  234.  
  235. while not HasModelLoaded(MISSION.hashTrailer) do
  236. Wait(1)
  237. end
  238.  
  239. --select random truck
  240. local randomTruck = GetRandomIntInRange(1, #Truck)
  241.  
  242. MISSION.hashTruck = GetHashKey(Truck[randomTruck])
  243. RequestModel(MISSION.hashTruck)
  244.  
  245. while not HasModelLoaded(MISSION.hashTruck) do
  246. Wait(1)
  247. end
  248. end
  249.  
  250. function GUI.mission(missionN)
  251. --currently one destination per ride
  252. BLIP.trailer.i = BLIP.trailer.i + 1
  253. BLIP.destination.i = BLIP.destination.i + 1
  254. currentMission = MissionData[missionN]
  255. GUI.showMenu = false
  256. --mission start
  257. MISSION.start = true
  258. MISSION.spawnTrailer()
  259. MISSION.spawnTruck()
  260. end
  261.  
  262. function MISSION.spawnTruck()
  263.  
  264. MISSION.truck = CreateVehicle(MISSION.hashTruck, 1145.352, -3284.845, 5.900, 0.0, true, false)
  265. SetVehicleOnGroundProperly(MISSION.trailer)
  266. SetVehicleNumberPlateText(MISSION.truck, "M15510")
  267. SetVehRadioStation(MISSION.truck, "OFF")
  268. SetPedIntoVehicle(playerPed, MISSION.truck, -1)
  269. SetVehicleEngineOn(MISSION.truck, true, false, false)
  270.  
  271. --important
  272. --SetEntityAsMissionEntity(MISSION.truck, true, true);
  273. end
  274.  
  275. function MISSION.spawnTrailer()
  276. MISSION.trailer = CreateVehicle(MISSION.hashTrailer, TruckingTrailer[0]["x"], TruckingTrailer[0]["y"], TruckingTrailer[0]["z"], 0.0, true, false)
  277. SetVehicleOnGroundProperly(MISSION.trailer)
  278.  
  279. --setMarker on trailer
  280. MISSION.trailerMarker()
  281. end
  282.  
  283. local oneTime = false
  284.  
  285. function MISSION.trailerMarker()
  286. --BLIP.trailer.i = BLIP.trailer.i + 1 this happens in GUI.mission()
  287. BLIP.trailer[BLIP.trailer.i] = AddBlipForEntity(MISSION.trailer)
  288. SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 1)
  289. SetBlipColour(BLIP.trailer[BLIP.trailer.i], 17)
  290. SetBlipRoute(BLIP.trailer[BLIP.trailer.i], false)
  291. Wait(50)
  292. end
  293.  
  294. function MISSION.markerUpdate(trailerAttached)
  295. if( not BLIP.destination[BLIP.destination.i] and trailerAttached) then
  296. -- BLIP.destination.i = BLIP.destination.i + 1 this happens in GUI.mission()
  297. BLIP.destination[BLIP.destination.i] = AddBlipForCoord(currentMission[1], currentMission[2], currentMission[3])
  298. SetBlipSprite(BLIP.destination[BLIP.destination.i], 1)
  299. SetBlipColour(BLIP.destination[BLIP.destination.i], 2)
  300. SetBlipRoute(BLIP.destination[BLIP.destination.i], true)
  301. end
  302. if( trailerAttached ) then
  303. SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 2) --invisible
  304. elseif ( not trailerAttached and BLIP.trailer[BLIP.trailer.i]) then
  305. SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 1) --visible
  306. SetBlipColour(BLIP.trailer[BLIP.trailer.i], 17)
  307. end
  308. Wait(50)
  309. end
  310.  
  311. function MISSION.removeMarker()
  312. SetBlipSprite(BLIP.destination[BLIP.destination.i], 2)--invisible
  313. SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 2) --invisible
  314. end
  315.  
  316. function MISSION.getMoney()
  317. TriggerEvent("es:addedMoney", currentMission[4])
  318. TriggerEvent("truckerJob:getMoney", currentMission[4])
  319. end
  320. ---------------------------------------
  321. ---------------------------------------
  322. ---------------------------------------
  323. -----------------MENU------------------
  324. ---------------------------------------
  325. ---------------------------------------
  326. ---------------------------------------
  327. function GUI.drawStartText()
  328. TriggerEvent("mt:missiontext", "You want to be a trucker? Press ~r~N+~w~ to start.", 500)
  329. --GUI.showStartText = true
  330. end
  331.  
  332. function GUI.renderMenu(menu)
  333. GUI.renderTitle()
  334. GUI.renderDesc()
  335. GUI.renderButtons(menu)
  336. end
  337.  
  338. function GUI.init()
  339. GUI.loaded = true
  340. GUI.addTitle("", 0.425, 0.19, 0.45, 0.07 )
  341. GUI.addDesc("Choose a trailer.", 0.575, 0.375, 0.15, 0.30 )
  342.  
  343. --menu, title, function, position
  344. GUI.addButton(0, "RON Tanker trailer", GUI.optionMisson, 0.35, 0.25, 0.3, 0.05 )
  345. GUI.addButton(0, "Container trailer", GUI.optionMisson, 0.35, 0.30, 0.3, 0.05 )
  346. GUI.addButton(0, "Articulated trailer", GUI.optionMisson, 0.35, 0.35, 0.3, 0.05 )
  347. GUI.addButton(0, "Log trailer", GUI.optionMisson, 0.35, 0.40, 0.3, 0.05 )
  348. GUI.addButton(0, "Car Transporter", GUI.optionMisson, 0.35, 0.45, 0.3, 0.05 )
  349. GUI.addButton(0, "Shipping Container", GUI.optionMisson, 0.35, 0.50, 0.3, 0.05 )
  350. GUI.addButton(0, "Exit Menu", GUI.exit, 0.35, 0.55, 0.3, 0.05 )
  351.  
  352. GUI.buttonCount = 0
  353.  
  354. GUI.addButton(1, "Mission 1 [ $4400 ]", GUI.mission, 0.35, 0.25, 0.3, 0.05)
  355. GUI.addButton(1, "Mission 2 [ $4840 ]", GUI.mission, 0.35, 0.30, 0.3, 0.05)
  356. GUI.addButton(1, "Mission 3 [ $6710 ]", GUI.mission, 0.35, 0.35, 0.3, 0.05)
  357. GUI.addButton(1, "Mission 4 [ $9350 ]", GUI.mission, 0.35, 0.40, 0.3, 0.05)
  358. GUI.addButton(1, "Mission 5 [ $12100 ]", GUI.mission, 0.35, 0.45, 0.3, 0.05)
  359. GUI.addButton(1, "Mission 6 [ $14300 ]", GUI.mission, 0.35, 0.50, 0.3, 0.05)
  360. GUI.addButton(1, "Mission 7 [ $14960 ]", GUI.mission, 0.35, 0.55, 0.3, 0.05)
  361. GUI.addButton(1, "Mission 8 [ $17160 ]", GUI.mission, 0.35, 0.60, 0.3, 0.05)
  362. GUI.addButton(1, "Exit Menu", GUI.exit, 0.35, 0.65, 0.3, 0.05)
  363. end
  364.  
  365. --Render stuff
  366. function GUI.renderTitle()
  367. for id, settings in pairs(GUI.title) do
  368. local screen_w = 0
  369. local screen_h = 0
  370. screen_w, screen_h = GetScreenResolution(0,0)
  371. boxColor = {0,0,0,255}
  372. SetTextFont(0)
  373. SetTextScale(0.0, 0.40)
  374. SetTextColour(255, 255, 255, 255)
  375. SetTextCentre(true)
  376. SetTextDropshadow(0, 0, 0, 0, 0)
  377. SetTextEdge(0, 0, 0, 0, 0)
  378. SetTextEntry("STRING")
  379. AddTextComponentString(settings["name"])
  380. DrawText((settings["xpos"] + 0.001), (settings["ypos"] - 0.015))
  381. --AddTextComponentString(settings["name"])
  382. GUI.renderBox(
  383. settings["xpos"], settings["ypos"], settings["xscale"], settings["yscale"],
  384. boxColor[1], boxColor[2], boxColor[3], boxColor[4]
  385. )
  386. end
  387. end
  388.  
  389. function GUI.renderDesc()
  390. for id, settings in pairs(GUI.desc) do
  391. local screen_w = 0
  392. local screen_h = 0
  393. screen_w, screen_h = GetScreenResolution(0, 0)
  394. boxColor = {0,0,0,240}
  395. SetTextFont(0)
  396. SetTextScale(0.0, 0.37)
  397. SetTextColour(255, 255, 255, 255)
  398. SetTextDropShadow(0, 0, 0, 0, 0)
  399. SetTextEdge(0, 0, 0, 0, 0)
  400. SetTextEntry("STRING")
  401. AddTextComponentString(settings["name"] .. "\n" .."\n" .."Navigate with" .. "\n" .. "arrows." .. "\n" .. "ENTER to Select".. "\n" .."Hold H to Detach" .. "\n" .. "Trailer")
  402. DrawText((settings["xpos"] - 0.06), (settings["ypos"] - 0.13))
  403. AddTextComponentString(settings["name"])
  404. GUI.renderBox(
  405. settings["xpos"], settings["ypos"], settings["xscale"], settings["yscale"],
  406. boxColor[1], boxColor[2], boxColor[3], boxColor[4]
  407. )
  408. end
  409. end
  410.  
  411. function GUI.renderButtons(menu)
  412. for id, settings in pairs(GUI.button[menu]) do
  413. local screen_w = 0
  414. local screen_h = 0
  415. screen_w, screen_h = GetScreenResolution(0, 0)
  416. boxColor = {0,0,0,100}
  417. if(settings["active"]) then
  418. boxColor = {r,g,b,alpha}
  419. end
  420. SetTextFont(0)
  421. SetTextScale(0.0, 0.35)
  422. SetTextColour(255, 255, 255, 255)
  423. SetTextCentre(true)
  424. SetTextDropShadow(0, 0, 0, 0, 0)
  425. SetTextEdge(0, 0, 0, 0, 0)
  426. SetTextEntry("STRING")
  427. AddTextComponentString(settings["name"])
  428. DrawText((settings["xpos"] + 0.001), (settings["ypos"] - 0.015))
  429. --AddTextComponentString(settings["name"])
  430. GUI.renderBox(
  431. settings["xpos"], settings["ypos"], settings["xscale"],
  432. settings["yscale"], boxColor[1], boxColor[2], boxColor[3], boxColor[4]
  433. )
  434. end
  435. end
  436.  
  437. function GUI.renderBox(xpos, ypos, xscale, yscale, color1, color2, color3, color4)
  438. DrawRect(xpos, ypos, xscale, yscale, color1, color2, color3, color4);
  439. end
  440.  
  441. --adding stuff
  442. function GUI.addTitle(name, xpos, ypos, xscale, yscale)
  443. GUI.title[GUI.titleCount] = {}
  444. GUI.title[GUI.titleCount]["name"] = name
  445. GUI.title[GUI.titleCount]["xpos"] = xpos
  446. GUI.title[GUI.titleCount]["ypos"] = ypos
  447. GUI.title[GUI.titleCount]["xscale"] = xscale
  448. GUI.title[GUI.titleCount]["yscale"] = yscale
  449. end
  450.  
  451. function GUI.addDesc(name, xpos, ypos, xscale, yscale)
  452. GUI.desc[GUI.descCount] = {}
  453. GUI.desc[GUI.descCount]["name"] = name
  454. GUI.desc[GUI.descCount]["xpos"] = xpos
  455. GUI.desc[GUI.descCount]["ypos"] = ypos
  456. GUI.desc[GUI.descCount]["xscale"] = xscale
  457. GUI.desc[GUI.descCount]["yscale"] = yscale
  458. end
  459.  
  460. function GUI.addButton(menu, name, func, xpos, ypos, xscale, yscale)
  461. if(not GUI.button[menu]) then
  462. GUI.button[menu] = {}
  463. GUI.selected[menu] = 0
  464. end
  465. GUI.button[menu][GUI.buttonCount] = {}
  466. GUI.button[menu][GUI.buttonCount]["name"] = name
  467. GUI.button[menu][GUI.buttonCount]["func"] = func
  468. GUI.button[menu][GUI.buttonCount]["xpos"] = xpos
  469. GUI.button[menu][GUI.buttonCount]["ypos"] = ypos
  470. GUI.button[menu][GUI.buttonCount]["xscale"] = xscale
  471. GUI.button[menu][GUI.buttonCount]["yscale"] = yscale
  472. GUI.button[menu][GUI.buttonCount]["active"] = 0
  473. GUI.buttonCount = GUI.buttonCount + 1
  474. end
  475.  
  476. function GUI.null()
  477. end
  478.  
  479. function GUI.exit()
  480. GUI.showMenu = false
  481. print("Exit menu")
  482. end
  483.  
  484. --update stuff
  485. function GUI.updateSelectionMenu(menu)
  486. if( IsControlPressed(0, Keys["DOWN"]) ) then
  487. if( GUI.selected[menu] < #GUI.button[menu] ) then
  488. GUI.selected[menu] = GUI.selected[menu] + 1
  489. end
  490. elseif( IsControlPressed(0, Keys["TOP"]) ) then
  491. if( GUI.selected[menu] > 0 ) then
  492. GUI.selected[menu] = GUI.selected[menu] - 1
  493. end
  494. elseif( IsControlPressed(0, Keys["ENTER"]) ) then
  495. if( type(GUI.button[menu][GUI.selected[menu]]["func"]) == "function" ) then
  496. --remember variable GUI.selected[menu]
  497.  
  498. --call mission functions
  499. GUI.button[menu][GUI.selected[menu]]["func"](GUI.selected[menu])
  500.  
  501. GUI.menu = 1
  502. GUI.selected[menu] = 0
  503. if( not GUI.menu ) then
  504. GUI.menu = -1
  505. end
  506. Wait(100)
  507.  
  508. --GUI.button[menu][GUI.selected[menu]]["func"](GUI.selected[menu])
  509. else
  510. Citizen.Trace("\n Failes to call function! - Selected Menu: "..GUI.selected[menu].." \n")
  511. end
  512. GUI.time = 0
  513. end
  514. local i = 0
  515. for id, settings in ipairs(GUI.button[menu]) do
  516. GUI.button[menu][i]["active"] = false
  517. if( i == GUI.selected[menu] ) then
  518. GUI.button[menu][i]["active"] = true
  519. end
  520. i = i + 1
  521. end
  522. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement