Altamurenza

Bully SE: Console Commands

Jan 26th, 2018
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. -- Basic of Console Commands
  2.  
  3. -- Main function:
  4. function main()
  5.     while not SystemIsReady() or AreaIsLoading() do
  6.         Wait(0)
  7.     end
  8.    
  9.     CreateThread("SYSTEM_Console")
  10. end
  11.  
  12. -- Thread:
  13. SYSTEM_Console = function()
  14.     local gData = {
  15.         Mode = 1,Select = 1
  16.        
  17.         Alphabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," "},
  18.         Command = {
  19.             -- {command,function,{function arguments}}:
  20.             {"Welcome",ForceStartMission,{"1_01"}},
  21.             {"Final",ForceStartMission,{"6_B"}},
  22.             {"PunishmentPoints",DisablePunishmentSystem,{false}}, -- Toggle
  23.         }
  24.     },
  25.     while true do
  26.         if IsButtonBeingPressed(4,0) then
  27.             PlayerSetControl(0)
  28.            
  29.             local PrintOut,ReBuild,Typing = "",false,{}
  30.             repeat
  31.                
  32.                 if IsButtonBeingPressed(1,0) then
  33.                     gData.Select = gData.Select + 1
  34.                     if gData.Select > table.getn(gData.Alphabet) then gData.Select = 1 end
  35.                 elseif IsButtonBeingPressed(0,0) then
  36.                     gData.Select = gData.Select - 1
  37.                     if gData.Select < 1 then gData.Select = table.getn(gData.Alphabet) end
  38.                 end
  39.                
  40.                 if IsButtonBeingPressed(7,0) then
  41.                     table.insert(Typing,gData.Alphabet[gData.Select])
  42.                     ReBuild = true
  43.                 elseif IsButtonBeingPressed(2,0) then
  44.                     if table.getn(Typing) > 0 then
  45.                         table.remove(Typing,table.getn(Typing))
  46.                         if table.getn(Typing) > 0 then
  47.                             ReBuild = true
  48.                         else
  49.                             PrintOut = ""
  50.                         end
  51.                     end
  52.                 end
  53.                
  54.                 if ReBuild then
  55.                     local Current = 0
  56.                     while true do
  57.                         Current = Current + 1
  58.                        
  59.                         if Current > table.getn(Typing) then
  60.                             break
  61.                         else
  62.                             if Current > 1 then
  63.                                 PrintOut = PrintOut..""..Typing[Current]
  64.                             else
  65.                                 PrintOut = Typing[Current]
  66.                             end
  67.                         end
  68.                     end
  69.                    
  70.                     ReBuilds = false
  71.                 end
  72.                
  73.                 TextPrintString("> "..PrintOut.."\n\n| "..gData.Alphabet[gData.Select].." |",0,1)
  74.                
  75.                 if IsButtonBeingPressed(14,0) then
  76.                     -- Default command, launch script:
  77.                     if string.find(PrintOut,".lua",-4) then
  78.                         LaunchScript(PrintOut)
  79.                     end
  80.                     -- Default command, starting mission:
  81.                     for Mission_ID = 0,261 do
  82.                         if tonumber(PrintOut) == Mission_ID then
  83.                             ForceStartMissionIndex(tonumber(PrintOut))
  84.                         end
  85.                     end
  86.                     -- Custom command:
  87.                     for i,code in ipairs(gData.Command) do
  88.                         if PrintOut == code[1] then
  89.                             -- If toggle:
  90.                             for Arg = 1,table.getn(code[3]) do
  91.                                 if type(code[3][Arg]) == "boolean" then
  92.                                     code[3][Arg] = not code[3][Arg]
  93.                                 end
  94.                             end
  95.                             -- Run command:
  96.                             code[2](unpack(code[3]))
  97.                         end
  98.                     end
  99.                 end
  100.                
  101.                 Wait(0)
  102.             until IsButtonBeingPressed(4,0)
  103.             PlayerSetControl(1)
  104.         end
  105.        
  106.         Wait(0)
  107.     end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment