Advertisement
Altamurenza

Bully SE/AE: Chalkboard - UI Framework

Jan 19th, 2022 (edited)
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.04 KB | None | 0 0
  1. -- CHALKBOARD - UI FRAMEWORK (V1.1)
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4. --[[
  5.     CURRENT FEATURES
  6.    
  7.     [X] MOD MENU
  8.     [X] QUESTIONARE
  9.     [X] PRINT
  10.    
  11.     ---> AUTHOR NOTES <---
  12.    
  13.     any suggestion, bug report, or criticism you can DM me
  14.     on discord or drop your comment in any video of my
  15.     youtube channel.
  16.    
  17.     suggested version to run with:
  18.     - scholarship edition (pc)
  19.     - anniversary edition (android)
  20.    
  21.     preview:
  22.     - scholarship edition   : https://imgur.com/YWopSWP
  23.     - anniversary edition   : https://imgur.com/9rngVWu
  24.    
  25.     pastebin    : pastebin.com/u/Altamurenza
  26.     youtube     : youtube.com/c/Altamurenza
  27. ]]
  28.  
  29.  
  30. ImportScript("SInitGl_data.lua")
  31.  
  32.  
  33.  
  34.  
  35. -------------------------------------------------------------------------------
  36. -- ONE-TOUCH SETTINGS
  37. -------------------------------------------------------------------------------
  38.  
  39. -- shared variables
  40.  
  41. shared.CB_Active = false
  42. shared.CB_Timer = GetTimer()
  43. shared.CB_Database = {}
  44.  
  45. shared.currentMG = nil
  46.  
  47. -- global functions
  48.  
  49. _G.CB_TypeCheck = function(F, T)
  50.     local S = {
  51.         [1] = "st",
  52.         [2] = "nd",
  53.         [3] = "rd",
  54.     }
  55.    
  56.     if type(T) == "table" then
  57.         for I, V in ipairs(T) do
  58.             if type(V[1]) ~= V[2] then
  59.                 return "- "..(type(F) == "string" and F or "unknown").." -\n\nexpected "..I..""..(S[I] or "th").." argument of type "..V[2]..", got "..type(V[1])
  60.             end
  61.         end
  62.     else
  63.         return "- CB_TypeCheck -\n\nexpected 2"..S[2].." argument of type table, got "..type(T)
  64.     end
  65.    
  66.     return nil
  67. end
  68.  
  69. _G.CB_IsRunning = function()
  70.     return shared.CB_Active
  71. end
  72.  
  73. _G.CB_IsSafe = function()
  74.     local SAFE = true
  75.     for INT, CODE in ipairs({"MATH", "ART", "CHEM", "MUSIC", "LAWNMOWING", "KEEPUPS", "SHOOT", "ARCADE", "LOCK", "SOCCERP", "BALLTOSS", "STRIKER", "DUNKTANK"}) do
  76.         if MG_IsRunning(CODE) then
  77.             SAFE = false; break
  78.         end
  79.     end
  80.    
  81.     return SAFE
  82. end
  83.  
  84. _G.CB_MustExit = function()
  85.     if PlayerGetHealth() < 1 or shared.CB_ForceStop or not MinigameIsActive() then
  86.         return true
  87.     end
  88.    
  89.     if PedIsValid(PedGetGrappleTargetPed(gPlayer)) then
  90.         for INT, NODE in ipairs({"Punishment_Hold", "Tonfa_Impale", "EarGrab", "Adult_Takedown"}) do
  91.             if PedMePlaying(PedGetGrappleTargetPed(gPlayer), NODE) then
  92.                 return true
  93.             end
  94.         end
  95.     end
  96.    
  97.     return false
  98. end
  99.  
  100. _G.CB_ForceStop = function()
  101.     if CB_IsRunning() then
  102.         shared.CB_ForceStop = true
  103.     end
  104. end
  105.  
  106. _G.CB_Register = function(BUTTON, BUTTON_OPTION, BUTTON_OPTION_VAL, TABLE, OPTION)
  107.     local ERROR_MSG = CB_TypeCheck("CB_Register", {
  108.         {BUTTON, "number"}, {BUTTON_OPTION, "number"}, {BUTTON_OPTION_VAL, "number"}, {TABLE, "table"}, {OPTION, "number"}
  109.     })
  110.    
  111.     if type(ERROR_MSG) ~= "string" then
  112.         if type(shared.CB_Database[BUTTON]) ~= "table" then
  113.             shared.CB_Database[BUTTON] = {}
  114.         end
  115.        
  116.         BUTTON_OPTION_VAL = (BUTTON_OPTION > 0 and BUTTON_OPTION_VAL < 1) and 1 or BUTTON_OPTION_VAL
  117.         local METHOD = BUTTON_OPTION > 2 and 0 or BUTTON_OPTION
  118.        
  119.         if type(shared.CB_Database[BUTTON][METHOD]) == "table" then
  120.             if BUTTON_OPTION > 0 and BUTTON_OPTION_VAL > 0 and shared.CB_Database[BUTTON][METHOD].Time ~= nil then
  121.                 shared.CB_Database[BUTTON][METHOD].Time = (BUTTON_OPTION == 1 and BUTTON_OPTION_VAL > 2) and 2 or shared.CB_Database[BUTTON][METHOD].Time
  122.             end
  123.         else
  124.             shared.CB_Database[BUTTON][METHOD] = {}
  125.            
  126.             if BUTTON_OPTION > 0 and BUTTON_OPTION_VAL > 0 then
  127.                 shared.CB_Database[BUTTON][METHOD].Time = (BUTTON_OPTION == 1 and BUTTON_OPTION_VAL > 2) and 2 or BUTTON_OPTION_VAL
  128.             end
  129.         end
  130.        
  131.         if type(shared.CB_Database[BUTTON][METHOD].Table) ~= "table" then
  132.             shared.CB_Database[BUTTON][METHOD].Table = {}
  133.         end
  134.        
  135.         for I = 1, table.getn(TABLE) do
  136.             table.insert(shared.CB_Database[BUTTON][METHOD].Table, TABLE[I])
  137.         end
  138.        
  139.         if type(shared.CB_Database[BUTTON][METHOD].Option) ~= "number" then
  140.             shared.CB_Database[BUTTON][METHOD].Option = OPTION
  141.         end
  142.     else
  143.         TextPrintString(ERROR_MSG, 5, 2)
  144.     end
  145. end
  146.  
  147. _G.CB_Start = function(T, S, W, R)
  148.     MinigameCreate("MATH", false)
  149.     while not MinigameIsReady() do
  150.         Wait(0)
  151.     end
  152.    
  153.     PlayerWeaponHudLock(true)
  154.    
  155.     HUDSaveVisibility()
  156.     HUDClearAllElements()
  157.    
  158.     MinigameStart()
  159.    
  160.     ClassMathSetNumQuestions(99999999)
  161.     if type(S) == "boolean" then
  162.         if S then
  163.             _G.ClassMathSetEquation("'"..T.."'", 4, 4, W, "", "", R)
  164.         else
  165.             _G.ClassMathSetEquation(T, 4, 3, "", W, R, "")
  166.         end
  167.     elseif type(S) == "table" then
  168.         _G.ClassMathSetEquation(T, unpack(S))
  169.     end
  170.    
  171.     ClassMathSetTimer(99999999)
  172.     MinigameEnableHUD(true)
  173. end
  174.  
  175. _G.CB_End = function(T)
  176.     ClassMathFinished()
  177.    
  178.     while MinigameIsActive() do
  179.         Wait(0)
  180.     end
  181.    
  182.     HUDRestoreVisibility()
  183.     PlayerWeaponHudLock(false)
  184.     MinigameEnableHUD(false)
  185.    
  186.     if shared.currentMG == nil then
  187.         MinigameDestroy()
  188.        
  189.         for INT, CODE in ipairs({"2_R11_Chad", "2_R11_Bryce", "2_R11_Justin", "2_R11_Parker", "2_R11_Random"}) do
  190.             if MissionActiveSpecific(CODE) then
  191.                 HUDSetFightStyle()
  192.                
  193.                 break
  194.             end
  195.         end
  196.     end
  197.    
  198.     if shared.CB_ForceStop then
  199.         shared.CB_ForceStop = nil
  200.     end
  201.    
  202.     if T then
  203.         _G.TERMINATE_NAV = true
  204.     end
  205.    
  206.     shared.CB_Active = false
  207. end
  208.  
  209. _G.CB_Run = function(B, M, T)
  210.     if CB_IsRunning() == false and CB_IsSafe() then
  211.         -- create MG
  212.         CB_Start(shared.CB_Database[B][M].Table[shared.CB_Database[B][M].Option].Name, true, "PREV", "NEXT")
  213.        
  214.         -- new thread
  215.         _G.CB_Nav = function()
  216.             local BUTTON, METHOD, TIMER, EXIT = B, M, T, false
  217.            
  218.             while true do
  219.                 if CB_IsRunning() then
  220.                     -- next
  221.                     if ClassMathValidAnswer() then
  222.                         shared.CB_Database[BUTTON][METHOD].Option = shared.CB_Database[BUTTON][METHOD].Option + 1 > table.getn(shared.CB_Database[BUTTON][METHOD].Table) and 1 or shared.CB_Database[BUTTON][METHOD].Option + 1
  223.                        
  224.                         while shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Name == "" do
  225.                             shared.CB_Database[BUTTON][METHOD].Option = shared.CB_Database[BUTTON][METHOD].Option + 1 > table.getn(shared.CB_Database[BUTTON][METHOD].Table) and 1 or shared.CB_Database[BUTTON][METHOD].Option + 1
  226.                         end
  227.                        
  228.                         _G.ClassMathSetEquation("'"..shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Name.."'", 4, 4, "PREV", "", "", "NEXT")
  229.                         shared.CB_Timer = GetTimer() + (TIMER * 1000)
  230.                     end
  231.                    
  232.                     -- prev
  233.                     if ClassMathInvalidAnswer() then
  234.                         shared.CB_Database[BUTTON][METHOD].Option = shared.CB_Database[BUTTON][METHOD].Option - 1 < 1 and table.getn(shared.CB_Database[BUTTON][METHOD].Table) or shared.CB_Database[BUTTON][METHOD].Option - 1
  235.                        
  236.                         while shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Name == "" do
  237.                             shared.CB_Database[BUTTON][METHOD].Option = shared.CB_Database[BUTTON][METHOD].Option - 1 < 1 and table.getn(shared.CB_Database[BUTTON][METHOD].Table) or shared.CB_Database[BUTTON][METHOD].Option - 1
  238.                         end
  239.                        
  240.                         _G.ClassMathSetEquation("'"..shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Name.."'", 4, 4, "PREV", "", "", "NEXT")
  241.                         shared.CB_Timer = GetTimer() + (TIMER * 1000)
  242.                     end
  243.                    
  244.                     -- confirm
  245.                     if shared.CB_Timer < GetTimer() and not EXIT then
  246.                        
  247.                         if shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Func then
  248.                             local CONFIRM = CB_Ask("# CONFIRM SELECTION #", "NO", "YES")
  249.                            
  250.                             if type(CONFIRM) == "number" and CONFIRM == 1 and type(shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Func) == "function" then
  251.                                 shared.CB_Database[BUTTON][METHOD].Table[shared.CB_Database[BUTTON][METHOD].Option].Func(shared.CB_Database[BUTTON][METHOD].Table, shared.CB_Database[BUTTON][METHOD].Option)
  252.                                
  253.                                 EXIT = true
  254.                             else
  255.                                 if type(CONFIRM) == "number" then
  256.                                     local RETURN = CB_Ask("# EXIT OR RETURN #", "EXIT", "RETURN")
  257.                                    
  258.                                     if type(RETURN) == "number" and RETURN == 1 then
  259.                                         shared.CB_Timer = GetTimer() + (TIMER * 1000)
  260.                                     else
  261.                                         EXIT = true
  262.                                     end
  263.                                 else
  264.                                     EXIT = true
  265.                                 end
  266.                             end
  267.                         else
  268.                             EXIT = true
  269.                         end
  270.                     end
  271.                    
  272.                     -- exit
  273.                     if CB_MustExit() or EXIT then
  274.                         CB_End(true)
  275.                     end
  276.                 else
  277.                     break
  278.                 end
  279.                
  280.                 Wait(0)
  281.             end
  282.         end
  283.        
  284.         -- set shared var
  285.         shared.CB_Timer = GetTimer() + (T * 1000)
  286.         shared.CB_Active = true
  287.        
  288.         -- set selection
  289.         shared.CB_Thread = CreateThread("CB_Nav")
  290.     else
  291.         SoundPlay2D("WrongBtn")
  292.     end
  293. end
  294.  
  295. _G.CB_Ask = function(T, W, R)
  296.     -- answer
  297.     local FINAL_ANSWER = nil
  298.    
  299.     -- start up
  300.     local LAST_QUESTION = nil
  301.    
  302.     if not CB_IsRunning() then
  303.         CB_Start(T, false, W, R)
  304.        
  305.         shared.CB_Active = true
  306.     else
  307.         LAST_QUESTION = ClassMathGetEquation()
  308.        
  309.         _G.ClassMathSetEquation(T, 4, 3, "", W, R, "")
  310.     end
  311.    
  312.     -- create loop
  313.     while true do
  314.         Wait(0)
  315.        
  316.         if CB_IsRunning() then
  317.             if ClassMathValidAnswer() then
  318.                 FINAL_ANSWER = 1; break
  319.             end
  320.            
  321.             if ClassMathInvalidAnswer() then
  322.                 FINAL_ANSWER = 0; break
  323.             end
  324.            
  325.             if CB_MustExit() then
  326.                 break
  327.             end
  328.         else
  329.             break
  330.         end
  331.     end
  332.    
  333.     -- exit / go back
  334.     if LAST_QUESTION ~= nil and table.getn(LAST_QUESTION) > 0 then
  335.         _G.ClassMathSetEquation(unpack(LAST_QUESTION))
  336.     else
  337.         CB_End()
  338.     end
  339.    
  340.     -- return
  341.     return FINAL_ANSWER
  342. end
  343.  
  344. _G.CB_Quiz = function(T, S, R)
  345.     -- checking arguments
  346.     local ERROR = CB_TypeCheck("CB_Quiz", {{T, "table"}, {S, "number"}, {R, "boolean"}})
  347.    
  348.     if type(ERROR) ~= "string" then
  349.         if CB_IsRunning() == false and CB_IsSafe() then
  350.             -- randoming quiz
  351.             if R == true then
  352.                 local TT = {}
  353.                 for I = 1, table.getn(T) do
  354.                     table.insert(TT, T[I])
  355.                 end
  356.                
  357.                 local NT = {}
  358.                 repeat
  359.                     local I = math.random(1, table.getn(TT))
  360.                    
  361.                     if TT[I] then table.insert(NT, TT[I]); table.remove(TT, I) end
  362.                    
  363.                     Wait(0)
  364.                 until table.getn(TT) <= 0
  365.                
  366.                 T = NT
  367.             end
  368.            
  369.             -- setup
  370.             local O, A = {}, false
  371.             CB_Start(T[S].Question, {table.getn(T[S].Choice), T[S].Answer, unpack(T[S].Choice)})
  372.            
  373.             -- loop
  374.             while true do
  375.                 Wait(0)
  376.                
  377.                 if not MinigameIsActive() then break end
  378.                
  379.                 if ClassMathValidAnswer() then
  380.                     O[S], A = true, true
  381.                 end
  382.                 if ClassMathInvalidAnswer() then
  383.                     O[S], A = false, true
  384.                 end
  385.                    
  386.                 if A then
  387.                     S = S + 1
  388.                     if S > table.getn(T) then
  389.                         break
  390.                     end
  391.                    
  392.                     _G.ClassMathSetEquation(T[S].Question, table.getn(T[S].Choice), T[S].Answer, unpack(T[S].Choice))
  393.                     A = false
  394.                 end
  395.             end
  396.            
  397.             -- cleanup
  398.             CB_End()
  399.            
  400.             -- report
  401.             local C = 0
  402.             for I = 1, table.getn(O) do
  403.                 if O[I] then
  404.                     C = C + 1
  405.                 end
  406.             end
  407.            
  408.             return tonumber(string.format("%.1f", (C / table.getn(T)) * 100))
  409.         else
  410.             SoundPlay2D("WrongBtn")
  411.         end
  412.     else
  413.         TextPrintString(ERROR, 5, 2)
  414.     end
  415.    
  416.     return nil
  417. end
  418.  
  419. _G.CB_Print = function(T, S)
  420.     -- checking arguments
  421.     local ERROR = CB_TypeCheck("CB_Print", {{T, "string"}, {S, "number"}})
  422.    
  423.     if type(ERROR) ~= "string" then
  424.         if CB_IsRunning() == false and CB_IsSafe() and S > 0.0 then
  425.             -- start
  426.             local TIMER, COUNT = GetTimer(), S
  427.             CB_Start(T, {3, 2,  "", "< "..string.format("%.1f", COUNT).."s >", ""})
  428.            
  429.             -- loop
  430.             while true do
  431.                 Wait(0)
  432.                
  433.                 if TIMER + 100 < GetTimer() then
  434.                     COUNT = COUNT - 0.1
  435.                     _G.ClassMathSetEquation(T, 3, 2, "", "< "..string.format("%.1f", COUNT).."s >", "")
  436.                    
  437.                     TIMER = GetTimer()
  438.                 end
  439.                
  440.                 if COUNT <= 0.0 or ClassMathValidAnswer() or not MinigameIsActive() then
  441.                     break
  442.                 end
  443.             end
  444.            
  445.             -- end
  446.             CB_End()
  447.         else
  448.             SoundPlay2D("WrongBtn")
  449.         end
  450.     else
  451.         TextPrintString(ERROR, 5, 2)
  452.     end
  453. end
  454.  
  455. _G.CBP = _G.ClothingBuildPlayer
  456. _G.ClothingBuildPlayer = function()
  457.     -- main thread
  458.     if not shared.CB_Coroutine then
  459.         _G.CB_Coroutine = function()
  460.             local YIELD = false
  461.            
  462.             local Wait = function(MS)
  463.                 if YIELD == true then coroutine.yield(MS)
  464.                 else
  465.                     _G.Wait(MS)
  466.                 end
  467.             end
  468.            
  469.             while true do
  470.                 local THREAD, STATUS, RESULT = coroutine.create(
  471.                     function()
  472.                         local BUTTON = {}
  473.                         for ID = 0, 15 do
  474.                             if ID == 9 then
  475.                                 if type(_G.ClassMusicSetPlayers) == "function" then
  476.                                     BUTTON[9] = {GetTimer(), GetTimer(), GetTimer()}
  477.                                 end
  478.                             else
  479.                                 BUTTON[ID] = {GetTimer(), GetTimer(), GetTimer()}
  480.                             end
  481.                         end
  482.                        
  483.                         BUTTON[24] = {GetTimer(), GetTimer(), GetTimer()}
  484.                        
  485.                         while true do
  486.                             Wait(0)
  487.                            
  488.                             if not CB_IsRunning() then
  489.                                 for B, T in pairs(BUTTON) do
  490.                                     if IsButtonBeingPressed(B, 0) and type(shared.CB_Database[B]) == "table" then
  491.                                         if type(shared.CB_Database[B][0]) == "table" then
  492.                                             CB_Run(B, 0, 3)
  493.                                         else
  494.                                             if T[1] and GetTimer() < T[1] + 500 then
  495.                                                 if type(shared.CB_Database[B][1]) == "table" and shared.CB_Database[B][1].Time == 1 then
  496.                                                     CB_Run(B, 1, 3)
  497.                                                 end
  498.                                                
  499.                                                 if T[2] and GetTimer() < T[2] + 500 then
  500.                                                     if type(shared.CB_Database[B][1]) == "table" and shared.CB_Database[B][1].Time == 2 then
  501.                                                         CB_Run(B, 1, 3)
  502.                                                     end
  503.                                                 else
  504.                                                     T[2] = GetTimer()
  505.                                                 end
  506.                                             else
  507.                                                 T[1] = GetTimer()
  508.                                             end
  509.                                         end
  510.                                     end
  511.                                    
  512.                                     if IsButtonPressed(B, 0) and type(shared.CB_Database[B]) == "table" then
  513.                                         if type(shared.CB_Database[B][2]) == "table" and shared.CB_Database[B][2].Time then
  514.                                             if T[3] + (shared.CB_Database[B][2].Time * 1000) <= GetTimer() then
  515.                                                 CB_Run(B, 2, 3); T[3] = GetTimer()
  516.                                             end
  517.                                         end
  518.                                     else
  519.                                         T[3] = GetTimer()
  520.                                     end
  521.                                 end
  522.                                
  523.                                 if _G.TERMINATE_NAV and shared.CB_Thread then
  524.                                     TerminateThread(shared.CB_Thread); shared.CB_Thread = nil
  525.                                    
  526.                                     _G.TERMINATE_NAV = false
  527.                                 end
  528.                             end
  529.                         end
  530.                     end
  531.                 )
  532.                
  533.                 while coroutine.status(THREAD) == "suspended" do
  534.                     YIELD = true
  535.                     if YIELD == true then
  536.                         STATUS, RESULT = coroutine.resume(THREAD)
  537.                     end
  538.                     YIELD = false
  539.                    
  540.                     _G.Wait(RESULT)
  541.                 end
  542.             end
  543.         end
  544.        
  545.         shared.CB_Coroutine = CreateThread("CB_Coroutine")
  546.     end
  547.    
  548.     -- do function!
  549.     _G.CBP()
  550. end
  551.  
  552.  
  553. -------------------------------------------------------------------------------
  554. -- FLEXIBLE SETTINGS
  555. -------------------------------------------------------------------------------
  556.  
  557. shared.CBUI_Database = {}
  558.  
  559. _G.CBUI_Show = function(TIME)
  560.     if not CBUI_IsActive() then
  561.         MinigameCreate("MATH", false)
  562.         repeat
  563.             Wait(0)
  564.         until MinigameIsReady()
  565.        
  566.         shared.CBUI_Database.STR_Time = TIME or 4
  567.        
  568.         HUDSaveVisibility()
  569.         HUDClearAllElements()
  570.        
  571.         MinigameStart()
  572.        
  573.         ClassMathSetNumQuestions(99999999)
  574.         CBUI_Update()
  575.        
  576.         ClassMathSetTimer(99999999)
  577.         MinigameEnableHUD(true)
  578.        
  579.         shared.CBUI_Active = true
  580.     else
  581.         SoundPlay2D("WrongBtn")
  582.     end
  583. end
  584.  
  585. _G.CBUI_1 = function()
  586.     if CBUI_IsActive() then
  587.         if CBUI_ExitViaSpace() then
  588.             CBUI_Close()
  589.            
  590.             return true
  591.         end
  592.        
  593.         return ClassMathValidAnswer()
  594.     end
  595.    
  596.     return false
  597. end
  598.  
  599. _G.CBUI_Select = function()
  600.     if CBUI_IsActive() then
  601.         return shared.CBUI_Database.Time < GetTimer()
  602.     end
  603.    
  604.     return false
  605. end
  606.  
  607. _G.CBUI_0 = function()
  608.     if CBUI_IsActive() then
  609.         return ClassMathInvalidAnswer()
  610.     end
  611.    
  612.     return false
  613. end
  614.  
  615. _G.CBUI_Close = function()
  616.     if CBUI_IsActive() then
  617.         ClassMathFinished()
  618.         while MinigameIsActive() do
  619.             Wait(0)
  620.         end
  621.        
  622.         HUDRestoreVisibility()
  623.         MinigameEnableHUD(false)
  624.         MinigameDestroy()
  625.        
  626.         shared.CBUI_Database.Text = nil
  627.         shared.CBUI_Database.Option = nil
  628.         shared.CBUI_Database.OptionTrue = nil
  629.         shared.CBUI_Database.Time = nil
  630.        
  631.         shared.CBUI_Active = false
  632.     end
  633. end
  634.  
  635. _G.CBUI_Update = function()
  636.     if shared.CBUI_Database.Text or shared.CBUI_Database.Option then
  637.         local TEXT = shared.CBUI_Database.Text or ""
  638.         local OPTION = type(shared.CBUI_Database.Option) == "table" and {
  639.             table.getn(shared.CBUI_Database.Option), shared.CBUI_Database.OptionTrue, unpack(shared.CBUI_Database.Option)
  640.         } or {3, 2, "", "", ""}
  641.        
  642.         ClassMathSetEquation(TEXT, unpack(OPTION))
  643.         shared.CBUI_Database.Time = GetTimer() + (shared.CBUI_Database.STR_Time * 1000)
  644.     else
  645.         SoundPlay2D("WrongBtn")
  646.     end
  647. end
  648.  
  649. _G.CBUI_SetText = function(TEXT)
  650.     shared.CBUI_Database.Text = TEXT
  651.    
  652.     if CBUI_IsActive() then
  653.         CBUI_Update()
  654.     end
  655. end
  656.  
  657. _G.CBUI_GetText = function()
  658.     return shared.CBUI_Database.Text or ""
  659. end
  660.  
  661. _G.CBUI_SetOption = function(TABLE, TRUE_ID)
  662.     if table.getn(TABLE) >= 3 and TRUE_ID <= table.getn(TABLE) then
  663.         shared.CBUI_Database.Option, shared.CBUI_Database.OptionTrue = TABLE, TRUE_ID
  664.        
  665.         if CBUI_IsActive() then
  666.             CBUI_Update()
  667.         end
  668.     else
  669.         SoundPlay2D("WrongBtn")
  670.     end
  671. end
  672.  
  673. _G.CBUI_GetOption = function()
  674.     return shared.CBUI_Database.Option and shared.CBUI_Database.Option, shared.CBUI_Database.OptionTrue or {"", "", ""}, 2
  675. end
  676.  
  677. _G.CBUI_IsActive = function()
  678.     return shared.CBUI_Active or false
  679. end
  680.  
  681. _G.CBUI_ExitViaSpace = function()
  682.     return not MinigameIsActive()
  683. end
  684.  
  685.  
  686. -------------------------------------------------------------------------------
  687. -- EXECUTABLE & TRIGGER
  688. -------------------------------------------------------------------------------
  689.  
  690. _G.ClassMathGetEquation = function()
  691.     return shared.gClassMathLastEquation or {}
  692. end
  693.  
  694. _G.CMSE = _G.ClassMathSetEquation
  695. _G.ClassMathSetEquation = function(A, B, C, D, E, F, G, H)
  696.     shared.gClassMathLastEquation = {A, B, C, D, E, F, G, H}
  697.    
  698.     -- do function!
  699.     _G.CMSE(A, B, C, D, E, F, G, H)
  700. end
  701.  
  702. _G.MG_IsRunning = function(CODE)
  703.     return (type(shared.currentMG) == "string" and shared.currentMG == CODE) and true or false
  704. end
  705.  
  706. _G.MGC = _G.MinigameCreate
  707. _G.MinigameCreate = function(CODE, TF)
  708.     -- stopping CB
  709.     if CB_IsRunning() then
  710.         CB_ForceStop()
  711.        
  712.         repeat
  713.             Wait(0)
  714.         until shared.CB_Thread == nil
  715.     end
  716.    
  717.     -- new condition
  718.     if CODE ~= "MATH" then
  719.         shared.currentMG = CODE
  720.     end
  721.    
  722.     -- do function!
  723.     _G.MGC(CODE, TF)
  724. end
  725.  
  726. _G.MGD = _G.MinigameDestroy
  727. _G.MinigameDestroy = function()
  728.     -- reset condition
  729.     if shared.currentMG ~= nil then
  730.         shared.currentMG = nil
  731.     end
  732.    
  733.     -- do function!
  734.     _G.MGD()
  735. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement