thenuke321

Untitled

May 31st, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.37 KB | None | 0 0
  1. function getSidebarSetting(_ARG_0_)
  2.   return Settings[_ARG_0_]
  3. end
  4. function setSidebarSetting(_ARG_0_, _ARG_1_)
  5.   Settings[_ARG_0_] = _ARG_1_
  6.   if isTimer(saveSettingsTimer) then
  7.     killTimer(saveSettingsTimer)
  8.   end
  9.   saveSettingsTimer = setTimer(saveSettings, 2000, 1, true)
  10. end
  11. addEventHandler("onClientChatMessage", root, function(_ARG_0_)
  12.   if string.gsub(_ARG_0_, " ", "") == "" then
  13.     cancelEvent()
  14.   end
  15. end)
  16. sidebar = {}
  17. sidebar.r = 5
  18. sidebar.g = 5
  19. sidebar.b = 5
  20. sidebar.a = 250
  21. sidebar.tr = 255
  22. sidebar.tg = 255
  23. sidebar.tb = 255
  24. theBoundSidebarKey = "u"
  25. sidebar.weekday = {
  26.   "Sunday",
  27.   "Monday",
  28.   "Tuesday",
  29.   "Wednesday",
  30.   "Thursday",
  31.   "Friday",
  32.   "Saturday"
  33. }
  34. sidebar.month = {
  35.   "January",
  36.   "February",
  37.   "March",
  38.   "April",
  39.   "May",
  40.   "June",
  41.   "July",
  42.   "August",
  43.   "September",
  44.   "October",
  45.   "November",
  46.   "December"
  47. }
  48. sidebar.appbgr = {
  49.   [0] = 0
  50. }
  51. sx, sy = guiGetScreenSize()
  52. white = tocolor(255, 255, 255, 255)
  53. sidebar.width = 160
  54. sidebar.app = {
  55.   "Maps",
  56.   "Store",
  57.   "Music",
  58.   "Stats",
  59.   "9GAG",
  60.   "Screenshots",
  61.   "Clan Manager",
  62.   "Settings"
  63. }
  64. sidebar.commands = {
  65.   "maps",
  66.   "store",
  67.   "music",
  68.   "stats",
  69.   "9gag",
  70.   "screenshots",
  71.   "clan",
  72.   "settings"
  73. }
  74. for _FORV_4_, _FORV_5_ in ipairs(sidebar.app) do
  75.   sidebar.appbgr[_FORV_4_] = 0
  76. end
  77. sidebar.hover = {}
  78. sidebar.hover[8] = function(_ARG_0_)
  79.   return _ARG_0_ * 10
  80. end
  81. if sy < 10 + 3 * 15 + 1 * 15 + 10 + #sidebar.app * (64 + 15) + 100 then
  82.   sidebar.width = 120
  83. end
  84. function drawSidebar()
  85.   if sidebar.state ~= 0 then
  86.     showCursor(true)
  87.   end
  88.   checkStates()
  89.   dxDrawRectangle(sx - sidebar.pos, 0, sidebar.pos, sy, tocolor(sidebar.r, sidebar.g, sidebar.b, sidebar.a), true)
  90.   dxDrawLine(sx - sidebar.pos, 0, sx - sidebar.pos, sy, tocolor(100, 100, 100, 100), 1, true)
  91.   dxDrawText(string.format("%02d:%02d", getRealTime().hour, getRealTime().minute), sx - sidebar.pos, _UPVALUE0_, sx - sidebar.pos + sidebar.width, _UPVALUE0_ + _UPVALUE1_ * 15, white, _UPVALUE1_, "default-bold", "center", "top", false, false, true)
  92.   dxDrawText(sidebar.weekday[getRealTime().weekday + 1] .. ", " .. sidebar.month[getRealTime().month + 1] .. " " .. getRealTime().monthday, sx - sidebar.pos, _UPVALUE0_ + _UPVALUE1_ * 15, sx - sidebar.pos + sidebar.width, _UPVALUE0_ + _UPVALUE1_ * 15 + _UPVALUE2_ * 15, white, _UPVALUE2_, "default-bold", "center", "top", false, false, true)
  93.   if getCursorPosition() and getCursorPosition() * sx and (getCursorPosition() and getCursorPosition() * sx) >= sx - sidebar.pos and 0 <= getCursorPosition() * sy and getCursorPosition() * sy < _UPVALUE3_ then
  94.     if getKeyState("mouse1") then
  95.       sidebar.appbgr[0] = 1.4
  96.     else
  97.       sidebar.appbgr[0] = math.min(1, sidebar.appbgr[0] + 0.1)
  98.     end
  99.   else
  100.     sidebar.appbgr[0] = math.max(0, sidebar.appbgr[0] - 0.1)
  101.   end
  102.   dxDrawRectangle(sx - sidebar.pos, 0, sidebar.width, _UPVALUE3_, tocolor(255, 255, 255, sidebar.appbgr[0] * 20), true)
  103.   if 0 < sidebar.appbgr[0] then
  104.     dxDrawRectangle(sx - sidebar.pos - sidebar.width, 0, sidebar.width, _UPVALUE3_, tocolor(sidebar.r, sidebar.g, sidebar.b, sidebar.appbgr[0] * sidebar.a * 0.9), true)
  105.     dxDrawText(string.format("%02d:%02d", getRealTime(getRealTime().timestamp + serverTimestampDifference).hour, getRealTime(getRealTime().timestamp + serverTimestampDifference).minute), sx - sidebar.pos - sidebar.width, _UPVALUE0_, sx - sidebar.pos, _UPVALUE3_, tocolor(255, 255, 255, sidebar.appbgr[0] * 255), _UPVALUE1_, "default-bold", "center", "top", false, false, true)
  106.     dxDrawText("Server Time", sx - sidebar.pos - sidebar.width, _UPVALUE0_ + _UPVALUE1_ * 15, sx - sidebar.pos, _UPVALUE0_ + _UPVALUE1_ * 15 + _UPVALUE2_ * 15, tocolor(255, 255, 255, sidebar.appbgr[0] * 255), _UPVALUE2_, "default-bold", "center", "top", false, false, true)
  107.   end
  108.   for _FORV_9_, _FORV_10_ in ipairs(sidebar.app) do
  109.     if getCursorPosition() and getCursorPosition() * sx and (getCursorPosition() and getCursorPosition() * sx) >= sx - sidebar.pos and getCursorPosition() * sy >= _UPVALUE3_ + (_FORV_9_ - 1) * _UPVALUE4_ and getCursorPosition() * sy < _UPVALUE3_ + _FORV_9_ * _UPVALUE4_ then
  110.       if getKeyState("mouse1") then
  111.         sidebar.appbgr[_FORV_9_] = 1.4
  112.       else
  113.         sidebar.appbgr[_FORV_9_] = math.min(1, sidebar.appbgr[_FORV_9_] + 0.1)
  114.         _UPVALUE5_[_FORV_9_] = (_UPVALUE5_[_FORV_9_] or 0) + 0.1
  115.       end
  116.     else
  117.       sidebar.appbgr[_FORV_9_] = math.max(0, sidebar.appbgr[_FORV_9_] - 0.1)
  118.       _UPVALUE5_[_FORV_9_] = 0
  119.     end
  120.     dxDrawRectangle(sx - sidebar.pos, _UPVALUE3_ + (_FORV_9_ - 1) * _UPVALUE4_, sidebar.width, _UPVALUE4_, tocolor(255, 255, 255, sidebar.appbgr[_FORV_9_] * 20), true)
  121.     dxDrawImage(sx - sidebar.pos + _UPVALUE6_, _UPVALUE3_ + (_FORV_9_ - 1) * _UPVALUE4_ + _UPVALUE7_, _UPVALUE8_, _UPVALUE8_, "images/icons/" .. sidebar.commands[_FORV_9_] .. ".png", sidebar.hover[_FORV_9_] and sidebar.hover[_FORV_9_](_UPVALUE5_[_FORV_9_]) or math.sin(_UPVALUE5_[_FORV_9_] * 1.5) * 10, 0, 0, white, true)
  122.     dxDrawText(_FORV_10_, sx - sidebar.pos, _UPVALUE3_ + (_FORV_9_ - 1) * _UPVALUE4_ + _UPVALUE7_ + _UPVALUE8_ + 5, sx - sidebar.pos + sidebar.width, _UPVALUE3_ + _FORV_9_ * _UPVALUE4_, white, _UPVALUE2_, "default-bold", "center", "top", false, false, true)
  123.   end
  124. end
  125. function setServerTimestampDifference(_ARG_0_)
  126.   serverTimestampDifference = _ARG_0_
  127. end
  128. function getServerTimestampDifference()
  129.   return serverTimestampDifference
  130. end
  131. addEvent("receiveServerTimestampDifference", true)
  132. addEventHandler("receiveServerTimestampDifference", localPlayer, setServerTimestampDifference)
  133. triggerServerEvent("getServerTimestampDifference", localPlayer, getRealTime().timestamp)
  134. function openSidebar()
  135.   if not getElementData(localPlayer, "isLobbyOpened") then
  136.     unbindKey(theBoundSidebarKey, "down")
  137.     showCursor(true)
  138.     addEventHandler("onClientRender", root, drawSidebar, true, "low-9")
  139.     sidebar.pos = 0
  140.     sidebar.state = 1
  141.     addEventHandler("onClientClick", root, sidebarClick)
  142.   end
  143. end
  144. function closeSidebar()
  145.   for _FORV_3_, _FORV_4_ in ipairs(getElementsByType("dxWindow")) do
  146.     if getElementData(_FORV_4_, "text") ~= title then
  147.       closeFFSWindow(_FORV_4_)
  148.     end
  149.   end
  150.   sidebar.state = 0
  151.   showCursor(false)
  152.   removeEventHandler("onClientClick", root, sidebarClick)
  153. end
  154. function main()
  155.   bindKey(theBoundSidebarKey, "down", openSidebar)
  156. end
  157. function checkStates()
  158.   if sidebar.state == 1 then
  159.     sidebar.pos = math.min(sidebar.pos + 10, sidebar.width)
  160.     if sidebar.pos == sidebar.width then
  161.       sidebar.state = 2
  162.       bindKey(theBoundSidebarKey, "down", closeSidebar)
  163.     end
  164.   elseif sidebar.state == 0 then
  165.     sidebar.pos = math.max(sidebar.pos - 10, 0)
  166.     if sidebar.pos == 0 then
  167.       bindKey(theBoundSidebarKey, "down", openSidebar)
  168.       removeEventHandler("onClientRender", root, drawSidebar)
  169.     end
  170.   end
  171. end
  172. function cursorChecks()
  173.   if isCursorShowing() then
  174.     for _FORV_5_ = 1, 4 do
  175.       sidebar.iconSize[_FORV_5_] = math.max(sidebar.iconSize[_FORV_5_] - 0.2, 0)
  176.     end
  177.     if getCursorPosition() * sx >= sx - 0.95 * sidebar.pos then
  178.       if getCursorPosition() * sy <= sidebar.pos then
  179.         sidebar.iconSize[1] = math.min(sidebar.iconSize[1] + 0.3, 1)
  180.       elseif getCursorPosition() * sy <= 2 * sidebar.pos then
  181.         sidebar.iconSize[2] = math.min(sidebar.iconSize[2] + 0.3, 1)
  182.       elseif getCursorPosition() * sy <= 3 * sidebar.pos then
  183.         sidebar.iconSize[3] = math.min(sidebar.iconSize[3] + 0.3, 1)
  184.       elseif getCursorPosition() * sy >= sy - sidebar.pos then
  185.         sidebar.iconSize[4] = math.min(sidebar.iconSize[4] + 0.3, 1)
  186.       end
  187.     end
  188.   end
  189. end
  190. function apps()
  191.   sidebar.appmenu = 0
  192.   drawAppMenu = true
  193. end
  194. function sidebarClick(_ARG_0_, _ARG_1_)
  195.   if _ARG_0_ ~= "left" or _ARG_1_ ~= "up" then
  196.     return
  197.   end
  198.   if getCursorPosition() and getCursorPosition() * sx and (getCursorPosition() and getCursorPosition() * sx) >= sx - sidebar.pos then
  199.     for _FORV_8_, _FORV_9_ in ipairs(sidebar.app) do
  200.       if getCursorPosition() * sy >= _UPVALUE0_ + (_FORV_8_ - 1) * _UPVALUE1_ and getCursorPosition() * sy < _UPVALUE0_ + _FORV_8_ * _UPVALUE1_ then
  201.         return executeCommandHandler(sidebar.commands[_FORV_8_])
  202.       end
  203.     end
  204.   end
  205. end
  206. addEvent("receiveData", true)
  207. addEventHandler("receiveData", getLocalPlayer(), function(_ARG_0_, _ARG_1_)
  208.   if _ARG_0_ == "News" then
  209.     News_cache = _ARG_1_
  210.   elseif _ARG_0_ == "Maps" then
  211.     cacheMaps(_ARG_1_)
  212.   elseif _ARG_0_ == "mInfo" then
  213.     getMapInfo(_ARG_1_)
  214.   elseif _ARG_0_ == "Music" then
  215.     receiveMusicList(_ARG_1_)
  216.   elseif _ARG_0_ == "Toptimes" then
  217.     getTopHunterReachers(_ARG_1_)
  218.   elseif _ARG_0_ == "Stats" then
  219.     leaderBoards = _ARG_1_
  220.   elseif _ARG_0_ == "likedMaps" then
  221.     likedMaps = _ARG_1_
  222.   elseif _ARG_0_ == "Cathegories" then
  223.     mapCat = _ARG_1_
  224.   elseif _ARG_0_ == "gagsList" then
  225.     images = _ARG_1_
  226.   elseif _ARG_0_ == "gag" then
  227.     if fileExists("cache/" .. _ARG_1_[1]) then
  228.       return
  229.     end
  230.     if fileCreate("cache/" .. _ARG_1_[1]) then
  231.       for _FORV_6_, _FORV_7_ in ipairs(_ARG_1_[2]) do
  232.         fileWrite(fileCreate("cache/" .. _ARG_1_[1]), _FORV_7_)
  233.       end
  234.       fileClose((fileCreate("cache/" .. _ARG_1_[1])))
  235.     end
  236.   elseif _ARG_0_ == "Tuning" then
  237.     Tuning = _ARG_1_
  238.     onTuningDataReceived()
  239.   end
  240. end)
  241. function drawSidebarNote()
  242.   timeDif = getTickCount() - _UPVALUE0_
  243.   if timeDif <= 500 then
  244.   elseif timeDif >= 500 and timeDif <= 5000 then
  245.   elseif timeDif <= 5500 then
  246.   else
  247.     removeEventHandler("onClientRender", root, drawSidebarNote)
  248.     return
  249.   end
  250.   dxDrawRectangle(sx / 2 - 200, sy - (5500 - timeDif) / 500 * 100, 400, 100, _UPVALUE1_[3])
  251.   dxDrawLine(sx / 2 - 200, sy - (5500 - timeDif) / 500 * 100, sx / 2 + 200, sy - (5500 - timeDif) / 500 * 100, tocolor(255, 255, 255, 100))
  252.   dxDrawLine(sx / 2 - 200, sy - (5500 - timeDif) / 500 * 100, sx / 2 - 200, sy, tocolor(255, 255, 255, 100))
  253.   dxDrawLine(sx / 2 + 200, sy - (5500 - timeDif) / 500 * 100, sx / 2 + 200, sy, tocolor(255, 255, 255, 100))
  254.   dxDrawText(_UPVALUE1_[1], sx / 2 - 195, sy - (5500 - timeDif) / 500 * 100 + 20, sx / 2 + 195, sy, tocolor(255, 255, 255, 255), 1.6, "default-bold", "center", "top", true, false)
  255.   dxDrawText(_UPVALUE1_[2], sx / 2 - 195, sy - (5500 - timeDif) / 500 * 100 + 60, sx / 2 + 195, sy, tocolor(255, 255, 255, 255), 1.6, "default", "center", "top", true, false)
  256. end
  257. addEvent("notifyPlayer", true)
  258. addEventHandler("notifyPlayer", localPlayer, function(...)
  259.   exports.ffs:addNotification(...)
  260. end)
  261. addEvent("alertPlayer", true)
  262. addEventHandler("alertPlayer", localPlayer, function(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
  263.   alert(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
  264. end)
  265. function postData(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
  266.   triggerServerEvent("postData", localPlayer, _ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
  267. end
  268. addEvent("onClientArenaLeave", true)
  269. addEvent("onClientArenaJoin", true)
  270. function onClientArenaJoin(_ARG_0_)
  271.   if _ARG_0_ ~= true and not Settings.serverAlreadyVisitted then
  272.     setSidebarSetting("serverAlreadyVisitted", "yes")
  273.     openHelp(true)
  274.   end
  275.   if not sidebarAlreadyStarted then
  276.     sidebarAlreadyStarted = true
  277.     main()
  278.   end
  279. end
  280. addEventHandler("onClientResourceStart", resourceRoot, function()
  281.   onClientArenaJoin(true)
  282. end)
  283. addEventHandler("onClientArenaJoin", root, onClientArenaJoin)
  284. bindKey("F1", "down", function()
  285.   closeSidebar()
  286. end)
  287. addEventHandler("onClientArenaLeave", root, closeSidebar)
Advertisement
Add Comment
Please, Sign In to add comment