thenuke321

Untitled

May 21st, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 85.70 KB | None | 0 0
  1. screenWidth, screenHeight = guiGetScreenSize()
  2. scale = screenHeight * 4 / 720
  3. local dashboardDisplaying = false
  4. currentAnimationStyle = 1
  5. local animationStyles = {
  6.   [1] = {"OutQuad", 400},
  7.   [2] = {"OutBack", 700},
  8.   [3] = {"OutElastic", 1300}
  9. }
  10. local dashboard = {
  11.   canSwapLevel = true,
  12.   alpha = 0,
  13.   animationStartTime = getTickCount(),
  14.   animationEndTime = getTickCount() + 700,
  15.   animationEasingFunction = "OutBack",
  16.   currentLevel = 1,
  17.   viewportProgression = 1,
  18.   lastViewportProgression = 1
  19. }
  20. LAST_SELECTED_PLAYER = getLocalPlayer()
  21. menu = {}
  22. local tileSize = scale * 25
  23. local rootMenuItems = {
  24.   {
  25.     name = "Donator",
  26.     img = "img/dashboard/icons/group_full.png",
  27.     fn = "checkDonator",
  28.     args = {}
  29.   },
  30.   {
  31.     name = "Stats",
  32.     img = "img/dashboard/icons/statistics.png",
  33.     fn = "swapLevel",
  34.     args = {"statsMenu"}
  35.   },
  36.   {
  37.     name = "Store",
  38.     img = "img/dashboard/icons/shopping_cart.png",
  39.     fn = "swapLevel",
  40.     args = {"shopMenu"}
  41.   },
  42.   {
  43.     name = "Achievements",
  44.     img = "img/dashboard/icons/star_outline.png",
  45.     fn = "swapLevel",
  46.     args = {
  47.       "achievementsMenu"
  48.     }
  49.   },
  50.   {
  51.     name = "Garage",
  52.     img = "img/dashboard/icons/transportation_car.png",
  53.     fn = "initiateGarage",
  54.     args = {}
  55.   },
  56.   {
  57.     name = "Tasks",
  58.     img = "img/dashboard/icons/flag.png",
  59.     fn = "swapLevel",
  60.     args = {"taskMenu"}
  61.   },
  62.   {
  63.     name = "Settings",
  64.     img = "img/dashboard/icons/settings.png",
  65.     fn = "swapLevel",
  66.     args = {
  67.       "settingsMenu"
  68.     }
  69.   }
  70. }
  71. local startingPosition = screenWidth / 2 - (tileSize * #rootMenuItems + tileSize / 20 * #rootMenuItems) / 2 - tileSize
  72. menu.rootMenu = {}
  73. menu.rootMenu.tiles = {}
  74. menu.rootMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  75. for i, k in ipairs(rootMenuItems) do
  76.   menu.rootMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 - tileSize / 2, tileSize, tileSize, menu.rootMenu.form)
  77.   flowFormSetTileProperty(menu.rootMenu.tiles[i], "fn", k.fn)
  78.   flowFormSetTileProperty(menu.rootMenu.tiles[i], "args", k.args)
  79.   flowFormSetTileProperty(menu.rootMenu.tiles[i], "text", k.name)
  80.   flowFormSetTileProperty(menu.rootMenu.tiles[i], "color", {
  81.     255,
  82.     100,
  83.     0
  84.   })
  85.   flowFormSetTileProperty(menu.rootMenu.tiles[i], "image", k.img)
  86. end
  87. dx_stats = {
  88.   "Money: $",
  89.   "Exp: ",
  90.   "Skillpoints: ",
  91.   "Total SP earned: ",
  92.   "Wins: ",
  93.   "Maps played: ",
  94.   "Win percent: ",
  95.   "Highest streak: ",
  96.   "Achievements unlocked: ",
  97.   "Tasks completed: ",
  98.   "Times joined: ",
  99.   "Playtime: ",
  100.   "Hunters reached: ",
  101.   "Hunter percent: ",
  102.   "Toptimes taken: ",
  103.   "Rockets fired: ",
  104.   "Kills with Hunter: ",
  105.   "Kills in Shooter/CTF maps: ",
  106.   "Maps bought: ",
  107.   "Times changed vehicle: ",
  108.   "PVP wins: ",
  109.   "DM Maps played: ",
  110.   "DM Wins: ",
  111.   "DM Win percent: ",
  112.   "DD Maps played: ",
  113.   "DD Wins: ",
  114.   "DD Win percent: ",
  115.   "Race Maps played: ",
  116.   "Race Wins: ",
  117.   "Race Win percent: ",
  118.   "CTF Maps played: ",
  119.   "CTF Wins: ",
  120.   "CTF Win percent: ",
  121.   "CTF Flags taken: ",
  122.   "CTF Flags captured: ",
  123.   "Shooter Maps played: ",
  124.   "Shooter Wins: ",
  125.   "Shooter Win percent: "
  126. }
  127. menu.statsMenu = {}
  128. menu.statsMenu.labels = {}
  129. menu.statsMenu.tiles = {}
  130. menu.statsMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  131. local innerWidth = screenHeight / 1.4
  132. menu.statsMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - innerWidth / 2, scale * 40, screenWidth, screenHeight, getPlayerName(getLocalPlayer()), menu.statsMenu.form)
  133. flowFormSetLabelProperty(menu.statsMenu.labels[1], "colorcoded", true)
  134. flowFormSetLabelProperty(menu.statsMenu.labels[1], "scale", scale / 2)
  135. local row = 0
  136. local numberOfColumns = 2
  137. for i, k in ipairs(dx_stats) do
  138.   local i = i - 1
  139.   if i - row * #dx_stats / numberOfColumns == #dx_stats / numberOfColumns then
  140.     row = row + 1
  141.   end
  142.   local label = flowFormCreateLabel(screenWidth / 2 - innerWidth / 2 + row * (innerWidth * 1.2 / numberOfColumns), scale * 55 + scale * 4.5 * (i - row * math.floor(#dx_stats / numberOfColumns)), screenWidth, screenHeight, k .. "0", menu.statsMenu.form)
  143.   flowFormSetLabelProperty(label, "scale", scale / 3.1)
  144.   table.insert(menu.statsMenu.labels, label)
  145. end
  146. menu.statsMenu.tiles[1] = flowFormCreateTile(screenWidth / 2 - innerWidth / 2, screenHeight - tileSize * 1.5, tileSize, tileSize, menu.statsMenu.form)
  147. flowFormSetTileProperty(menu.statsMenu.tiles[1], "fn", "swapLevel")
  148. flowFormSetTileProperty(menu.statsMenu.tiles[1], "args", {
  149.   "[STEP_BACK]"
  150. })
  151. flowFormSetTileProperty(menu.statsMenu.tiles[1], "text", "Back")
  152. flowFormSetTileProperty(menu.statsMenu.tiles[1], "color", {
  153.   255,
  154.   100,
  155.   0
  156. })
  157. flowFormSetTileProperty(menu.statsMenu.tiles[1], "image", "img/dashboard/icons/arrow_full_left.png")
  158. menu.playerSelectionMenu = {}
  159. menu.playerSelectionMenu.buttons = {}
  160. menu.playerSelectionMenu.labels = {}
  161. menu.playerSelectionMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  162. menu.playerSelectionMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Select a player", scale / 2, "default-bold") / 2, scale * 30, screenWidth, screenHeight, "Select a player", menu.playerSelectionMenu.form)
  163. flowFormSetLabelProperty(menu.playerSelectionMenu.labels[1], "scale", scale / 2)
  164. local shopMenuItems = {
  165.   {
  166.     name = "Back",
  167.     img = "img/dashboard/icons/arrow_full_left.png",
  168.     fn = "swapLevel",
  169.     args = {
  170.       "[STEP_BACK]"
  171.     }
  172.   },
  173.   {
  174.     name = "Maps",
  175.     img = "img/dashboard/icons/website.png",
  176.     fn = "goToMapMenu",
  177.     args = {}
  178.   },
  179.   {
  180.     name = "Upgrades",
  181.     img = "img/dashboard/icons/transportation_car.png",
  182.     fn = "swapLevel",
  183.     args = {
  184.       "upgradesMenu"
  185.     }
  186.   }
  187. }
  188. local startingPosition = screenWidth / 2 - (tileSize * #shopMenuItems + tileSize / 20 * #shopMenuItems) / 2 - tileSize
  189. menu.shopMenu = {}
  190. menu.shopMenu.tiles = {}
  191. menu.shopMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  192. for i, k in ipairs(shopMenuItems) do
  193.   menu.shopMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 - tileSize / 2, tileSize, tileSize, menu.shopMenu.form)
  194.   flowFormSetTileProperty(menu.shopMenu.tiles[i], "fn", k.fn)
  195.   flowFormSetTileProperty(menu.shopMenu.tiles[i], "args", k.args)
  196.   flowFormSetTileProperty(menu.shopMenu.tiles[i], "text", k.name)
  197.   flowFormSetTileProperty(menu.shopMenu.tiles[i], "color", {
  198.     255,
  199.     100,
  200.     0
  201.   })
  202.   flowFormSetTileProperty(menu.shopMenu.tiles[i], "image", k.img)
  203. end
  204. menu.mapMainMenu = {}
  205. menu.mapMainMenu.tiles = {}
  206. menu.mapMainMenu.fields = {}
  207. menu.mapMainMenu.labels = {}
  208. menu.mapMainMenu.lists = {}
  209. menu.mapMainMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  210. local listWidth = scale * 120
  211. local listHeight = scale * 90
  212. local fieldWidth = math.floor(scale * 80)
  213. local fieldHeight = math.floor(scale * 6)
  214. menu.mapMainMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Maps", scale / 2, "default-bold") / 2, scale * 15, screenWidth, screenHeight, "Maps", menu.mapMainMenu.form)
  215. flowFormSetLabelProperty(menu.mapMainMenu.labels[1], "scale", scale / 2)
  216. menu.mapMainMenu.lists[1] = flowFormCreateList(screenWidth / 2 - listWidth / 2, screenHeight / 2 - listHeight / 2, listWidth, listHeight, menu.mapMainMenu.form)
  217. flowFormSetListProperty(menu.mapMainMenu.lists[1], "itemHeight", 0.05)
  218. menu.mapMainMenu.fields[1] = flowFormCreateField(screenWidth / 2 - listWidth / 2, screenHeight / 2 - listHeight / 2 - fieldHeight * 1.5, fieldWidth, fieldHeight, "", menu.mapMainMenu.form)
  219. flowFormSetFieldProperty(menu.mapMainMenu.fields[1], "scale", math.round(scale / 3, 3))
  220. flowFormSetFieldProperty(menu.mapMainMenu.fields[1], "ghostText", "Search...")
  221. flowFormSetFieldProperty(menu.mapMainMenu.fields[1], "useSearchIcon", true)
  222. local mapMainMenuItems = {
  223.   {
  224.     name = "Back",
  225.     img = "img/dashboard/icons/arrow_full_left.png",
  226.     fn = "swapLevel",
  227.     args = {
  228.       "[STEP_BACK]"
  229.     }
  230.   }
  231. }
  232. local startingPosition = screenWidth / 2 - (tileSize * #mapMainMenuItems + tileSize / 20 * #mapMainMenuItems) / 2 - tileSize
  233. for i, k in ipairs(mapMainMenuItems) do
  234.   menu.mapMainMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 + listHeight / 2 + tileSize / 2, tileSize, tileSize, menu.mapMainMenu.form)
  235.   flowFormSetTileProperty(menu.mapMainMenu.tiles[i], "fn", k.fn)
  236.   flowFormSetTileProperty(menu.mapMainMenu.tiles[i], "args", k.args)
  237.   flowFormSetTileProperty(menu.mapMainMenu.tiles[i], "text", k.name)
  238.   flowFormSetTileProperty(menu.mapMainMenu.tiles[i], "color", {
  239.     255,
  240.     100,
  241.     0
  242.   })
  243.   flowFormSetTileProperty(menu.mapMainMenu.tiles[i], "image", k.img)
  244. end
  245. function onServerReturnMapList(mapList, rebuild)
  246.   MAP_LIST_CACHE = mapList
  247.   if rebuild and mapList then
  248.     flowFormListClear(menu.mapMainMenu.lists[1])
  249.     for i, map in ipairs(mapList) do
  250.       flowFormAddListItem(menu.mapMainMenu.lists[1], "mapShopViewMapDetails", {map}, map.name, scale / 4.5, "default-bold")
  251.     end
  252.   end
  253. end
  254. callServerFunction("getMapList", getLocalPlayer())
  255. addEvent("dashboard:getMapList", true)
  256. addEventHandler("dashboard:getMapList", getRootElement(), function(mapList, rebuild)
  257.   MAP_LIST_CACHE = mapList
  258.   if rebuild and mapList then
  259.     flowFormListClear(menu.mapMainMenu.lists[1])
  260.     for i, map in ipairs(mapList) do
  261.       flowFormAddListItem(menu.mapMainMenu.lists[1], "mapShopViewMapDetails", {map}, map.name, scale / 4.5, "default-bold")
  262.     end
  263.   end
  264. end)
  265. addEvent("onFlowFormFieldChange", true)
  266. addEventHandler("onFlowFormFieldChange", resourceRoot, function(field, text)
  267.   if not MAP_LIST_CACHE then
  268.     return
  269.   end
  270.   if flowFormMatch(field, menu.mapMainMenu.fields[1]) then
  271.     flowFormListClear(menu.mapMainMenu.lists[1])
  272.     local matchingMaps = {}
  273.     if text == "" then
  274.       matchingMaps = MAP_LIST_CACHE
  275.     else
  276.       for i, map in ipairs(MAP_LIST_CACHE) do
  277.         if string.find(map.name:lower(), text:lower()) then
  278.           table.insert(matchingMaps, map)
  279.         end
  280.       end
  281.     end
  282.     if #matchingMaps <= 0 then
  283.       flowFormAddListItem(menu.mapMainMenu.lists[1], nil, nil, "No maps matching your search", scale / 4.5, "default-bold", {
  284.         255,
  285.         50,
  286.         50
  287.       })
  288.       return
  289.     end
  290.     for i, map in ipairs(matchingMaps) do
  291.       flowFormAddListItem(menu.mapMainMenu.lists[1], "mapShopViewMapDetails", {map}, map.name, scale / 4.5, "default-bold")
  292.     end
  293.   end
  294. end)
  295. function mapShopViewMapDetails(mapData)
  296.   MAPSHOPDATA.DATA = mapData
  297.   if menu.mapShopMapDetails.labels[1] then
  298.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[1])
  299.   end
  300.   if menu.mapShopMapDetails.labels[2] then
  301.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[2])
  302.   end
  303.   if menu.mapShopMapDetails.labels[3] then
  304.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[3])
  305.   end
  306.   if menu.mapShopMapDetails.labels[4] then
  307.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[4])
  308.   end
  309.   if menu.mapShopMapDetails.labels[5] then
  310.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[5])
  311.   end
  312.   if menu.mapShopMapDetails.labels[6] then
  313.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[6])
  314.   end
  315.   if menu.mapShopMapDetails.labels[7] then
  316.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[7])
  317.   end
  318.   if menu.mapShopMapDetails.labels[8] then
  319.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[8])
  320.   end
  321.   if menu.mapShopMapDetails.labels[9] then
  322.     flowFormDestroyLabel(menu.mapShopMapDetails.labels[9])
  323.   end
  324.   menu.mapShopMapDetails.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(mapData.name, scale / 2, "default-bold") / 2, screenHeight / 3, screenWidth, screenHeight, mapData.name, menu.mapShopMapDetails.form)
  325.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[1], "scale", scale / 2)
  326.   local offsetFromCenter = scale * 4
  327.   menu.mapShopMapDetails.labels[2] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Author:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 2.4, screenWidth, screenHeight, "Author:", menu.mapShopMapDetails.form)
  328.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[2], "scale", scale / 2.6)
  329.   menu.mapShopMapDetails.labels[3] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Times played:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 2.4 + scale * 7, screenWidth, screenHeight, "Times played:", menu.mapShopMapDetails.form)
  330.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[3], "scale", scale / 2.6)
  331.   menu.mapShopMapDetails.labels[4] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Win Ratio:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 2.4 + scale * 14, screenWidth, screenHeight, "Win Ratio:", menu.mapShopMapDetails.form)
  332.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[4], "scale", scale / 2.6)
  333.   menu.mapShopMapDetails.labels[5] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Uploaded on:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 2.4 + scale * 21, screenWidth, screenHeight, "Uploaded on:", menu.mapShopMapDetails.form)
  334.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[5], "scale", scale / 2.6)
  335.   menu.mapShopMapDetails.labels[10] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Price:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 2.4 + scale * 28, screenWidth, screenHeight, "Price:", menu.mapShopMapDetails.form)
  336.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[10], "scale", scale / 2.6)
  337.   menu.mapShopMapDetails.labels[6] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4, screenWidth, screenHeight, mapData.author, menu.mapShopMapDetails.form)
  338.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[6], "scale", scale / 2.6)
  339.   menu.mapShopMapDetails.labels[7] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + scale * 7, screenWidth, screenHeight, mapData.timesPlayed, menu.mapShopMapDetails.form)
  340.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[7], "scale", scale / 2.6)
  341.   menu.mapShopMapDetails.labels[8] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + scale * 14, screenWidth, screenHeight, mapData.difficulty, menu.mapShopMapDetails.form)
  342.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[8], "scale", scale / 2.6)
  343.   menu.mapShopMapDetails.labels[9] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + scale * 21, screenWidth, screenHeight, mapData.timeUploaded, menu.mapShopMapDetails.form)
  344.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[9], "scale", scale / 2.6)
  345.   menu.mapShopMapDetails.labels[11] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + scale * 28, screenWidth, screenHeight, "$5000", menu.mapShopMapDetails.form)
  346.   flowFormSetLabelProperty(menu.mapShopMapDetails.labels[11], "scale", scale / 2.6)
  347.   swapLevel("mapShopMapDetails")
  348. end
  349. function goToMapMenu()
  350.   if not getElementData(getLocalPlayer(), "dashboard:room") or getElementData(getLocalPlayer(), "dashboard:room") == "BAR_1" then
  351.     exports.xmsg:displayMsg("error", "Map shop is not available in the bar", "Map shop")
  352.     return
  353.   end
  354.   swapLevel("mapMainMenu")
  355. end
  356. MAPSHOPDATA = {DATA = nil}
  357. menu.mapShopMapDetails = {}
  358. menu.mapShopMapDetails.tiles = {}
  359. menu.mapShopMapDetails.labels = {}
  360. menu.mapShopMapDetails.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  361. local mapShopMapDetailsItems = {
  362.   {
  363.     name = "Back",
  364.     img = "img/dashboard/icons/arrow_full_left.png",
  365.     fn = "swapLevel",
  366.     args = {
  367.       "[STEP_BACK]"
  368.     }
  369.   },
  370.   {
  371.     name = "Buy map",
  372.     img = "img/dashboard/icons/buy.png",
  373.     fn = "buyMapCall",
  374.     args = {MAPSHOPDATA}
  375.   }
  376. }
  377. local startingPosition = screenWidth / 2 - (tileSize * #mapShopMapDetailsItems + tileSize / 20 * #mapShopMapDetailsItems) / 2 - tileSize
  378. for i, k in ipairs(mapShopMapDetailsItems) do
  379.   menu.mapShopMapDetails.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 + tileSize, tileSize, tileSize, menu.mapShopMapDetails.form)
  380.   flowFormSetTileProperty(menu.mapShopMapDetails.tiles[i], "fn", k.fn)
  381.   flowFormSetTileProperty(menu.mapShopMapDetails.tiles[i], "args", k.args)
  382.   flowFormSetTileProperty(menu.mapShopMapDetails.tiles[i], "text", k.name)
  383.   flowFormSetTileProperty(menu.mapShopMapDetails.tiles[i], "color", {
  384.     255,
  385.     100,
  386.     0
  387.   })
  388.   flowFormSetTileProperty(menu.mapShopMapDetails.tiles[i], "image", k.img)
  389. end
  390. function buyMapCall(dataPointer)
  391.   local data = dataPointer.DATA
  392.   if not data then
  393.     return
  394.   end
  395.   buyMap(data.name)
  396. end
  397. function buildUpgradesMenu(upgradesMenuItems)
  398.   local upgradesTileSize = math.floor(tileSize * 1.9)
  399.   local rows = 2
  400.   local count = 0
  401.   local row = 1
  402.   local startingPosition = screenWidth / 2 - (upgradesTileSize * math.ceil(#upgradesMenuItems / rows) + upgradesTileSize / 20 * math.ceil(#upgradesMenuItems / rows)) / 2 - upgradesTileSize
  403.   menu.upgradesMenu = {}
  404.   menu.upgradesMenu.tiles = {}
  405.   menu.upgradesMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  406.   for i, k in ipairs(upgradesMenuItems) do
  407.     count = count + 1
  408.     if count > math.ceil(#upgradesMenuItems / rows) then
  409.       count = 1
  410.       row = row + 1
  411.     end
  412.     menu.upgradesMenu.tiles[i] = flowFormCreateTile(startingPosition + upgradesTileSize * count + upgradesTileSize / 20 * count, screenHeight / 2 - upgradesTileSize * (rows - row) - upgradesTileSize / 20 * (rows - row), upgradesTileSize, upgradesTileSize, menu.upgradesMenu.form)
  413.     flowFormSetTileProperty(menu.upgradesMenu.tiles[i], "fn", "upgradeViewDetails")
  414.     flowFormSetTileProperty(menu.upgradesMenu.tiles[i], "args", {k})
  415.     flowFormSetTileProperty(menu.upgradesMenu.tiles[i], "image", k.img)
  416.     setElementData(menu.upgradesMenu.tiles[i].itemData._gui, "tooltip-text", k.desc, false)
  417.   end
  418.   local items = {
  419.     {
  420.       name = "Back",
  421.       img = "img/dashboard/icons/arrow_full_left.png",
  422.       fn = "swapLevel",
  423.       args = {
  424.         "[STEP_BACK]"
  425.       }
  426.     }
  427.   }
  428.   local startingPosition = screenWidth / 2 - (tileSize * #items + tileSize / 20 * #items) / 2 - tileSize
  429.   for i, k in ipairs(items) do
  430.     menu.upgradesMenu.tiles[100] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight - tileSize * 1.5, tileSize, tileSize, menu.upgradesMenu.form)
  431.     flowFormSetTileProperty(menu.upgradesMenu.tiles[100], "fn", k.fn)
  432.     flowFormSetTileProperty(menu.upgradesMenu.tiles[100], "args", k.args)
  433.     flowFormSetTileProperty(menu.upgradesMenu.tiles[100], "text", k.name)
  434.     flowFormSetTileProperty(menu.upgradesMenu.tiles[100], "color", {
  435.       255,
  436.       100,
  437.       0
  438.     })
  439.     flowFormSetTileProperty(menu.upgradesMenu.tiles[100], "image", k.img)
  440.   end
  441. end
  442. function upgradeViewDetails(upgradeData)
  443.   if not menu.upgradeViewDetailsMenu then
  444.     menu.upgradeViewDetailsMenu = {}
  445.     menu.upgradeViewDetailsMenu.tiles = {}
  446.     menu.upgradeViewDetailsMenu.labels = {}
  447.     menu.upgradeViewDetailsMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  448.   end
  449.   if not upgradeData then
  450.     return
  451.   end
  452.   for i, k in pairs(menu.upgradeViewDetailsMenu.tiles) do
  453.     flowFormDestroyTile(k)
  454.   end
  455.   for i, k in pairs(menu.upgradeViewDetailsMenu.labels) do
  456.     flowFormDestroyLabel(k)
  457.   end
  458.   menu.upgradeViewDetailsMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(upgradeData.name, scale / 1.5, "default-bold") / 2, screenHeight / 3.5, screenWidth, screenHeight, upgradeData.name, menu.upgradeViewDetailsMenu.form)
  459.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[1], "scale", scale / 1.5)
  460.   menu.upgradeViewDetailsMenu.labels[2] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(upgradeData.desc, scale / 3.8, "default-bold") / 2, screenHeight / 3.5 + scale * 11, screenWidth, screenHeight, upgradeData.desc, menu.upgradeViewDetailsMenu.form)
  461.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[2], "scale", scale / 3.8)
  462.   menu.upgradeViewDetailsMenu.labels[7] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Price", scale / 2.3, "default-bold") / 2, screenHeight / 3.5 + scale * 23, screenWidth, screenHeight, "Price", menu.upgradeViewDetailsMenu.form)
  463.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[7], "scale", scale / 2.3)
  464.   local offsetFromCenter = scale * 3
  465.   menu.upgradeViewDetailsMenu.labels[3] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Money:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 3.5 + scale * 30, screenWidth, screenHeight, "Money:", menu.upgradeViewDetailsMenu.form)
  466.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[3], "scale", scale / 2.6)
  467.   menu.upgradeViewDetailsMenu.labels[4] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Skillpoints:", scale / 2.6, "default-bold") - offsetFromCenter, screenHeight / 3.5 + scale * 36, screenWidth, screenHeight, "Skillpoints:", menu.upgradeViewDetailsMenu.form)
  468.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[4], "scale", scale / 2.6)
  469.   menu.upgradeViewDetailsMenu.labels[5] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 3.5 + scale * 30, screenWidth, screenHeight, upgradeData.priceMoney, menu.upgradeViewDetailsMenu.form)
  470.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[5], "scale", scale / 2.6)
  471.   menu.upgradeViewDetailsMenu.labels[6] = flowFormCreateLabel(screenWidth / 2 + offsetFromCenter, screenHeight / 3.5 + scale * 36, screenWidth, screenHeight, upgradeData.priceSP, menu.upgradeViewDetailsMenu.form)
  472.   flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[6], "scale", scale / 2.6)
  473.   local hasUpgrade = getElementData(getLocalPlayer(), upgradeData.data) == 1 and true or false
  474.   local items
  475.   if hasUpgrade then
  476.     items = {
  477.       {
  478.         name = "Back",
  479.         img = "img/dashboard/icons/arrow_full_left.png",
  480.         fn = "swapLevel",
  481.         args = {
  482.           "[STEP_BACK]"
  483.         }
  484.       },
  485.       {
  486.         name = "Refund",
  487.         img = "img/dashboard/icons/cross.png",
  488.         fn = "buyShopUpgrade",
  489.         args = {upgradeData}
  490.       }
  491.     }
  492.     menu.upgradeViewDetailsMenu.labels[8] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("You already own this item! If you wish to refund it, click the button below", scale / 2.8, "default-bold") / 2, screenHeight / 3.5 + scale * 45, screenWidth, screenHeight, "You already own this item! If you wish to refund it, click the button below", menu.upgradeViewDetailsMenu.form)
  493.     flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[8], "scale", scale / 2.8)
  494.     flowFormSetLabelProperty(menu.upgradeViewDetailsMenu.labels[8], "color", {
  495.       255,
  496.       100,
  497.       100
  498.     })
  499.   else
  500.     items = {
  501.       {
  502.         name = "Back",
  503.         img = "img/dashboard/icons/arrow_full_left.png",
  504.         fn = "swapLevel",
  505.         args = {
  506.           "[STEP_BACK]"
  507.         }
  508.       },
  509.       {
  510.         name = "Purchase",
  511.         img = "img/dashboard/icons/buy.png",
  512.         fn = "buyShopUpgrade",
  513.         args = {upgradeData}
  514.       }
  515.     }
  516.   end
  517.   local startingPosition = screenWidth / 2 - (tileSize * #items + tileSize / 20 * #items) / 2 - tileSize
  518.   for i, k in ipairs(items) do
  519.     menu.upgradeViewDetailsMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 + tileSize, tileSize, tileSize, menu.upgradeViewDetailsMenu.form)
  520.     flowFormSetTileProperty(menu.upgradeViewDetailsMenu.tiles[i], "fn", k.fn)
  521.     flowFormSetTileProperty(menu.upgradeViewDetailsMenu.tiles[i], "args", k.args)
  522.     flowFormSetTileProperty(menu.upgradeViewDetailsMenu.tiles[i], "text", k.name)
  523.     flowFormSetTileProperty(menu.upgradeViewDetailsMenu.tiles[i], "color", {
  524.       255,
  525.       100,
  526.       0
  527.     })
  528.     flowFormSetTileProperty(menu.upgradeViewDetailsMenu.tiles[i], "image", k.img)
  529.     if hasUpgrade then
  530.       setElementData(menu.upgradeViewDetailsMenu.tiles[i].itemData._gui, "tooltip-text", "Click to refund this item", false)
  531.     end
  532.   end
  533.   swapLevel("upgradeViewDetailsMenu")
  534. end
  535. function createAchievementsMenu(achievements)
  536.   if menu.achievementsMenu and menu.achievementsMenu.form then
  537.     flowFormDestroyForm(menu.achievementsMenu.form)
  538.   end
  539.   menu.achievementsMenu = {}
  540.   menu.achievementsMenu.tiles = {}
  541.   menu.achievementsMenu.labels = {}
  542.   menu.achievementsMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  543.   local achTileWidth = math.floor(scale * 52)
  544.   local achTileHeight = math.floor(scale * 11.2)
  545.   local achRowSpacing = math.floor(scale * 2)
  546.   local achVerticalSpacing = math.floor(scale * 1.5)
  547.   local totalColumns = 4
  548.   local currentCount = 0
  549.   local currentRow = 1
  550.   local startingPosition = screenWidth / 2 - (achTileWidth * totalColumns + achRowSpacing * totalColumns) / 2 - achTileWidth
  551.   local UNLOCKED_COUNT = 0
  552.   for i, k in ipairs(achievements) do
  553.     currentCount = currentCount + 1
  554.     if currentCount > math.floor(#achievements / totalColumns) then
  555.       currentCount = 1
  556.       currentRow = currentRow + 1
  557.     end
  558.     local isUnlocked = getElementData(getLocalPlayer(), "Ach" .. i) == 1 and true or false
  559.     menu.achievementsMenu.tiles[i] = flowFormCreateTile(startingPosition + achTileWidth * currentRow + achRowSpacing * currentRow, scale * 25 + achTileHeight * currentCount + achVerticalSpacing * currentCount, achTileWidth, achTileHeight, menu.achievementsMenu.form)
  560.     setElementData(menu.achievementsMenu.tiles[i].itemData._gui, "tooltip-text", k[2], false)
  561.     flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "text", k[3])
  562.     flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "scale", scale / 4)
  563.     if isUnlocked then
  564.       UNLOCKED_COUNT = UNLOCKED_COUNT + 1
  565.       flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "color", {
  566.         255,
  567.         100,
  568.         0
  569.       })
  570.       flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "image", "img/achievement_unlocked_overlay.png")
  571.     else
  572.       flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "color", {
  573.         80,
  574.         80,
  575.         80
  576.       })
  577.       flowFormSetTileProperty(menu.achievementsMenu.tiles[i], "image", "img/achievement_locked_overlay.png")
  578.     end
  579.   end
  580.   menu.achievementsMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Achievements", scale / 1.5, "default-bold") / 2, scale * 13, screenWidth, screenHeight, "Achievements", menu.achievementsMenu.form)
  581.   flowFormSetLabelProperty(menu.achievementsMenu.labels[1], "scale", scale / 1.5)
  582.   menu.achievementsMenu.labels[2] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Unlocked " .. UNLOCKED_COUNT .. "/" .. #achievements, scale / 2.2, "default-bold") / 2, scale * 24, screenWidth, screenHeight, "Unlocked " .. UNLOCKED_COUNT .. "/" .. #achievements, menu.achievementsMenu.form)
  583.   flowFormSetLabelProperty(menu.achievementsMenu.labels[2], "scale", scale / 2.2)
  584.   local items = {
  585.     {
  586.       name = "Back",
  587.       img = "img/dashboard/icons/arrow_full_left.png",
  588.       fn = "swapLevel",
  589.       args = {
  590.         "[STEP_BACK]"
  591.       }
  592.     }
  593.   }
  594.   local startingPosition = screenWidth / 2 - (tileSize * #items + tileSize / 20 * #items) / 2 - tileSize
  595.   for i, k in ipairs(items) do
  596.     menu.achievementsMenu.tiles[100] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight - tileSize * 1.4, tileSize, tileSize, menu.achievementsMenu.form)
  597.     flowFormSetTileProperty(menu.achievementsMenu.tiles[100], "fn", k.fn)
  598.     flowFormSetTileProperty(menu.achievementsMenu.tiles[100], "args", k.args)
  599.     flowFormSetTileProperty(menu.achievementsMenu.tiles[100], "text", k.name)
  600.     flowFormSetTileProperty(menu.achievementsMenu.tiles[100], "color", {
  601.       255,
  602.       100,
  603.       0
  604.     })
  605.     flowFormSetTileProperty(menu.achievementsMenu.tiles[100], "image", k.img)
  606.   end
  607.   ACHIEVEMENTS = achievements
  608. end
  609. addEventHandler("onClientResourceStart", resourceRoot, function()
  610.   callServerFunction("clientRequestedAchievements", getLocalPlayer())
  611. end)
  612. addEvent("onDashboardLevelChanged", true)
  613. addEventHandler("onDashboardLevelChanged", getRootElement(), function(oldLevel, newLevel)
  614.   if newLevel == "achievementsMenu" and ACHIEVEMENTS then
  615.     createAchievementsMenu(ACHIEVEMENTS)
  616.   end
  617. end)
  618. function initiateGarage()
  619.   garageEnter()
  620. end
  621. local garageTileHeight = tileSize / 2
  622. local garageTileWidth = garageTileHeight * 4
  623. local items = {
  624.   {
  625.     name = nil,
  626.     img = "img/dashboard/garage/vehicle.png",
  627.     fn = "swapGarageLevel",
  628.     args = {
  629.       "garageVehicleMenu"
  630.     }
  631.   },
  632.   {
  633.     name = nil,
  634.     img = "img/dashboard/garage/player_skin.png",
  635.     fn = "swapGarageLevel",
  636.     args = {
  637.       "garagePlayerSkinMenu"
  638.     }
  639.   },
  640.   {
  641.     name = nil,
  642.     img = "img/dashboard/garage/postcard_mode.png",
  643.     fn = "enterPostcardMode",
  644.     args = {}
  645.   },
  646.   {
  647.     name = nil,
  648.     img = "img/dashboard/garage/quit.png",
  649.     fn = "garageLeave",
  650.     args = {}
  651.   }
  652. }
  653. local startingPosition = screenWidth / 2 - (garageTileWidth * #items + garageTileWidth / 20 * #items) / 2 - garageTileWidth
  654. menu.garageMainMenu = {}
  655. menu.garageMainMenu.tiles = {}
  656. menu.garageMainMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  657. for i, k in ipairs(items) do
  658.   menu.garageMainMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * i + garageTileWidth / 20 * i, screenHeight - garageTileHeight * 2, garageTileWidth, garageTileHeight, menu.garageMainMenu.form)
  659.   flowFormSetTileProperty(menu.garageMainMenu.tiles[i], "fn", k.fn)
  660.   flowFormSetTileProperty(menu.garageMainMenu.tiles[i], "args", k.args)
  661.   flowFormSetTileProperty(menu.garageMainMenu.tiles[i], "text", k.name)
  662.   flowFormSetTileProperty(menu.garageMainMenu.tiles[i], "color", {
  663.     255,
  664.     100,
  665.     0
  666.   })
  667.   flowFormSetTileProperty(menu.garageMainMenu.tiles[i], "image", k.img)
  668. end
  669. local items = {
  670.   {
  671.     name = nil,
  672.     img = "img/dashboard/garage/headlights.png",
  673.     fn = "swapGarageLevel",
  674.     args = {
  675.       "garageHeadlightsMenu"
  676.     }
  677.   },
  678.   {
  679.     name = nil,
  680.     img = "img/dashboard/garage/lights_style.png",
  681.     fn = "swapGarageLevel",
  682.     args = {
  683.       "garageLightsStyleMenu"
  684.     }
  685.   },
  686.   {
  687.     name = nil,
  688.     img = "img/dashboard/garage/pick_color.png",
  689.     fn = "swapGarageLevel",
  690.     args = {
  691.       "garageVehicleColorMenu"
  692.     }
  693.   },
  694.   {
  695.     name = nil,
  696.     img = "img/dashboard/garage/nitro_color.png",
  697.     fn = "swapGarageLevel",
  698.     args = {
  699.       "garageNitroColorMenu"
  700.     }
  701.   },
  702.   {
  703.     name = nil,
  704.     img = "img/dashboard/garage/rims.png",
  705.     fn = "swapGarageLevel",
  706.     args = {
  707.       "garageRimsMenu"
  708.     }
  709.   },
  710.   {
  711.     name = nil,
  712.     img = "img/dashboard/garage/vehicle_skin.png",
  713.     fn = "swapGarageLevel",
  714.     args = {
  715.       "garageVehicleSkinMenu"
  716.     }
  717.   },
  718.   {
  719.     name = nil,
  720.     img = "img/dashboard/garage/swap_vehicle.png",
  721.     fn = "swapGarageLevel",
  722.     args = {
  723.       "garageSwapVehicleMenu"
  724.     }
  725.   },
  726.   {
  727.     name = nil,
  728.     img = "img/dashboard/garage/back.png",
  729.     fn = "swapGarageLevel",
  730.     args = {
  731.       "[STEP_BACK]"
  732.     }
  733.   }
  734. }
  735. local rows = 3
  736. menu.garageVehicleMenu = {}
  737. menu.garageVehicleMenu.tiles = {}
  738. menu.garageVehicleMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  739. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  740. local count = 0
  741. local row = 1
  742. for i, k in ipairs(items) do
  743.   if count >= math.ceil(#items / rows) then
  744.     row = row + 1
  745.     count = 0
  746.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  747.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  748.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  749.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  750.   end
  751.   count = count + 1
  752.   menu.garageVehicleMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garageVehicleMenu.form)
  753.   flowFormSetTileProperty(menu.garageVehicleMenu.tiles[i], "fn", k.fn)
  754.   flowFormSetTileProperty(menu.garageVehicleMenu.tiles[i], "args", k.args)
  755.   flowFormSetTileProperty(menu.garageVehicleMenu.tiles[i], "text", k.name)
  756.   flowFormSetTileProperty(menu.garageVehicleMenu.tiles[i], "color", {
  757.     255,
  758.     100,
  759.     0
  760.   })
  761.   flowFormSetTileProperty(menu.garageVehicleMenu.tiles[i], "image", k.img)
  762. end
  763. local items = {
  764.   {
  765.     name = nil,
  766.     img = "img/dashboard/garage/accept.png",
  767.     fn = "garageDonePickingColor",
  768.     args = {}
  769.   }
  770. }
  771. local rows = 1
  772. menu.garagePickColorMenu = {}
  773. menu.garagePickColorMenu.tiles = {}
  774. menu.garagePickColorMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  775. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  776. local count = 0
  777. local row = 1
  778. for i, k in ipairs(items) do
  779.   if count >= math.ceil(#items / rows) then
  780.     row = row + 1
  781.     count = 0
  782.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  783.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  784.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  785.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  786.   end
  787.   count = count + 1
  788.   menu.garagePickColorMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garagePickColorMenu.form)
  789.   flowFormSetTileProperty(menu.garagePickColorMenu.tiles[i], "fn", k.fn)
  790.   flowFormSetTileProperty(menu.garagePickColorMenu.tiles[i], "args", k.args)
  791.   flowFormSetTileProperty(menu.garagePickColorMenu.tiles[i], "text", k.name)
  792.   flowFormSetTileProperty(menu.garagePickColorMenu.tiles[i], "color", {
  793.     255,
  794.     100,
  795.     0
  796.   })
  797.   flowFormSetTileProperty(menu.garagePickColorMenu.tiles[i], "image", k.img)
  798. end
  799. local items = {
  800.   {
  801.     name = nil,
  802.     img = "img/dashboard/garage/pick_color.png",
  803.     fn = "garagePickColor",
  804.     args = {
  805.       "headlights_color"
  806.     }
  807.   },
  808.   {
  809.     name = nil,
  810.     img = "img/dashboard/garage/back.png",
  811.     fn = "swapLevel",
  812.     args = {
  813.       "[STEP_BACK]"
  814.     }
  815.   }
  816. }
  817. local rows = 1
  818. menu.garageHeadlightsMenu = {}
  819. menu.garageHeadlightsMenu.tiles = {}
  820. menu.garageHeadlightsMenu.labels = {}
  821. menu.garageHeadlightsMenu.strips = {}
  822. menu.garageHeadlightsMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  823. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  824. local count = 0
  825. local row = 1
  826. for i, k in ipairs(items) do
  827.   if count >= math.ceil(#items / rows) then
  828.     row = row + 1
  829.     count = 0
  830.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  831.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  832.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  833.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  834.   end
  835.   count = count + 1
  836.   menu.garageHeadlightsMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garageHeadlightsMenu.form)
  837.   flowFormSetTileProperty(menu.garageHeadlightsMenu.tiles[i], "fn", k.fn)
  838.   flowFormSetTileProperty(menu.garageHeadlightsMenu.tiles[i], "args", k.args)
  839.   flowFormSetTileProperty(menu.garageHeadlightsMenu.tiles[i], "text", k.name)
  840.   flowFormSetTileProperty(menu.garageHeadlightsMenu.tiles[i], "color", {
  841.     255,
  842.     100,
  843.     0
  844.   })
  845.   flowFormSetTileProperty(menu.garageHeadlightsMenu.tiles[i], "image", k.img)
  846. end
  847. local stripItems = {
  848.   {
  849.     text = "Rainbow lights",
  850.     fn = "garageToggleDiscoLights",
  851.     default = 2,
  852.     options = {
  853.       {
  854.         text = "Enabled",
  855.         args = {true}
  856.       },
  857.       {
  858.         text = "Disabled",
  859.         args = {false}
  860.       }
  861.     }
  862.   },
  863.   {
  864.     text = "Custom headlights color",
  865.     fn = "garageToggleHeadlightsColorEnabled",
  866.     default = 2,
  867.     options = {
  868.       {
  869.         text = "Enabled",
  870.         args = {true}
  871.       },
  872.       {
  873.         text = "Disabled",
  874.         args = {false}
  875.       }
  876.     }
  877.   }
  878. }
  879. for i, k in ipairs(stripItems) do
  880.   local offsetFromCenter = scale * 4
  881.   local scale = scale / 3
  882.   menu.garageHeadlightsMenu.labels[i] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(k.text, scale, "default-bold") - offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, screenWidth, screenHeight, k.text, menu.garageHeadlightsMenu.form)
  883.   flowFormSetLabelProperty(menu.garageHeadlightsMenu.labels[i], "scale", scale)
  884.   menu.garageHeadlightsMenu.strips[i] = flowFormCreateStrip(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, menu.garageHeadlightsMenu.form)
  885.   for x, y in ipairs(k.options) do
  886.     flowFormAddStripItem(menu.garageHeadlightsMenu.strips[i], y.text, "default-bold", scale, k.fn, y.args)
  887.   end
  888.   flowFormStripSetSelected(menu.garageHeadlightsMenu.strips[i], k.default)
  889. end
  890. local items = {
  891.   {
  892.     name = nil,
  893.     img = "img/dashboard/garage/primary_color.png",
  894.     fn = "garagePickColor",
  895.     args = {
  896.       "vehicle_color_primary"
  897.     }
  898.   },
  899.   {
  900.     name = nil,
  901.     img = "img/dashboard/garage/secondary_color.png",
  902.     fn = "garagePickColor",
  903.     args = {
  904.       "vehicle_color_secondary"
  905.     }
  906.   },
  907.   {
  908.     name = nil,
  909.     img = "img/dashboard/garage/back.png",
  910.     fn = "swapLevel",
  911.     args = {
  912.       "[STEP_BACK]"
  913.     }
  914.   }
  915. }
  916. local rows = 1
  917. menu.garageVehicleColorMenu = {}
  918. menu.garageVehicleColorMenu.tiles = {}
  919. menu.garageVehicleColorMenu.labels = {}
  920. menu.garageVehicleColorMenu.strips = {}
  921. menu.garageVehicleColorMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  922. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  923. local count = 0
  924. local row = 1
  925. for i, k in ipairs(items) do
  926.   if count >= math.ceil(#items / rows) then
  927.     row = row + 1
  928.     count = 0
  929.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  930.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  931.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  932.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  933.   end
  934.   count = count + 1
  935.   menu.garageVehicleColorMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garageVehicleColorMenu.form)
  936.   flowFormSetTileProperty(menu.garageVehicleColorMenu.tiles[i], "fn", k.fn)
  937.   flowFormSetTileProperty(menu.garageVehicleColorMenu.tiles[i], "args", k.args)
  938.   flowFormSetTileProperty(menu.garageVehicleColorMenu.tiles[i], "text", k.name)
  939.   flowFormSetTileProperty(menu.garageVehicleColorMenu.tiles[i], "color", {
  940.     255,
  941.     100,
  942.     0
  943.   })
  944.   flowFormSetTileProperty(menu.garageVehicleColorMenu.tiles[i], "image", k.img)
  945. end
  946. local stripItems = {
  947.   {
  948.     text = "Custom vehicle color",
  949.     fn = "garageToggleVehicleColorEnabled",
  950.     default = 2,
  951.     options = {
  952.       {
  953.         text = "Enabled",
  954.         args = {true}
  955.       },
  956.       {
  957.         text = "Disabled",
  958.         args = {false}
  959.       }
  960.     }
  961.   }
  962. }
  963. for i, k in ipairs(stripItems) do
  964.   local offsetFromCenter = scale * 4
  965.   local scale = scale / 3
  966.   menu.garageVehicleColorMenu.labels[i] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(k.text, scale, "default-bold") - offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, screenWidth, screenHeight, k.text, menu.garageVehicleColorMenu.form)
  967.   flowFormSetLabelProperty(menu.garageVehicleColorMenu.labels[i], "scale", scale)
  968.   menu.garageVehicleColorMenu.strips[i] = flowFormCreateStrip(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, menu.garageVehicleColorMenu.form)
  969.   for x, y in ipairs(k.options) do
  970.     flowFormAddStripItem(menu.garageVehicleColorMenu.strips[i], y.text, "default-bold", scale, k.fn, y.args)
  971.   end
  972.   flowFormStripSetSelected(menu.garageVehicleColorMenu.strips[i], k.default)
  973. end
  974. local items = {
  975.   {
  976.     name = nil,
  977.     img = "img/dashboard/garage/pick_color.png",
  978.     fn = "garagePickColor",
  979.     args = {
  980.       "nitro_color"
  981.     }
  982.   },
  983.   {
  984.     name = nil,
  985.     img = "img/dashboard/garage/back.png",
  986.     fn = "swapLevel",
  987.     args = {
  988.       "[STEP_BACK]"
  989.     }
  990.   }
  991. }
  992. local rows = 1
  993. menu.garageNitroColorMenu = {}
  994. menu.garageNitroColorMenu.tiles = {}
  995. menu.garageNitroColorMenu.labels = {}
  996. menu.garageNitroColorMenu.strips = {}
  997. menu.garageNitroColorMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  998. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  999. local count = 0
  1000. local row = 1
  1001. for i, k in ipairs(items) do
  1002.   if count >= math.ceil(#items / rows) then
  1003.     row = row + 1
  1004.     count = 0
  1005.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  1006.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  1007.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  1008.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  1009.   end
  1010.   count = count + 1
  1011.   menu.garageNitroColorMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garageNitroColorMenu.form)
  1012.   flowFormSetTileProperty(menu.garageNitroColorMenu.tiles[i], "fn", k.fn)
  1013.   flowFormSetTileProperty(menu.garageNitroColorMenu.tiles[i], "args", k.args)
  1014.   flowFormSetTileProperty(menu.garageNitroColorMenu.tiles[i], "text", k.name)
  1015.   flowFormSetTileProperty(menu.garageNitroColorMenu.tiles[i], "color", {
  1016.     255,
  1017.     100,
  1018.     0
  1019.   })
  1020.   flowFormSetTileProperty(menu.garageNitroColorMenu.tiles[i], "image", k.img)
  1021. end
  1022. local stripItems = {
  1023.   {
  1024.     text = "Custom nitro color",
  1025.     fn = "garageToggleNitroColorEnabled",
  1026.     default = 2,
  1027.     options = {
  1028.       {
  1029.         text = "Enabled",
  1030.         args = {true}
  1031.       },
  1032.       {
  1033.         text = "Disabled",
  1034.         args = {false}
  1035.       }
  1036.     }
  1037.   }
  1038. }
  1039. for i, k in ipairs(stripItems) do
  1040.   local offsetFromCenter = scale * 4
  1041.   local scale = scale / 3
  1042.   menu.garageNitroColorMenu.labels[i] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(k.text, scale, "default-bold") - offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, screenWidth, screenHeight, k.text, menu.garageNitroColorMenu.form)
  1043.   flowFormSetLabelProperty(menu.garageNitroColorMenu.labels[i], "scale", scale)
  1044.   menu.garageNitroColorMenu.strips[i] = flowFormCreateStrip(screenWidth / 2 + offsetFromCenter, screenHeight / 2.4 + i * dxGetFontHeight(scale, "default-bold") * 1.5, menu.garageNitroColorMenu.form)
  1045.   for x, y in ipairs(k.options) do
  1046.     flowFormAddStripItem(menu.garageNitroColorMenu.strips[i], y.text, "default-bold", scale, k.fn, y.args)
  1047.   end
  1048.   flowFormStripSetSelected(menu.garageNitroColorMenu.strips[i], k.default)
  1049. end
  1050. menu.garageRimsMenu = {}
  1051. menu.garageRimsMenu.buttons = {}
  1052. menu.garageRimsMenu.labels = {}
  1053. menu.garageRimsMenu.tiles = {}
  1054. menu.garageRimsMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1055. local buttonWidth = tileSize * 0.7
  1056. local buttonHeight = buttonWidth / 2
  1057. local middleOffset = buttonWidth * 1.7
  1058. menu.garageRimsMenu.buttons[1] = flowFormCreateButton(screenWidth / 2 - middleOffset / 2 - buttonWidth, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, "<", menu.garageRimsMenu.form)
  1059. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[1], "colorcoded", false)
  1060. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[1], "fn", "garageCycleRims")
  1061. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[1], "args", {"prev"})
  1062. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[1], "color", {
  1063.   35,
  1064.   35,
  1065.   35
  1066. })
  1067. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[1], "scale", scale / 1.5)
  1068. menu.garageRimsMenu.buttons[2] = flowFormCreateButton(screenWidth / 2 + middleOffset / 2, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, ">", menu.garageRimsMenu.form)
  1069. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[2], "colorcoded", false)
  1070. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[2], "fn", "garageCycleRims")
  1071. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[2], "args", {"next"})
  1072. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[2], "color", {
  1073.   35,
  1074.   35,
  1075.   35
  1076. })
  1077. flowFormSetButtonProperty(menu.garageRimsMenu.buttons[2], "scale", scale / 1.5)
  1078. local fontScale = scale / 1.2
  1079. menu.garageRimsMenu.labels[1] = flowFormCreateLabel(0, screenHeight - buttonHeight * 2.7, screenWidth, screenHeight, "0/0", menu.garageRimsMenu.form)
  1080. flowFormSetLabelProperty(menu.garageRimsMenu.labels[1], "scale", fontScale)
  1081. flowFormSetLabelProperty(menu.garageRimsMenu.labels[1], "align_horizontal", "center")
  1082. menu.garageRimsMenu.labels[2] = flowFormCreateLabel(0, screenHeight - buttonHeight * 4, screenWidth, screenHeight, "", menu.garageRimsMenu.form)
  1083. flowFormSetLabelProperty(menu.garageRimsMenu.labels[2], "scale", scale / 2)
  1084. flowFormSetLabelProperty(menu.garageRimsMenu.labels[2], "align_horizontal", "center")
  1085. menu.garageRimsMenu.labels[3] = flowFormCreateLabel(0, screenHeight - buttonHeight * 1.2, screenWidth, screenHeight, "Default rims", menu.garageRimsMenu.form)
  1086. flowFormSetLabelProperty(menu.garageRimsMenu.labels[3], "scale", scale / 3)
  1087. flowFormSetLabelProperty(menu.garageRimsMenu.labels[3], "align_horizontal", "center")
  1088. menu.garageRimsMenu.tiles[1] = flowFormCreateTile(screenWidth / 2 - garageTileWidth * 2, screenHeight - buttonHeight * 2.5, garageTileWidth, garageTileHeight, menu.garageRimsMenu.form)
  1089. flowFormSetTileProperty(menu.garageRimsMenu.tiles[1], "fn", "garageAcceptRims")
  1090. flowFormSetTileProperty(menu.garageRimsMenu.tiles[1], "args", {})
  1091. flowFormSetTileProperty(menu.garageRimsMenu.tiles[1], "text", nil)
  1092. flowFormSetTileProperty(menu.garageRimsMenu.tiles[1], "color", {
  1093.   255,
  1094.   100,
  1095.   0
  1096. })
  1097. flowFormSetTileProperty(menu.garageRimsMenu.tiles[1], "image", "img/dashboard/garage/accept.png")
  1098. menu.garageVehicleSkinMenu = {}
  1099. menu.garageVehicleSkinMenu.buttons = {}
  1100. menu.garageVehicleSkinMenu.labels = {}
  1101. menu.garageVehicleSkinMenu.tiles = {}
  1102. menu.garageVehicleSkinMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1103. local buttonWidth = tileSize * 0.7
  1104. local buttonHeight = buttonWidth / 2
  1105. local middleOffset = buttonWidth * 1.7
  1106. menu.garageVehicleSkinMenu.buttons[1] = flowFormCreateButton(screenWidth / 2 - middleOffset / 2 - buttonWidth, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, "<", menu.garageVehicleSkinMenu.form)
  1107. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[1], "colorcoded", false)
  1108. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[1], "fn", "garageCycleVehicleSkin")
  1109. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[1], "args", {"prev"})
  1110. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[1], "color", {
  1111.   35,
  1112.   35,
  1113.   35
  1114. })
  1115. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[1], "scale", scale / 1.5)
  1116. menu.garageVehicleSkinMenu.buttons[2] = flowFormCreateButton(screenWidth / 2 + middleOffset / 2, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, ">", menu.garageVehicleSkinMenu.form)
  1117. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[2], "colorcoded", false)
  1118. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[2], "fn", "garageCycleVehicleSkin")
  1119. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[2], "args", {"next"})
  1120. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[2], "color", {
  1121.   35,
  1122.   35,
  1123.   35
  1124. })
  1125. flowFormSetButtonProperty(menu.garageVehicleSkinMenu.buttons[2], "scale", scale / 1.5)
  1126. local fontScale = scale / 1.2
  1127. menu.garageVehicleSkinMenu.labels[1] = flowFormCreateLabel(0, screenHeight - buttonHeight * 2.7, screenWidth, screenHeight, "0/0", menu.garageVehicleSkinMenu.form)
  1128. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[1], "scale", fontScale)
  1129. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[1], "align_horizontal", "center")
  1130. menu.garageVehicleSkinMenu.labels[2] = flowFormCreateLabel(0, screenHeight - buttonHeight * 4, screenWidth, screenHeight, "", menu.garageVehicleSkinMenu.form)
  1131. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[2], "scale", scale / 2)
  1132. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[2], "align_horizontal", "center")
  1133. menu.garageVehicleSkinMenu.labels[3] = flowFormCreateLabel(0, screenHeight - buttonHeight * 1.2, screenWidth, screenHeight, "Default vehicle skin", menu.garageVehicleSkinMenu.form)
  1134. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[3], "scale", scale / 3)
  1135. flowFormSetLabelProperty(menu.garageVehicleSkinMenu.labels[3], "align_horizontal", "center")
  1136. menu.garageVehicleSkinMenu.tiles[1] = flowFormCreateTile(screenWidth / 2 - garageTileWidth * 2, screenHeight - buttonHeight * 2.5, garageTileWidth, garageTileHeight, menu.garageVehicleSkinMenu.form)
  1137. flowFormSetTileProperty(menu.garageVehicleSkinMenu.tiles[1], "fn", "garageAcceptVehicleSkin")
  1138. flowFormSetTileProperty(menu.garageVehicleSkinMenu.tiles[1], "args", {})
  1139. flowFormSetTileProperty(menu.garageVehicleSkinMenu.tiles[1], "text", nil)
  1140. flowFormSetTileProperty(menu.garageVehicleSkinMenu.tiles[1], "color", {
  1141.   255,
  1142.   100,
  1143.   0
  1144. })
  1145. flowFormSetTileProperty(menu.garageVehicleSkinMenu.tiles[1], "image", "img/dashboard/garage/accept.png")
  1146. menu.garageSwapVehicleMenu = {}
  1147. menu.garageSwapVehicleMenu.tiles = {}
  1148. menu.garageSwapVehicleMenu.fields = {}
  1149. menu.garageSwapVehicleMenu.labels = {}
  1150. menu.garageSwapVehicleMenu.lists = {}
  1151. menu.garageSwapVehicleMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  1152. local listWidth = scale * 120
  1153. local listHeight = scale * 90
  1154. local fieldWidth = math.floor(scale * 80)
  1155. local fieldHeight = math.floor(scale * 6)
  1156. menu.garageSwapVehicleMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Available vehicles", scale / 2, "default-bold") / 2, scale * 15, screenWidth, screenHeight, "Available vehicles", menu.garageSwapVehicleMenu.form)
  1157. flowFormSetLabelProperty(menu.garageSwapVehicleMenu.labels[1], "scale", scale / 2)
  1158. menu.garageSwapVehicleMenu.lists[1] = flowFormCreateList(screenWidth / 2 - listWidth / 2, screenHeight / 2 - listHeight / 2, listWidth, listHeight, menu.garageSwapVehicleMenu.form)
  1159. flowFormSetListProperty(menu.garageSwapVehicleMenu.lists[1], "itemHeight", 0.05)
  1160. flowFormSetListProperty(menu.garageSwapVehicleMenu.lists[1], "color", {
  1161.   70,
  1162.   70,
  1163.   70
  1164. })
  1165. flowFormSetListProperty(menu.garageSwapVehicleMenu.lists[1], "listBackgroundMultiplier", 2)
  1166. menu.garageSwapVehicleMenu.fields[1] = flowFormCreateField(screenWidth / 2 - listWidth / 2, screenHeight / 2 - listHeight / 2 - fieldHeight * 1.5, fieldWidth, fieldHeight, "", menu.garageSwapVehicleMenu.form)
  1167. flowFormSetFieldProperty(menu.garageSwapVehicleMenu.fields[1], "scale", math.round(scale / 3, 3))
  1168. flowFormSetFieldProperty(menu.garageSwapVehicleMenu.fields[1], "ghostText", "Search...")
  1169. flowFormSetFieldProperty(menu.garageSwapVehicleMenu.fields[1], "useSearchIcon", true)
  1170. addEventHandler("onClientResourceStart", resourceRoot, function()
  1171.   for i, k in ipairs(garageVehiclesList) do
  1172.     flowFormAddListItem(menu.garageSwapVehicleMenu.lists[1], "garageSwapVehicle", {k}, getVehicleNameFromModel(k), scale / 4.5, "default-bold")
  1173.   end
  1174. end)
  1175. local items = {
  1176.   {
  1177.     name = nil,
  1178.     img = "img/dashboard/garage/back.png",
  1179.     fn = "swapLevel",
  1180.     args = {
  1181.       "[STEP_BACK]"
  1182.     }
  1183.   }
  1184. }
  1185. local rows = 1
  1186. local startingPosition = screenWidth / 2 - (garageTileWidth * math.ceil(#items / rows) + garageTileWidth / 20 * math.ceil(#items / rows)) / 2 - garageTileWidth
  1187. local count = 0
  1188. local row = 1
  1189. for i, k in ipairs(items) do
  1190.   if count >= math.ceil(#items / rows) then
  1191.     row = row + 1
  1192.     count = 0
  1193.     local totalItemsLeft = #items - (row - 1) * math.ceil(#items / rows)
  1194.     local totalitemsLeftOnNextRow = totalItemsLeft - math.ceil(#items / rows)
  1195.     local itemsDecrement = totalitemsLeftOnNextRow < 0 and totalitemsLeftOnNextRow or 0
  1196.     startingPosition = screenWidth / 2 - (garageTileWidth * (math.ceil(#items / rows) + itemsDecrement) + garageTileWidth / 20 * (math.ceil(#items / rows) + itemsDecrement)) / 2 - garageTileWidth
  1197.   end
  1198.   count = count + 1
  1199.   menu.garageSwapVehicleMenu.tiles[i] = flowFormCreateTile(startingPosition + garageTileWidth * count + garageTileWidth / 20 * count, screenHeight - garageTileHeight * 2 - (rows - row) * (garageTileHeight * 1.2), garageTileWidth, garageTileHeight, menu.garageSwapVehicleMenu.form)
  1200.   flowFormSetTileProperty(menu.garageSwapVehicleMenu.tiles[i], "fn", k.fn)
  1201.   flowFormSetTileProperty(menu.garageSwapVehicleMenu.tiles[i], "args", k.args)
  1202.   flowFormSetTileProperty(menu.garageSwapVehicleMenu.tiles[i], "text", k.name)
  1203.   flowFormSetTileProperty(menu.garageSwapVehicleMenu.tiles[i], "color", {
  1204.     255,
  1205.     100,
  1206.     0
  1207.   })
  1208.   flowFormSetTileProperty(menu.garageSwapVehicleMenu.tiles[i], "image", k.img)
  1209. end
  1210. addEvent("onFlowFormFieldChange", true)
  1211. addEventHandler("onFlowFormFieldChange", resourceRoot, function(field, text)
  1212.   if flowFormMatch(field, menu.garageSwapVehicleMenu.fields[1]) then
  1213.     flowFormListClear(menu.garageSwapVehicleMenu.lists[1])
  1214.     local matchingVehicles = {}
  1215.     if text == "" then
  1216.       matchingVehicles = garageVehiclesList
  1217.     else
  1218.       for i, veh in ipairs(garageVehiclesList) do
  1219.         if string.find(getVehicleNameFromModel(veh):lower(), text:lower()) then
  1220.           table.insert(matchingVehicles, veh)
  1221.         end
  1222.       end
  1223.     end
  1224.     if #matchingVehicles <= 0 then
  1225.       flowFormAddListItem(menu.garageSwapVehicleMenu.lists[1], nil, nil, "No vehicles matching your search", scale / 4.5, "default-bold", {
  1226.         255,
  1227.         50,
  1228.         50
  1229.       })
  1230.       return
  1231.     end
  1232.     for i, veh in ipairs(matchingVehicles) do
  1233.       flowFormAddListItem(menu.garageSwapVehicleMenu.lists[1], "garageSwapVehicle", {veh}, getVehicleNameFromModel(veh), scale / 4.5, "default-bold")
  1234.     end
  1235.   end
  1236. end)
  1237. menu.garageLightsStyleMenu = {}
  1238. menu.garageLightsStyleMenu.buttons = {}
  1239. menu.garageLightsStyleMenu.labels = {}
  1240. menu.garageLightsStyleMenu.tiles = {}
  1241. menu.garageLightsStyleMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1242. local buttonWidth = tileSize * 0.7
  1243. local buttonHeight = buttonWidth / 2
  1244. local middleOffset = buttonWidth * 1.7
  1245. menu.garageLightsStyleMenu.buttons[1] = flowFormCreateButton(screenWidth / 2 - middleOffset / 2 - buttonWidth, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, "<", menu.garageLightsStyleMenu.form)
  1246. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[1], "colorcoded", false)
  1247. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[1], "fn", "garageCycleLightsStyle")
  1248. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[1], "args", {"prev"})
  1249. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[1], "color", {
  1250.   35,
  1251.   35,
  1252.   35
  1253. })
  1254. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[1], "scale", scale / 1.5)
  1255. menu.garageLightsStyleMenu.buttons[2] = flowFormCreateButton(screenWidth / 2 + middleOffset / 2, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, ">", menu.garageLightsStyleMenu.form)
  1256. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[2], "colorcoded", false)
  1257. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[2], "fn", "garageCycleLightsStyle")
  1258. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[2], "args", {"next"})
  1259. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[2], "color", {
  1260.   35,
  1261.   35,
  1262.   35
  1263. })
  1264. flowFormSetButtonProperty(menu.garageLightsStyleMenu.buttons[2], "scale", scale / 1.5)
  1265. local fontScale = scale / 1.2
  1266. menu.garageLightsStyleMenu.labels[1] = flowFormCreateLabel(0, screenHeight - buttonHeight * 2.7, screenWidth, screenHeight, "0/0", menu.garageLightsStyleMenu.form)
  1267. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[1], "scale", fontScale)
  1268. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[1], "align_horizontal", "center")
  1269. menu.garageLightsStyleMenu.labels[2] = flowFormCreateLabel(0, screenHeight - buttonHeight * 4, screenWidth, screenHeight, "", menu.garageLightsStyleMenu.form)
  1270. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[2], "scale", scale / 2)
  1271. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[2], "align_horizontal", "center")
  1272. menu.garageLightsStyleMenu.labels[3] = flowFormCreateLabel(0, screenHeight - buttonHeight * 1.2, screenWidth, screenHeight, "Default lights", menu.garageLightsStyleMenu.form)
  1273. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[3], "scale", scale / 3)
  1274. flowFormSetLabelProperty(menu.garageLightsStyleMenu.labels[3], "align_horizontal", "center")
  1275. menu.garageLightsStyleMenu.tiles[1] = flowFormCreateTile(screenWidth / 2 - garageTileWidth * 2, screenHeight - buttonHeight * 2.5, garageTileWidth, garageTileHeight, menu.garageLightsStyleMenu.form)
  1276. flowFormSetTileProperty(menu.garageLightsStyleMenu.tiles[1], "fn", "garageAcceptLightsStyle")
  1277. flowFormSetTileProperty(menu.garageLightsStyleMenu.tiles[1], "args", {})
  1278. flowFormSetTileProperty(menu.garageLightsStyleMenu.tiles[1], "text", nil)
  1279. flowFormSetTileProperty(menu.garageLightsStyleMenu.tiles[1], "color", {
  1280.   255,
  1281.   100,
  1282.   0
  1283. })
  1284. flowFormSetTileProperty(menu.garageLightsStyleMenu.tiles[1], "image", "img/dashboard/garage/accept.png")
  1285. menu.garagePlayerSkinMenu = {}
  1286. menu.garagePlayerSkinMenu.buttons = {}
  1287. menu.garagePlayerSkinMenu.labels = {}
  1288. menu.garagePlayerSkinMenu.tiles = {}
  1289. menu.garagePlayerSkinMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1290. local buttonWidth = tileSize * 0.7
  1291. local buttonHeight = buttonWidth / 2
  1292. local middleOffset = buttonWidth * 1.7
  1293. menu.garagePlayerSkinMenu.buttons[1] = flowFormCreateButton(screenWidth / 2 - middleOffset / 2 - buttonWidth, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, "<", menu.garagePlayerSkinMenu.form)
  1294. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[1], "colorcoded", false)
  1295. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[1], "fn", "garageCyclePlayerSkin")
  1296. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[1], "args", {"prev"})
  1297. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[1], "color", {
  1298.   35,
  1299.   35,
  1300.   35
  1301. })
  1302. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[1], "scale", scale / 1.5)
  1303. menu.garagePlayerSkinMenu.buttons[2] = flowFormCreateButton(screenWidth / 2 + middleOffset / 2, screenHeight - buttonHeight * 2.5, buttonWidth, buttonHeight, ">", menu.garagePlayerSkinMenu.form)
  1304. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[2], "colorcoded", false)
  1305. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[2], "fn", "garageCyclePlayerSkin")
  1306. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[2], "args", {"next"})
  1307. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[2], "color", {
  1308.   35,
  1309.   35,
  1310.   35
  1311. })
  1312. flowFormSetButtonProperty(menu.garagePlayerSkinMenu.buttons[2], "scale", scale / 1.5)
  1313. local fontScale = scale / 1.7
  1314. menu.garagePlayerSkinMenu.labels[1] = flowFormCreateLabel(0, screenHeight - buttonHeight * 2.7, screenWidth, screenHeight, "0/0", menu.garagePlayerSkinMenu.form)
  1315. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[1], "scale", fontScale)
  1316. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[1], "align_horizontal", "center")
  1317. menu.garagePlayerSkinMenu.labels[2] = flowFormCreateLabel(0, screenHeight - buttonHeight * 4, screenWidth, screenHeight, "", menu.garagePlayerSkinMenu.form)
  1318. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[2], "scale", scale / 2)
  1319. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[2], "align_horizontal", "center")
  1320. menu.garagePlayerSkinMenu.labels[3] = flowFormCreateLabel(0, screenHeight - buttonHeight * 1.2, screenWidth, screenHeight, "Default skin", menu.garagePlayerSkinMenu.form)
  1321. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[3], "scale", scale / 3)
  1322. flowFormSetLabelProperty(menu.garagePlayerSkinMenu.labels[3], "align_horizontal", "center")
  1323. menu.garagePlayerSkinMenu.tiles[1] = flowFormCreateTile(screenWidth / 2 - garageTileWidth * 2, screenHeight - buttonHeight * 2.5, garageTileWidth, garageTileHeight, menu.garagePlayerSkinMenu.form)
  1324. flowFormSetTileProperty(menu.garagePlayerSkinMenu.tiles[1], "fn", "garageAcceptPlayerSkin")
  1325. flowFormSetTileProperty(menu.garagePlayerSkinMenu.tiles[1], "args", {})
  1326. flowFormSetTileProperty(menu.garagePlayerSkinMenu.tiles[1], "text", nil)
  1327. flowFormSetTileProperty(menu.garagePlayerSkinMenu.tiles[1], "color", {
  1328.   255,
  1329.   100,
  1330.   0
  1331. })
  1332. flowFormSetTileProperty(menu.garagePlayerSkinMenu.tiles[1], "image", "img/dashboard/garage/accept.png")
  1333. function constructTaskMenu()
  1334.   if menu.taskMenu then
  1335.     flowFormDestroyForm(menu.taskMenu.form)
  1336.     menu.taskMenu = nil
  1337.   end
  1338.   menu.taskMenu = {}
  1339.   menu.taskMenu.tiles = {}
  1340.   menu.taskMenu.labels = {}
  1341.   menu.taskMenu.bars = {}
  1342.   menu.taskMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  1343.   local taskMenuItems = {
  1344.     {
  1345.       name = "Back",
  1346.       img = "img/dashboard/icons/arrow_full_left.png",
  1347.       fn = "swapLevel",
  1348.       args = {
  1349.         "[STEP_BACK]"
  1350.       }
  1351.     }
  1352.   }
  1353.   if getElementData(getLocalPlayer(), "TaskActive") == 1 then
  1354.     if TASK_DATA then
  1355.       menu.taskMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Current Task", scale / 1.5, "default-bold") / 2, scale * 17, screenWidth, screenHeight, "Current Task", menu.taskMenu.form)
  1356.       flowFormSetLabelProperty(menu.taskMenu.labels[1], "scale", scale / 1.5)
  1357.       local difficulty = "#00DD00Easy - 1 SP"
  1358.       if TASK_DATA.difficulty == 2 then
  1359.         difficulty = "#00AAFFMedium - 2 SP"
  1360.       elseif TASK_DATA.difficulty == 3 then
  1361.         difficulty = "#FF4400Hard - 3 SP"
  1362.       end
  1363.       menu.taskMenu.labels[3] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(TASK_DATA.text1, scale / 1.5, "default-bold") / 2, scale * 76, screenWidth, screenHeight, TASK_DATA.text1, menu.taskMenu.form)
  1364.       flowFormSetLabelProperty(menu.taskMenu.labels[3], "scale", scale / 1.5)
  1365.       menu.taskMenu.labels[4] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(difficulty:gsub("#%x%x%x%x%x%x", ""), scale / 2, "default-bold") / 2, scale * 87, screenWidth, screenHeight, difficulty, menu.taskMenu.form)
  1366.       flowFormSetLabelProperty(menu.taskMenu.labels[4], "scale", scale / 2)
  1367.       flowFormSetLabelProperty(menu.taskMenu.labels[4], "colorcoded", true)
  1368.       menu.taskMenu.labels[5] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(TASK_DATA.text2, scale / 2.8, "default-bold") / 2, scale * 109.2, screenWidth, screenHeight, TASK_DATA.text2, menu.taskMenu.form)
  1369.       flowFormSetLabelProperty(menu.taskMenu.labels[5], "scale", scale / 2.8)
  1370.       local width = scale * 140
  1371.       local height = scale * 7
  1372.       menu.taskMenu.bars[1] = flowFormCreateProgressBar(screenWidth / 2 - width / 2, screenHeight - height * 9, width, height, menu.taskMenu.form)
  1373.       flowFormSetProgressBarProperty(menu.taskMenu.bars[1], "scale", scale / 2.4)
  1374.       flowFormSetProgressBarProperty(menu.taskMenu.bars[1], "textcolor", {
  1375.         255,
  1376.         255,
  1377.         255
  1378.       })
  1379.       if TASK_DATA.progress == 0 then
  1380.         flowFormSetProgressBarProperty(menu.taskMenu.bars[1], "progress", 0)
  1381.       else
  1382.         flowFormSetProgressBarProperty(menu.taskMenu.bars[1], "progress", 100 / TASK_DATA.target * TASK_DATA.progress / 100)
  1383.       end
  1384.       table.insert(taskMenuItems, {
  1385.         name = "Abandon Task",
  1386.         img = "img/dashboard/icons/cross.png",
  1387.         fn = "swapLevel",
  1388.         args = {
  1389.           "abandonTaskMenu"
  1390.         }
  1391.       })
  1392.     end
  1393.   else
  1394.     menu.taskMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Tasks", scale / 1.5, "default-bold") / 2, scale * 17, screenWidth, screenHeight, "Tasks", menu.taskMenu.form)
  1395.     flowFormSetLabelProperty(menu.taskMenu.labels[1], "scale", scale / 1.5)
  1396.     menu.taskMenu.labels[2] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("You do not have an active Task at the moment", scale / 2.5, "default-bold") / 2, scale * 75, screenWidth, screenHeight, "You do not have an active Task at the moment", menu.taskMenu.form)
  1397.     flowFormSetLabelProperty(menu.taskMenu.labels[2], "scale", scale / 2.5)
  1398.     menu.taskMenu.labels[3] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Click the \"New Task\" button below to get a new Task", scale / 2.5, "default-bold") / 2, scale * 83, screenWidth, screenHeight, "Click the \"New Task\" button below to get a new Task", menu.taskMenu.form)
  1399.     flowFormSetLabelProperty(menu.taskMenu.labels[3], "scale", scale / 2.5)
  1400.     table.insert(taskMenuItems, {
  1401.       name = "New Task",
  1402.       img = "img/dashboard/icons/flag.png",
  1403.       fn = "swapLevel",
  1404.       args = {
  1405.         "newTaskMenu"
  1406.       }
  1407.     })
  1408.   end
  1409.   local startingPosition = screenWidth / 2 - (tileSize * #taskMenuItems + tileSize / 20 * #taskMenuItems) / 2 - tileSize
  1410.   for i, k in ipairs(taskMenuItems) do
  1411.     menu.taskMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight / 2 + listHeight / 2 + tileSize / 2, tileSize, tileSize, menu.taskMenu.form)
  1412.     flowFormSetTileProperty(menu.taskMenu.tiles[i], "fn", k.fn)
  1413.     flowFormSetTileProperty(menu.taskMenu.tiles[i], "args", k.args)
  1414.     flowFormSetTileProperty(menu.taskMenu.tiles[i], "text", k.name)
  1415.     flowFormSetTileProperty(menu.taskMenu.tiles[i], "color", {
  1416.       255,
  1417.       100,
  1418.       0
  1419.     })
  1420.     flowFormSetTileProperty(menu.taskMenu.tiles[i], "image", k.img)
  1421.   end
  1422. end
  1423. menu.newTaskMenu = {}
  1424. menu.newTaskMenu.tiles = {}
  1425. menu.newTaskMenu.labels = {}
  1426. menu.newTaskMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1427. menu.newTaskMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Select Difficulty", scale / 1.5, "default-bold") / 2, scale * 35, screenWidth, screenHeight, "Select Difficulty", menu.newTaskMenu.form)
  1428. flowFormSetLabelProperty(menu.newTaskMenu.labels[1], "scale", scale / 1.5)
  1429. local newTaskMenuItems = {
  1430.   {
  1431.     name = nil,
  1432.     img = "img/task-easy.png",
  1433.     fn = "startNewTask",
  1434.     args = {1}
  1435.   },
  1436.   {
  1437.     name = nil,
  1438.     img = "img/task-medium.png",
  1439.     fn = "startNewTask",
  1440.     args = {2}
  1441.   },
  1442.   {
  1443.     name = nil,
  1444.     img = "img/task-hard.png",
  1445.     fn = "startNewTask",
  1446.     args = {3}
  1447.   }
  1448. }
  1449. local taskTileWidth = math.floor(tileSize * 4)
  1450. local taskTileHeight = math.floor(taskTileWidth / 4)
  1451. for i, k in ipairs(newTaskMenuItems) do
  1452.   menu.newTaskMenu.tiles[i] = flowFormCreateTile(screenWidth / 2 - taskTileWidth / 2, scale * 30 + taskTileHeight * 1.1 * i, taskTileWidth, taskTileHeight, menu.newTaskMenu.form)
  1453.   flowFormSetTileProperty(menu.newTaskMenu.tiles[i], "fn", k.fn)
  1454.   flowFormSetTileProperty(menu.newTaskMenu.tiles[i], "args", k.args)
  1455.   flowFormSetTileProperty(menu.newTaskMenu.tiles[i], "text", k.name)
  1456.   flowFormSetTileProperty(menu.newTaskMenu.tiles[i], "color", {
  1457.     255,
  1458.     100,
  1459.     0
  1460.   })
  1461.   flowFormSetTileProperty(menu.newTaskMenu.tiles[i], "image", k.img)
  1462. end
  1463. menu.abandonTaskMenu = {}
  1464. menu.abandonTaskMenu.tiles = {}
  1465. menu.abandonTaskMenu.labels = {}
  1466. menu.abandonTaskMenu.form = flowFormCreateForm(0, 0, screenWidth, screenHeight, false)
  1467. menu.abandonTaskMenu.labels[1] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth("Do you wish to abandon your current task?", scale / 1.5, "default-bold") / 2, scale * 38, screenWidth, screenHeight, "Do you wish to abandon your current task?", menu.abandonTaskMenu.form)
  1468. flowFormSetLabelProperty(menu.abandonTaskMenu.labels[1], "scale", scale / 1.5)
  1469. local text = "If you don't like your current Task, you can abandon it and get a new one"
  1470. menu.abandonTaskMenu.labels[2] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale / 2.5, "default-bold") / 2, scale * 60, screenWidth, screenHeight, text, menu.abandonTaskMenu.form)
  1471. flowFormSetLabelProperty(menu.abandonTaskMenu.labels[2], "scale", scale / 2.5)
  1472. local text = "To abandon a Task, you need to pay a fee of #FF8C00$20,000"
  1473. menu.abandonTaskMenu.labels[3] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale / 2.5, "default-bold") / 2, scale * 60 + scale * 6, screenWidth, screenHeight, text, menu.abandonTaskMenu.form)
  1474. flowFormSetLabelProperty(menu.abandonTaskMenu.labels[3], "scale", scale / 2.5)
  1475. flowFormSetLabelProperty(menu.abandonTaskMenu.labels[3], "colorcoded", true)
  1476. local text = "All progress you made so far will be lost!"
  1477. menu.abandonTaskMenu.labels[4] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale / 2.5, "default-bold") / 2, scale * 60 + scale * 15, screenWidth, screenHeight, text, menu.abandonTaskMenu.form)
  1478. flowFormSetLabelProperty(menu.abandonTaskMenu.labels[4], "scale", scale / 2.5)
  1479. local abandonTaskMenuItems = {
  1480.   {
  1481.     name = nil,
  1482.     img = "img/task-abandon.png",
  1483.     fn = "abandonCurrentTask",
  1484.     args = {}
  1485.   },
  1486.   {
  1487.     name = nil,
  1488.     img = "img/task-continue.png",
  1489.     fn = "swapLevel",
  1490.     args = {
  1491.       "[STEP_BACK]"
  1492.     }
  1493.   }
  1494. }
  1495. local taskTileWidth = math.floor(tileSize * 4)
  1496. local taskTileHeight = math.floor(taskTileWidth / 4)
  1497. for i, k in ipairs(abandonTaskMenuItems) do
  1498.   menu.abandonTaskMenu.tiles[i] = flowFormCreateTile(screenWidth / 2 - taskTileWidth / 2, scale * 70 + taskTileHeight * 1.1 * i, taskTileWidth, taskTileHeight, menu.abandonTaskMenu.form)
  1499.   flowFormSetTileProperty(menu.abandonTaskMenu.tiles[i], "fn", k.fn)
  1500.   flowFormSetTileProperty(menu.abandonTaskMenu.tiles[i], "args", k.args)
  1501.   flowFormSetTileProperty(menu.abandonTaskMenu.tiles[i], "text", k.name)
  1502.   flowFormSetTileProperty(menu.abandonTaskMenu.tiles[i], "color", {
  1503.     255,
  1504.     100,
  1505.     0
  1506.   })
  1507.   flowFormSetTileProperty(menu.abandonTaskMenu.tiles[i], "image", k.img)
  1508. end
  1509. local yFix = 70
  1510. function constructSettingsMenu()
  1511.   if menu.settingsMenu and menu.settingsMenu.form then
  1512.     flowFormDestroyForm(menu.settingsMenu.form)
  1513.   end
  1514.   menu.settingsMenu = {}
  1515.   menu.settingsMenu.tiles = {}
  1516.   menu.settingsMenu.labels = {}
  1517.   menu.settingsMenu.strips = {}
  1518.   menu.settingsMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  1519.   local settingsMenuItems = {
  1520.     {
  1521.       name = "Accept",
  1522.       img = "img/dashboard/icons/arrow_full_left.png",
  1523.       fn = "swapLevel",
  1524.       args = {
  1525.         "[STEP_BACK]"
  1526.       }
  1527.     }
  1528.   }
  1529.   local startingPosition = screenWidth / 2 - (tileSize * #settingsMenuItems + tileSize / 20 * #settingsMenuItems) / 2 - tileSize
  1530.   for i, k in ipairs(settingsMenuItems) do
  1531.     menu.settingsMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight - tileSize * 1.6, tileSize, tileSize, menu.settingsMenu.form)
  1532.     flowFormSetTileProperty(menu.settingsMenu.tiles[i], "fn", k.fn)
  1533.     flowFormSetTileProperty(menu.settingsMenu.tiles[i], "args", k.args)
  1534.     flowFormSetTileProperty(menu.settingsMenu.tiles[i], "text", k.name)
  1535.     flowFormSetTileProperty(menu.settingsMenu.tiles[i], "color", {
  1536.       255,
  1537.       100,
  1538.       0
  1539.     })
  1540.     flowFormSetTileProperty(menu.settingsMenu.tiles[i], "image", k.img)
  1541.   end
  1542.   for i, k in ipairs(SETTINGS_LIST) do
  1543.     if k.text then
  1544.       local offsetFromCenter = scale * 4
  1545.       local scale = scale / 3
  1546.       menu.settingsMenu.labels[i] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(k.text, scale, "default-bold") - offsetFromCenter, scale * 80 + i * dxGetFontHeight(scale, "default-bold") * 1.5 - yFix, screenWidth, screenHeight, k.text, menu.settingsMenu.form)
  1547.       flowFormSetLabelProperty(menu.settingsMenu.labels[i], "scale", scale)
  1548.       menu.settingsMenu.strips[i] = flowFormCreateStrip(screenWidth / 2 + offsetFromCenter, scale * 80 + i * dxGetFontHeight(scale, "default-bold") * 1.5 - yFix, menu.settingsMenu.form)
  1549.       for x, y in ipairs(k.options) do
  1550.         flowFormAddStripItem(menu.settingsMenu.strips[i], y[1], "default-bold", scale, "saveSetting", {
  1551.           k.data,
  1552.           y[2]
  1553.         })
  1554.       end
  1555.       if SETTINGS[k.data] then
  1556.         flowFormStripSetSelected(menu.settingsMenu.strips[i], SETTINGS[k.data])
  1557.       else
  1558.         flowFormStripSetSelected(menu.settingsMenu.strips[i], k.default)
  1559.       end
  1560.     end
  1561.   end
  1562. end
  1563. for i, thisMenu in pairs(menu) do
  1564.   flowFormSetPosition(thisMenu.form, screenWidth, 0)
  1565.   flowFormSetProperty(thisMenu.form, "visible", false)
  1566.   flowFormSetProperty(thisMenu.form, "alpha", 0)
  1567. end
  1568. function preRenderDashboardOperations()
  1569.   if dashboard.alpha <= 0 then
  1570.     for i, thisMenu in pairs(menu) do
  1571.       flowFormSetPosition(thisMenu.form, screenWidth, 0)
  1572.       flowFormSetProperty(thisMenu.form, "visible", false)
  1573.     end
  1574.     return
  1575.   end
  1576.   local now = getTickCount()
  1577.   local elapsedTime = now - dashboard.animationStartTime
  1578.   local duration = dashboard.animationEndTime - dashboard.animationStartTime
  1579.   local progress = elapsedTime / duration
  1580.   if now > dashboard.animationEndTime then
  1581.     progress = 1
  1582.   end
  1583.   if dashboard.animationEasingFunction == "OutBack" then
  1584.     fAnimationTime = getEasingValue(progress, dashboard.animationEasingFunction, 0, 0, 1)
  1585.   elseif dashboard.animationEasingFunction == "OutElastic" then
  1586.     fAnimationTime = getEasingValue(progress, dashboard.animationEasingFunction, 0.35, 1)
  1587.   else
  1588.     fAnimationTime = getEasingValue(progress, dashboard.animationEasingFunction)
  1589.   end
  1590.   local addition = (dashboard.currentLevel - dashboard.lastViewportProgression) * fAnimationTime
  1591.   dashboard.viewportProgression = dashboard.lastViewportProgression + addition
  1592.   local levelsOnScreen = {}
  1593.   for i, thisMenu in pairs(menu) do
  1594.     local match = false
  1595.     for x, level in ipairs(menuLevels) do
  1596.       if level == i then
  1597.         match = {x, level}
  1598.       end
  1599.     end
  1600.     if match then
  1601.       flowFormSetProperty(menu[match[2]].form, "visible", true)
  1602.       flowFormSetProperty(menu[match[2]].form, "alpha", dashboard.alpha)
  1603.       flowFormSetPosition(menu[match[2]].form, screenWidth * (match[1] - 1), 0)
  1604.       table.insert(levelsOnScreen, match[1], menu[match[2]])
  1605.     else
  1606.       flowFormSetProperty(menu[i].form, "alpha", 0)
  1607.       flowFormSetProperty(menu[i].form, "visible", false)
  1608.     end
  1609.   end
  1610.   for i, level in pairs(levelsOnScreen) do
  1611.     local px, py = flowFormGetPosition(level.form)
  1612.     if px then
  1613.       px = px - screenWidth * (dashboard.viewportProgression - 1)
  1614.       flowFormSetPosition(level.form, px, py)
  1615.     end
  1616.   end
  1617.   for i, level in pairs(levelsOnScreen) do
  1618.     local px, py = flowFormGetPosition(level.form)
  1619.     if px then
  1620.       local levelOffset = math.abs(px) / (screenWidth * 1.5)
  1621.       local levelAlpha = math.min(math.max(dashboard.alpha - dashboard.alpha * levelOffset, 0), dashboard.alpha)
  1622.       flowFormSetProperty(level.form, "alpha", levelAlpha)
  1623.       if levelAlpha <= 0 then
  1624.         flowFormSetProperty(level.form, "visible", false)
  1625.       else
  1626.         flowFormSetProperty(level.form, "visible", true)
  1627.       end
  1628.     end
  1629.   end
  1630. end
  1631. addEventHandler("onClientPreRender", getRootElement(), preRenderDashboardOperations)
  1632. function drawPanel()
  1633.   if dashboardDisplaying == false then
  1634.     dashboard.alpha = math.max(dashboard.alpha - 14, 0)
  1635.     if dashboard.alpha == 0 then
  1636.       dashboard.currentLevel = 1
  1637.       dashboard.viewportProgression = 1
  1638.       for i, thisMenu in pairs(menu) do
  1639.         flowFormSetProperty(thisMenu.form, "alpha", 0)
  1640.         flowFormSetProperty(thisMenu.form, "visible", false)
  1641.       end
  1642.     end
  1643.     return false
  1644.   else
  1645.     dashboard.alpha = math.min(dashboard.alpha + 14, 255)
  1646.   end
  1647.   if dashboard.alpha > 0 and not IN_GARAGE then
  1648.     dxDrawRectangle(0, 0, screenWidth, screenHeight, tocolor(0, 0, 0, dashboard.alpha / 2))
  1649.     local imgW = scale * 95
  1650.     local imgH = imgW / 4
  1651.     local px, py = flowFormGetProperty(menu.rootMenu.form, "posX"), flowFormGetProperty(menu.rootMenu.form, "posY")
  1652.     dxDrawImage(px + screenWidth / 2 - imgW / 2, py + screenHeight / 2 - imgH * 1.7, imgW, imgH, "img/dashboard.png", 0, 0, 0, tocolor(255, 255, 255, flowFormGetProperty(menu.rootMenu.form, "alpha")))
  1653.     dxDrawText("Dashboard created by Rointep aka Nextreme @ Zur.io", screenWidth / 2, screenHeight - 10)
  1654.   end
  1655. end
  1656. addEventHandler("onClientRender", getRootElement(), drawPanel)
  1657. menuLevels = {
  1658.   [1] = "rootMenu"
  1659. }
  1660. function swapLevel(level)
  1661.   if dashboard.canSwapLevel == false then
  1662.     return
  1663.   end
  1664.   local oldLevel = ""
  1665.   local newLevel = ""
  1666.   dashboard.lastViewportProgression = dashboard.viewportProgression
  1667.   if level == "[STEP_BACK]" then
  1668.     oldLevel = menuLevels[dashboard.currentLevel]
  1669.     newLevel = menuLevels[math.max(dashboard.currentLevel - 1, 1)]
  1670.     dashboard.currentLevel = math.max(dashboard.currentLevel - 1, 1)
  1671.   else
  1672.     oldLevel = menuLevels[dashboard.currentLevel]
  1673.     newLevel = level
  1674.     dashboard.currentLevel = dashboard.currentLevel + 1
  1675.     menuLevels[dashboard.currentLevel] = level
  1676.   end
  1677.   dashboard.animationStartTime = getTickCount()
  1678.   dashboard.animationEndTime = dashboard.animationStartTime + animationStyles[currentAnimationStyle][2]
  1679.   dashboard.animationEasingFunction = animationStyles[currentAnimationStyle][1]
  1680.   if isTimer(levelSwapTimer) then
  1681.     killTimer(levelSwapTimer)
  1682.   end
  1683.   levelSwapTimer = setTimer(function()
  1684.     dashboard.canSwapLevel = true
  1685.   end, 100, 1)
  1686.   dashboard.canSwapLevel = false
  1687.   triggerEvent("onDashboardLevelChanged", getRootElement(), oldLevel, newLevel)
  1688. end
  1689. function toggleDashboard()
  1690.   if isPlayerGuest(getLocalPlayer()) or IN_GARAGE then
  1691.     return
  1692.   end
  1693.   if menu.mapMainMenu.fields[1] then
  1694.     flowFormClearFocus(menu.mapMainMenu.fields[1])
  1695.   end
  1696.   if menu.garageSwapVehicleMenu.fields[1] then
  1697.     flowFormClearFocus(menu.garageSwapVehicleMenu.fields[1])
  1698.   end
  1699.   dashboardDisplaying = not dashboardDisplaying
  1700.   flowFormActive = dashboardDisplaying
  1701.   if dashboardDisplaying then
  1702.     showCursor(true)
  1703.     for i, tile in ipairs(menu.rootMenu.tiles) do
  1704.       tile.itemData.DX3D.enabled = true
  1705.       tile.itemData.DX3D.frozen = true
  1706.       tile.itemData.DX3D.rotX = 90
  1707.       setTimer(function()
  1708.         tile.itemData.DX3D.frozen = false
  1709.       end, 110 * i, 1)
  1710.     end
  1711.   else
  1712.     showCursor(false)
  1713.   end
  1714. end
  1715. bindKey("F7", "down", toggleDashboard)
  1716. addEvent("onDashboardLevelChanged", true)
  1717. addEventHandler("onDashboardLevelChanged", getRootElement(), function(oldLevel, newLevel)
  1718.   if oldLevel == "playerSelectionMenu" and newLevel == "statsMenu" then
  1719.     player_stats[1] = getPlayerName(LAST_SELECTED_PLAYER)
  1720.     reloadPlayerStats(LAST_SELECTED_PLAYER, "_ALL_")
  1721.     updateStatsDisplay()
  1722.   elseif newLevel == "statsMenu" then
  1723.     reloadPlayerStats(getLocalPlayer(), "_ALL_")
  1724.     updateStatsDisplay()
  1725.   elseif newLevel == "taskMenu" or oldLevel == "newTaskMenu" then
  1726.     callServerFunction("getCurrentTaskInfo", getLocalPlayer())
  1727.   end
  1728. end)
  1729. viewingOwnStats = true
  1730. player_stats = {
  1731.   getPlayerName(getLocalPlayer())
  1732. }
  1733. stats_names = {
  1734.   "<PlayerName>",
  1735.   "Cash",
  1736.   "Exp",
  1737.   "SP",
  1738.   "TotalSP",
  1739.   "Wins",
  1740.   "Attempts",
  1741.   "Percent",
  1742.   "WinStreak",
  1743.   "Achievements",
  1744.   "TasksCompleted",
  1745.   "Joined",
  1746.   "Playtime",
  1747.   "TimesTaken",
  1748.   "HunterPercent",
  1749.   "Toptimes",
  1750.   "RocketsFired",
  1751.   "KilledHunter",
  1752.   "KilledShooterCTF",
  1753.   "MapsBought",
  1754.   "TimesChangedVehicle",
  1755.   "PVPWins",
  1756.   "DMAttempts",
  1757.   "DMWins",
  1758.   "DMPercent",
  1759.   "DDAttempts",
  1760.   "DDWins",
  1761.   "DDPercent",
  1762.   "RACEAttempts",
  1763.   "RACEWins",
  1764.   "RACEPercent",
  1765.   "CTFAttempts",
  1766.   "CTFWins",
  1767.   "CTFPercent",
  1768.   "CTFFlagsTaken",
  1769.   "CTFFlagsCaptured",
  1770.   "SHAttempts",
  1771.   "SHWins",
  1772.   "SHPercent"
  1773. }
  1774. function updateStatsDisplay()
  1775.   flowFormSetLabelProperty(menu.statsMenu.labels[1], "text", player_stats[1])
  1776.   for i, text in pairs(dx_stats) do
  1777.     if text:lower():find("playtime") ~= nil then
  1778.       local playtime = tonumber(player_stats[i + 1])
  1779.       local time = {m = 0, h = 0}
  1780.       repeat
  1781.         if playtime >= 60 then
  1782.           playtime = playtime - 60
  1783.           time.h = time.h + 1
  1784.         else
  1785.           time.m = playtime
  1786.           playtime = 0
  1787.         end
  1788.       until playtime == 0
  1789.       if time.m < 10 then
  1790.         time.m = "0" .. time.m
  1791.       end
  1792.       if time.h < 10 then
  1793.         time.h = "0" .. time.h
  1794.       end
  1795.       flowFormSetLabelProperty(menu.statsMenu.labels[i + 1], "text", text .. time.h .. ":" .. time.m)
  1796.     else
  1797.       local append = ""
  1798.       if text:lower():find("percent") ~= nil then
  1799.         player_stats[i + 1] = math.round(player_stats[i + 1], 2)
  1800.         append = "%"
  1801.       end
  1802.       flowFormSetLabelProperty(menu.statsMenu.labels[i + 1], "text", text .. player_stats[i + 1] .. append)
  1803.     end
  1804.   end
  1805. end
  1806. function reloadPlayerStats(who, reloadWhat)
  1807.   reloadWhat = reloadWhat or "_ALL_"
  1808.   if getElementData(who, "Cash") == "Guest" then
  1809.     return
  1810.   end
  1811.   if not viewingOwnStats then
  1812.     return
  1813.   end
  1814.   if reloadWhat == "_ALL_" then
  1815.     for i, data in pairs(stats_names) do
  1816.       player_stats[i] = tostring(getElementData(who, data))
  1817.     end
  1818.   else
  1819.     local counter = 0
  1820.     for i, check in pairs(stats_names) do
  1821.       if reloadWhat == check then
  1822.         counter = i
  1823.         break
  1824.       end
  1825.     end
  1826.     if counter ~= 0 then
  1827.       player_stats[counter] = tostring(getElementData(who, stats_names[counter]))
  1828.     else
  1829.       outputDebugString("Failed to update stat " .. reloadWhat .. "!")
  1830.     end
  1831.   end
  1832.   local pName = getElementData(who, "Player.Name")
  1833.   if not pName or pName == "" then
  1834.     pName = getPlayerName(who)
  1835.   end
  1836.   player_stats[1] = pName
  1837. end
  1838. addEventHandler("onClientResourceStart", resourceRoot, function()
  1839.   reloadPlayerStats(getLocalPlayer(), "_ALL_")
  1840. end)
  1841. function setSelectedPlayer(player)
  1842.   LAST_SELECTED_PLAYER = player
  1843.   swapLevel("[STEP_BACK]")
  1844. end
  1845. function reloadPlayerListForSelectionScreen()
  1846. end
  1847. for k, gui in ipairs(getElementsByType("gui-window", resourceRoot)) do
  1848.   guiSetVisible(gui, false)
  1849. end
  1850. local yFix = -70
  1851. function constructdonatorMenu()
  1852.   if menu.donatorMenu and menu.donatorMenu.form then
  1853.     flowFormDestroyForm(menu.donatorMenu.form)
  1854.   end
  1855.   menu.donatorMenu = {}
  1856.   menu.donatorMenu.tiles = {}
  1857.   menu.donatorMenu.labels = {}
  1858.   menu.donatorMenu.strips = {}
  1859.   menu.donatorMenu.form = flowFormCreateForm(screenWidth, 0, screenWidth, screenHeight, false)
  1860.   local donatorMenuItems = {
  1861.     {
  1862.       name = "Accept",
  1863.       img = "img/dashboard/icons/arrow_full_left.png",
  1864.       fn = "swapLevel",
  1865.       args = {
  1866.         "[STEP_BACK]"
  1867.       }
  1868.     },
  1869.     {
  1870.       name = "Watch Live CW",
  1871.       img = "img/dashboard/icons/star_outline.png",
  1872.       fn = "joinCW",
  1873.       args = {}
  1874.     }
  1875.   }
  1876.   local startingPosition = screenWidth / 2 - (tileSize * #donatorMenuItems + tileSize / 20 * #donatorMenuItems) / 2 - tileSize
  1877.   for i, k in ipairs(donatorMenuItems) do
  1878.     menu.donatorMenu.tiles[i] = flowFormCreateTile(startingPosition + tileSize * i + tileSize / 20 * i, screenHeight - tileSize * 1.6, tileSize, tileSize, menu.donatorMenu.form)
  1879.     flowFormSetTileProperty(menu.donatorMenu.tiles[i], "fn", k.fn)
  1880.     flowFormSetTileProperty(menu.donatorMenu.tiles[i], "args", k.args)
  1881.     flowFormSetTileProperty(menu.donatorMenu.tiles[i], "text", k.name)
  1882.     flowFormSetTileProperty(menu.donatorMenu.tiles[i], "color", {
  1883.       255,
  1884.       100,
  1885.       0
  1886.     })
  1887.     flowFormSetTileProperty(menu.donatorMenu.tiles[i], "image", k.img)
  1888.   end
  1889.   for i, k in ipairs(DONATOR_LIST) do
  1890.     if k.text then
  1891.       if k.info then
  1892.         k.options[1][1] = getElementData(localPlayer, "freeMaps") .. " Maps Left"
  1893.       end
  1894.       local offsetFromCenter = scale * 4
  1895.       local scale = scale / 3
  1896.       menu.donatorMenu.labels[i] = flowFormCreateLabel(screenWidth / 2 - dxGetTextWidth(k.text, scale, "default-bold") - offsetFromCenter, scale * 80 + i * dxGetFontHeight(scale, "default-bold") * 1.5 - yFix, screenWidth, screenHeight, k.text, menu.donatorMenu.form)
  1897.       flowFormSetLabelProperty(menu.donatorMenu.labels[i], "scale", scale)
  1898.       menu.donatorMenu.strips[i] = flowFormCreateStrip(screenWidth / 2 + offsetFromCenter, scale * 80 + i * dxGetFontHeight(scale, "default-bold") * 1.5 - yFix, menu.donatorMenu.form)
  1899.       for x, y in ipairs(k.options) do
  1900.         flowFormAddStripItem(menu.donatorMenu.strips[i], y[1], "default-bold", scale, "saveDonatorSetting", {
  1901.           k.data,
  1902.           y[2]
  1903.         })
  1904.       end
  1905.       if DONATOR[k.data] then
  1906.         flowFormStripSetSelected(menu.donatorMenu.strips[i], DONATOR[k.data])
  1907.       else
  1908.         flowFormStripSetSelected(menu.donatorMenu.strips[i], k.default)
  1909.       end
  1910.     end
  1911.   end
  1912. end
  1913. function checkDonator()
  1914.   if getElementData(getLocalPlayer(), "isDonator") then
  1915.     swapLevel("donatorMenu")
  1916.   else
  1917.     exports.xmsg:displayMsg("error", "You're not donator!", "Access Denied")
  1918.   end
  1919. end
  1920. function joinCW()
  1921.   if getElementData(getLocalPlayer(), "isDonator") then
  1922.     triggerServerEvent("watchCWlive", localPlayer)
  1923.   else
  1924.     exports.xmsg:displayMsg("error", "You're not donator!", "Access Denied")
  1925.   end
  1926. end
Advertisement
Add Comment
Please, Sign In to add comment