Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONSOLE COMMANDS 1.0 (SOURCE CODE)
- -- AUTHOR : ALTAMURENZA
- -- SPECIAL THANKS TO DERPY54320 FOR HER STABLE COROUTINE METHOD.
- --[[
- this is what i got so far, not even close to perfect but it's quite good to go, and beside that
- i don't know what to add for upcoming version which means this is the end of my project's idea.
- anyway, here are some information that you probably want to know about this script :
- - F_ConsoleMenu = user interface, 1st argument is string, 2nd argument is function, 3rd argument is boolean, 4th argument is boolean, 5th argument is string
- - F_StringToObj = convert string into object such as pedestrians and vehicles, only string is required here
- - F_StringToVar = commonly used for re-arrange the string from table, may return table or string
- - F_StringToArg = convert string into various arguments but it was changed lately in 0.9 version which 1st argument were table, and the 2nd argument was string
- - F_TableToVar = convert a specified table into readable format, only need table as its argument
- - F_TableToStr = re-arrange table into string / reversion of F_StringToVar and returns string, require a specified table as its argument
- - F_Arithmetical = processing math likely calculator, 1st argument is a specified table and the 2nd one is a specified string
- - F_FuncGetResult = self-explanatory, require a string for the function and the second argument is an optional field filled by table or string
- - F_ImportTable = create new table by importing from an old table, of course table is required
- - F_CreateAnIndependentLoop = basically create new thread, but it will be a container for an external script, function is required as its argument
- - F_ToggleSwitchBoolean = reverse boolean, string or table is required as its argument
- - F_ToString = an improved function of F_TableToStr, string or table is required as its argument
- - F_ToVariable = an improved function of F_TableToVar, string or table is required as its argument
- - F_Wait = wait function can't be used properly in ConsoleCommand, so it's a custom made wait function as alternate
- - SET_VARIABLES = set local and global, require "_G " or "_L " in the 1st argument, a specified table or string by F_StringToVar in the 2nd argument, string in the 3rd argument, 4th argument is optional filled with table of the 3rd argument
- - ER_MESSAGE = print an error result, 1st argument is string, and the 2nd one is number for how long it'll be on the screen
- feel free to tweak as much as possible, as long as it doesn't crash the game state xd.
- ]]
- -------------------------------------------------------------------------------
- -- Setup
- -------------------------------------------------------------------------------
- _G.A,_G.X,_G.Y,_G.Z = AreaGetVisible(),PlayerGetPosXYZ() -- this A X Y Z values is always be the current player position
- _G["PLAYER_POS_UPDATER"] = function()
- while true do _G["A"],_G["X"],_G["Y"],_G["Z"] = AreaGetVisible(),PlayerGetPosXYZ() Wait(0) end
- end
- _G.Ins,_G.Rem,_G.Getn = table.insert,table.remove,table.getn
- gConsole = {
- Mode = 1,Option = 1,Clipboard = {},IsHistoryEnabled = true,ScrollFaster = GetTimer(),Yield = false,ColumnFill = {},
- History = {Commands = {},FuncArg = {},Threads = {}},Pause = {false,{}},Name = "CONSOLE",
- DEFAULT_DIR = "Scripts/", -- this is the folder where you should put your custom script
- 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"," "},
- }
- function main()
- local THREAD = {"PRELOADER","PLAYER_POS_UPDATER"}
- for i = 1,table.getn(THREAD) do
- CreateThread(THREAD[i])
- end
- main = nil -- we don't need this main function because it will be replaced later by another script
- end
- -------------------------------------------------------------------------------
- -- Preloader
- -------------------------------------------------------------------------------
- local FAKE_TextPrintString,CC_Print = function(Arg1,Arg2,Arg3)
- print(Arg1)
- end,TextPrintString
- local FAKE_Button,IBP,IBBP,IBBR = function(b,c)
- print(b)
- end,IsButtonPressed,IsButtonBeingPressed,IsButtonBeingReleased
- function PRELOADER()
- local Wait,EndScript = function(ms)
- if gConsole.Yield == true then coroutine.yield(ms)
- else
- _G["Wait"](ms)
- end
- end,false
- while true do
- local Console,Status,Result = coroutine.create(ConsoleCommand)
- while coroutine.status(Console) == "suspended" do
- gConsole.Yield = true
- if gConsole.Yield == true then
- Status,Result = coroutine.resume(Console)
- end
- gConsole.Yield = false
- _G["Wait"](Result)
- end
- local Timer,Time = GetTimer(),15
- while true do
- _G.IsButtonPressed,_G.IsButtonBeingPressed,_G.IsButtonBeingReleased = FAKE_Button,FAKE_Button,FAKE_Button
- _G.TextPrintString = FAKE_TextPrintString
- CC_Print("( "..Time.."s )\n\nConsole Command has stopped working\nHold ~ddown~ to restart the script",0,2)
- if IBBP(3,0) then
- local FullyLoaded,Load = false,0
- while FullyLoaded == false do
- if Load > 100 then
- Load = 100
- end
- Load = Load + 1
- Wait(math.random(0,70))
- CC_Print("Console Commands "..Load.."%",0.5,2)
- if Load == 100 then FullyLoaded = true end
- end
- _G.IsButtonPressed,_G.IsButtonBeingPressed,_G.IsButtonBeingReleased = IBP,IBBP,IBBR
- _G.TextPrintString = CC_Print
- break
- end
- if Timer + 1000 < GetTimer() then
- Timer,Time = GetTimer(),Time - 1
- if Time == 0 then EndScript = true break end
- end
- _G["Wait"](0)
- end
- PlayerSetControl(1) collectgarbage()
- if EndScript == true then
- _G.IsButtonPressed,_G.IsButtonBeingPressed,_G.IsButtonBeingReleased = IBP,IBBP,IBBR
- _G.TextPrintString = CC_Print
- break
- end
- _G["Wait"](0)
- end
- end
- -------------------------------------------------------------------------------
- -- Main part
- -------------------------------------------------------------------------------
- function ConsoleCommand()
- while not SystemIsReady() or AreaIsLoading() do
- Wait(0)
- end
- -- Take the 'CreateThread' over, it's the only way to break in
- local DEFAULT_CreateThread = CreateThread
- _G["CreateThread"] = function(Name)
- local Thread = DEFAULT_CreateThread(Name)
- table.insert(gConsole.History.Threads,{Name,Thread})
- if table.getn(gConsole.History.Threads) > 250 then
- table.remove(gConsole.History.Threads,10)
- end
- return Thread
- end
- -- Main Loop
- while true do
- if IBBR(4,0) then
- function ExecuteCommand(Typing,Text)
- if table.getn(Typing) > 0 then
- local IsCommandValid = false
- local COMMAND_Type = ""
- for COMMAND_Word = 1,3 do
- COMMAND_Type = COMMAND_Type..""..Typing[COMMAND_Word]
- end
- -- _G & _L = change variable
- if COMMAND_Type == "_G " or COMMAND_Type == "_L " then
- local COMMAND_Text = F_StringToVar(Typing,4,table.getn(Typing))
- function F_SetVariable(TableArg,Arg)
- SET_VARIABLES(COMMAND_Type,COMMAND_Text,Arg,TableArg)
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),COMMAND_Type.."."..F_ToString(COMMAND_Text)})
- IsCommandValid = true
- end
- F_ConsoleMenu("#VALUE",F_SetVariable,false,true,COMMAND_Type == "_G " and "'"..F_ToString(COMMAND_Text).."' is recognized as "..type(F_ToVariable(COMMAND_Text)) or nil)
- end
- -- _R = run function, the most intricate part of this script but yeah here we go
- if COMMAND_Type == "_R " then
- local CALL_FUNC,COMMAND_Text = function(Func,TableArg,Arg)
- local IsTextPrint,Separator,Key = false,{},","
- local SeparatedArg,TEMP_Arguments,Arguments = {},{},{}
- if type(Func) == "string" and Func == "TextPrintString" then
- IsTextPrint = true
- end
- F_Func,FuncInString = F_ToVariable(Func),type(Func) == "table" and F_ToString(Func) or Func
- if table.getn(TableArg) > 0 then
- if string.find(Arg,Key,1) then
- for Index = 1,table.getn(TableArg) do
- if TableArg[Index] == Key then
- table.insert(Separator,Index)
- else
- if type(SeparatedArg[table.getn(Separator) + 1]) ~= "table" then
- SeparatedArg[table.getn(Separator) + 1] = {}
- end
- table.insert(SeparatedArg[table.getn(Separator) + 1],TableArg[Index])
- end
- end
- local TEMP_Arg,Current = "",0
- while true do
- Current = Current + 1
- if Current > table.getn(TableArg) then
- break
- else
- if Current > 1 then
- local SkipThisOne = false
- for i = 1,table.getn(Separator) do
- if Current == Separator[i] then
- table.insert(TEMP_Arguments,{F_ImportTable(SeparatedArg[i]),TEMP_Arg})
- TEMP_Arg,SkipThisOne = "",true
- end
- end
- if not SkipThisOne then
- TEMP_Arg = TEMP_Arg..""..TableArg[Current]
- if Current == table.getn(TableArg) then
- table.insert(TEMP_Arguments,{F_ImportTable(SeparatedArg[table.getn(SeparatedArg)]),TEMP_Arg})
- end
- end
- else
- TEMP_Arg = TableArg[Current]
- end
- end
- end
- local New = {Symbol = {".","[","]"},Separator = {},Table = {}}
- for TableNumber = 1,table.getn(TEMP_Arguments) do
- if (string.find(TEMP_Arguments[TableNumber][2],New.Symbol[2],1) and string.find(TEMP_Arguments[TableNumber][2],New.Symbol[3],1)) or string.find(TEMP_Arguments[TableNumber][2],New.Symbol[1],1) then
- for Number = 1,table.getn(TEMP_Arguments[TableNumber][1]) do
- if TEMP_Arguments[TableNumber][1] == New.Symbol[2] or TEMP_Arguments[TableNumber][1] == New.Symbol[3] or TEMP_Arguments[TableNumber][1] == New.Symbol[1] then
- table.insert(New.Separator,Number)
- end
- end
- end
- end
- if table.getn(New.Separator) > 0 then
- for TableNumber = 1,table.getn(TEMP_Arguments) do
- local Var,Current = "",0
- while true do
- Current = Current + 1
- if Current > table.getn(TEMP_Arguments[TableNumber][1]) then
- break
- else
- if Current > 1 then
- local SKIP = false
- for i = 1,table.getn(New.Separator) do
- if Current == New.Separator[i] then
- if type(New.Table[TableNumber]) ~= "table" then
- New.Table[TableNumber] = {}
- end
- table.insert(New.Table[TableNumber],Var)
- Var,SKIP = "",true
- end
- end
- if not SKIP then
- Var = Var..""..TEMP_Arguments[TableNumber][1][Current]
- if Current == table.getn(TEMP_Arguments[TableNumber][1]) then
- if type(New.Table[TableNumber]) ~= "table" then
- New.Table[TableNumber] = {}
- end
- table.insert(New.Table[TableNumber],Var)
- end
- end
- else
- Var = Var..""..TEMP_Arguments[TableNumber][1][Current]
- end
- end
- end
- end
- end
- for Number = 1,table.getn(TEMP_Arguments) do
- if type(New.Table[Number]) == "table" then
- table.insert(Arguments,F_ToVariable(New.Table[Number]))
- else
- table.insert(Arguments,F_StringToArg(TEMP_Arguments[Number][1],TEMP_Arguments[Number][2]))
- end
- end
- if IsTextPrint == false then
- local IsReturningValue = F_FuncGetResult(FuncInString,Arguments)
- if not IsReturningValue then
- local Reference = {
- PedCreateXYZ = 1,VehicleCreateXYZ = 2,PickupCreateXYZ = 3,BlipAddXYZ = 4,AddBlipForChar = 5,EffectCreate = 6,
- }
- if Reference[FuncInString] then
- for Count = 1,5000 do
- if type(_G["OBJ_"..Count]) == "nil" then
- _G["OBJ_"..Count] = F_Func(unpack(Arguments)) break
- end
- end
- else
- if FuncInString == "CreatePersistentEntity" then
- for Count = 1,5000 do
- if type(_G["OBJ_"..Count]) == "nil" then
- _G["OBJ_"..Count.."_I"],_G["OBJ_"..Count.."_P"] = F_Func(unpack(Arguments)) break
- end
- end
- else
- F_Func(unpack(Arguments))
- end
- end
- end
- end
- else
- if IsTextPrint == false then
- local IsReturningValue = F_FuncGetResult(FuncInString,
- ((string.find(Arg,"[",1) and string.find(Arg,"]",1)) or string.find(Arg,".",1)) and F_TableToVar(F_StringToVar(TableArg,1,table.getn(TableArg))) or F_StringToArg(TableArg,Arg)
- )
- if not IsReturningValue then
- F_Func(
- ((string.find(Arg,"[",1) and string.find(Arg,"]",1)) or string.find(Arg,".",1)) and F_TableToVar(F_StringToVar(TableArg,1,table.getn(TableArg))) or F_StringToArg(TableArg,Arg)
- )
- end
- end
- end
- else
- if IsTextPrint == false then
- local IsReturningValue = F_FuncGetResult(FuncInString)
- if not IsReturningValue then
- F_Func()
- end
- end
- end
- if IsTextPrint == true then
- if table.getn(Arguments) >= 3 then
- CC_Print(unpack(Arguments))
- F_Wait(type(Arguments[2]) == "number" and Arguments[2] * 1000 or 0)
- else
- ER_MESSAGE("expected 3 more arguments",2)
- end
- end
- local FoundIt = false
- if table.getn(gConsole.History.FuncArg) > 0 then
- for i = 1,table.getn(gConsole.History.FuncArg) do
- if FuncInString == gConsole.History.FuncArg[i].F then
- gConsole.History.FuncArg[i].A,FoundIt = TableArg,true break
- end
- end
- end
- if FoundIt == false then
- table.insert(gConsole.History.FuncArg,{F = FuncInString,A = TableArg})
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),COMMAND_Type.."."..F_ToString(Func)})
- IsCommandValid = true
- end,F_StringToVar(Typing,4,table.getn(Typing))
- if type(F_ToVariable(COMMAND_Text)) == "function" then
- function F_CallFunc(TableArg,Arg)
- CALL_FUNC(COMMAND_Text,TableArg,Arg)
- end
- if table.getn(gConsole.History.FuncArg) > 0 then
- for i = 1,table.getn(gConsole.History.FuncArg) do
- if COMMAND_Text == gConsole.History.FuncArg[i].F then
- if table.getn(gConsole.History.FuncArg[i].A) > 0 then
- gConsole.ColumnFill = F_ImportTable(gConsole.History.FuncArg[i].A)
- break
- end
- end
- end
- end
- F_ConsoleMenu("#ARGUMENTS",F_CallFunc,false,true)
- end
- end
- -- _S = load/run script
- if COMMAND_Type == "_S " then
- local ScriptList,COMMAND_Text,HasOption = {
- {Option = " -ls",Func = LaunchScript,History = "Launch Script"},{Option = " -is",Func = ImportScript,History = "Import Script"},
- {Option = " -rs",Func = function(filename)
- local File,Code = loadfile(gConsole.DEFAULT_DIR..""..filename)
- if File then
- File()
- if type(main) ~= "function" then
- function RUN_SCRIPT(Table,Func)
- local F_Func = F_ToVariable(Table)
- if type(F_Func) == "function" then F_CreateAnIndependentLoop(F_Func)
- else
- ER_MESSAGE("'"..Func.."' FUNCTION DOESN'T EXIST",2)
- end
- end
- F_ConsoleMenu("#MAIN_FUNC",RUN_SCRIPT,false,true,"type which function do you want to run from "..filename)
- else
- local MainFunc = main
- F_CreateAnIndependentLoop(MainFunc)
- main = nil
- end
- else
- ER_MESSAGE(tostring(Code),2)
- end
- end,History = "Run Script"},{Option = " -lo",Func = function(filename)
- local File,Code = loadfile(gConsole.DEFAULT_DIR..""..filename)
- if not File then ER_MESSAGE(tostring(Code),2)
- else
- File()
- end
- end,History = "Load Script"},{Option = " -lm",Func = function(filename)
- _G.shared.CC_CustomMission = gConsole.DEFAULT_DIR..""..filename
- ForceStartMissionIndex(215)
- end,History = "Play Custom Mission"}
- },F_StringToVar(Typing,4,table.getn(Typing)),false
- for i,SCRIPT in ipairs(ScriptList) do
- if string.find(F_ToString(COMMAND_Text),SCRIPT.Option,-4) then
- COMMAND_Text = ""
- for i = 4,table.getn(Typing) - 4 do
- COMMAND_Text = COMMAND_Text..""..Typing[i]
- end
- SCRIPT.Func(COMMAND_Text)
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),SCRIPT.History})
- IsCommandValid,HasOption = true,true
- end
- end
- if not HasOption then
- ER_MESSAGE("expected options: -ls, -is, -rs, -lo and -lm",2)
- end
- end
- -- rb = reverse boolean (v = not v)
- if COMMAND_Type == "rb " then
- F_ToggleSwitchBoolean(F_StringToVar(Typing,4,table.getn(Typing)))
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"NOT '"..F_ToString(F_StringToVar(Typing,4,table.getn(Typing))).."'"})
- IsCommandValid = true
- end
- -- tp = check type
- if COMMAND_Type == "tp " then
- local VarType,F_ReadValue = F_ToVariable(F_StringToVar(Typing,4,table.getn(Typing))),function(Item)
- local NewItem = F_ToVariable(Item)
- if type(NewItem) == "string" or type(NewItem) == "number" or type(NewItem) == "boolean" then
- if type(NewItem) == "boolean" then
- NewItem = tostring(NewItem)
- end
- return NewItem..""
- elseif type(NewItem) == "table" then return table.getn(NewItem).." (max)" end
- return "unreadable"
- end
- local Content = F_StringToVar(Typing,4,table.getn(Typing))
- while not IBBP(8,0) do
- CC_Print("#INFO\n\n\n"..F_ToString(Content).."\nt: "..type(VarType)..", v: "..F_ReadValue(Content),0,1) Wait(0)
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"check '"..F_ToString(Content).."'"})
- IsCommandValid = true
- end
- -- thread = kill thread
- if Text == "thread" then
- if table.getn(gConsole.History.Threads) > 0 then
- local ThreadSelect = 1
- while not IBBP(8,0) do
- ThreadSelect = F_Navigate(gConsole.History.Threads,ThreadSelect,0,1,0)
- if F_Controller(3,0) then
- while not IBBR(3,0) do
- Wait(0)
- end
- local NoThreadsLeft = false
- function F_KillOrLeaveItAlone(TableArg,Arg)
- if Arg == "y" or Arg == "yes" or Arg == "Y" or Arg == "YES" then
- TerminateThread(gConsole.History.Threads[ThreadSelect][2])
- table.remove(gConsole.History.Threads,ThreadSelect)
- if table.getn(gConsole.History.Threads) >= 1 then ThreadSelect = 1
- else
- NoThreadsLeft = true
- end
- end
- end
- F_ConsoleMenu("#CHOICE",F_KillOrLeaveItAlone,false,true,"Y = KILL | N = LEAVE")
- if NoThreadsLeft then
- break
- end
- end
- CC_Print("THREAD KILL\n\n"..ThreadSelect..") "..gConsole.History.Threads[ThreadSelect][1],0,1)
- Wait(0)
- end
- if IBBP(8,0) then
- while not IBBR(8,0) do
- Wait(0)
- end
- end
- else
- CC_Print("NO THREADS FOUND",2,1)
- F_Wait(2000)
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"kill thread"})
- IsCommandValid = true
- end
- -- save = save game
- if Text == "save" then
- if not MissionActive() then
- PlayerSetControl(1)
- PlayerLockButtonInputsExcept(true,9,8)
- repeat
- CC_Print("CONSOLE COMMANDS\n- SaveGame -\n\n\nSAVE ~GRAPPLE~ / CANCEL ~JUMP~",0.5,1)
- Wait(0)
- until IBBP(9,0) or IBBP(8,0)
- if IBBP(9,0) then
- local x,y,z = PlayerGetPosXYZ()
- PlayerSetScriptSavedData(69,4134)
- PedFaceXYZ(gPlayer,x,y + 1,z)
- local Index,Pool = CreatePersistentEntity("AnimSave",x,y + 0.5,z + 1,PedGetHeading(gPlayer),AreaGetVisible())
- PlayerLockButtonInputsExcept(false)
- CameraReturnToPlayer()
- repeat
- Wait(0)
- until IBBR(7,0) or IBBR(8,0)
- DeletePersistentEntity(Index,Pool)
- else
- while not IBBR(8,0) do
- Wait(0)
- end
- end
- PlayerLockButtonInputsExcept(false)
- PlayerSetControl(0)
- else
- CC_Print("UNABLE TO SAVE DURING A MISSION",2,1)
- F_Wait(2000)
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"game: save progress"})
- IsCommandValid = true
- end
- -- save [slot] = save game editor / checker
- local SGIndex = nil
- for _SAVEINDEX = 0,100 do
- if Text == "save ".._SAVEINDEX or Text == "save ".._SAVEINDEX.." /c" then
- SGIndex = _SAVEINDEX
- end
- end
- if type(SGIndex) == "number" then
- if Text ~= "save "..SGIndex.." /c" then
- NEW_ALPHABET = function()
- while true do
- gConsole.Alphabet = {"1","2","3","4","5","6","7","8","9","0"} Wait(0)
- end
- end
- local T = CreateThread("NEW_ALPHABET")
- function SAVEDATA(TableVAL,Value)
- PlayerSetScriptSavedData(SGIndex,Value)
- end
- F_ConsoleMenu("#VALUE",SAVEDATA,false,true,"wild edits may damage your savegame")
- TerminateThread(T)
- else
- local Value = PlayerGetScriptSavedData(SGIndex)
- while not IBBP(8,0) do
- CC_Print("#INFO\n\n\nSAVEDATA("..SGIndex..")\nt: "..type(Value)..", v: "..Value,0,1) Wait(0)
- end
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"game: modify saves"})
- IsCommandValid = true
- end
- -- /pass = quick pass the mission
- if Text == "/pass" then
- if MissionActive() then
- SoundPlayMissionEndMusic(true,10)
- MissionSucceed(false,true,true)
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"mission pass"})
- IsCommandValid = true
- end
- -- /fail = quick fail the mission
- if Text == "/fail" or Text == "/fail -f" then
- if MissionActive() then
- if Text == "/fail -f" then
- MissionSetAutoRestart(false)
- end
- SoundPlayMissionEndMusic(false,10)
- MissionFail(false,true,true)
- end
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"mission fail"})
- IsCommandValid = true
- end
- -- command is not valid, still being ported to command's history
- if not IsCommandValid then
- if table.getn(Typing) <= 6 then
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"'"..Text.."' is unrecognized"})
- else
- local TEMP_Text = ""
- for TEXT_Num = 1,4 do
- TEMP_Text = TEMP_Text..""..Typing[TEXT_Num]
- end
- TEMP_Text = TEMP_Text..".."
- table.insert(gConsole.History.Commands,{F_ImportTable(Typing),"'"..TEMP_Text.."' is unrecognized"})
- end
- end
- end
- end
- F_ConsoleMenu(gConsole.Name,ExecuteCommand,true,false)
- end
- Wait(0)
- end
- end
- function F_ConsoleMenu(Title,Executor,IsHistoryAllowed,Once,Note)
- PlayerSetControl(0)
- PlayerStopAllActionControllers()
- local InsertionWait,InsertionAvailable = GetTimer(),false
- local InsertionPoint,Typing = function()
- if InsertionWait + 800 < GetTimer() then
- InsertionAvailable = not InsertionAvailable
- InsertionWait = GetTimer()
- end
- if InsertionAvailable then return "|"
- else
- return ""
- end
- end,{}
- local PrintOut,ReBuild,ExtraMessage = "",false,nil
- local HistoryID
- if table.getn(gConsole.ColumnFill) > 0 then
- Typing,ReBuild = F_ImportTable(gConsole.ColumnFill),true
- end
- repeat
- gConsole.Option = F_Navigate(gConsole.Alphabet,gConsole.Option,0,1,0)
- if IBBP(3,0) then
- gConsole.Mode = gConsole.Mode + 1
- if gConsole.Mode > 3 then gConsole.Mode = 1 end
- if gConsole.Mode == 1 then
- gConsole.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"," "}
- elseif gConsole.Mode == 2 then
- gConsole.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"," "}
- elseif gConsole.Mode == 3 then
- gConsole.Alphabet = {"1","2","3","4","5","6","7","8","9","0",",",".","/",":",";","'","[","]","{","}","-","_","+","!","@","#","$","%","^","&","*","(",")","`","~"}
- end
- end
- if gConsole.Option > table.getn(gConsole.Alphabet) then
- gConsole.Option = 1
- end
- if IBBP(7,0) then
- if table.getn(Typing) <= 25 then
- table.insert(Typing,gConsole.Alphabet[gConsole.Option])
- ReBuild = true
- else
- SoundPlay2D("WrongBtn")
- end
- elseif IBBP(2,0) then
- if table.getn(Typing) > 0 then
- table.remove(Typing,table.getn(Typing))
- if table.getn(Typing) > 0 then ReBuild = true
- else
- PrintOut = ""
- end
- end
- elseif IBBP(6,0) then
- if table.getn(Typing) > 0 then
- for i = 1,table.getn(Typing) do
- table.remove(Typing,i)
- end
- PrintOut = ""
- end
- end
- if Title == gConsole.Name then
- if IBBP(15,0) then
- gConsole.Pause[1] = not gConsole.Pause[1]
- end
- if IBBP(12,0) then
- if table.getn(gConsole.History.Commands) > 0 then
- if type(HistoryID) == "number" then HistoryID = F_Selection(gConsole.History.Commands,HistoryID,0)
- else
- HistoryID = table.getn(gConsole.History.Commands)
- end
- Typing = F_ImportTable(gConsole.History.Commands[HistoryID][1])
- ReBuild = true
- end
- end
- if IBBP(10,0) then
- if table.getn(gConsole.History.Commands) > 0 then
- if type(HistoryID) == "number" then HistoryID = F_Selection(gConsole.History.Commands,HistoryID,1)
- else
- HistoryID = 1
- end
- Typing = F_ImportTable(gConsole.History.Commands[HistoryID][1])
- ReBuild = true
- end
- end
- else
- if IBBR(8,0) then
- break
- end
- end
- if gConsole.Pause[1] then
- for i,Ped in {PedFindInAreaXYZ(0,0,0,999999)} do
- if PedIsValid(Ped) and Ped ~= gPlayer then
- if table.getn(gConsole.Pause[2]) > 0 then
- local Found = false
- for k,v in ipairs(gConsole.Pause[2]) do
- if Ped == v[1] then Found = true break end
- end
- if not Found then table.insert(gConsole.Pause[2],{Ped,GameGetPedStat(Ped,20)}) end
- else
- table.insert(gConsole.Pause[2],{Ped,GameGetPedStat(Ped,20)})
- end
- end
- end
- for k,v in ipairs(gConsole.Pause[2]) do if PedIsValid(v[1]) then GameSetPedStat(v[1],20,0) end end
- else
- for k,v in ipairs(gConsole.Pause[2]) do
- if PedIsValid(v[1]) then
- GameSetPedStat(v[1],20,v[2])
- end
- end
- for i = 1,table.getn(gConsole.Pause[2]) do table.remove(gConsole.Pause[2],i) end
- end
- if IBP(9,0) then
- if IBBP(0,0) and table.getn(Typing) > 0 then
- if table.getn(gConsole.Clipboard) > 0 then gConsole.Clipboard = {} end
- local Text = ""
- for i = 1,table.getn(Typing) do
- table.insert(gConsole.Clipboard,Typing[i])
- Text = Text..""..Typing[i]
- end
- while not IBBR(0,0) do Wait(0) end
- if type(Note) ~= "string" then CC_Print("'"..Text.."' has been copied to clipboard",2,2)
- else
- ExtraMessage = {"'"..Text.."' has been copied to clipboard",GetTimer(),2}
- end
- end
- if IBBP(1,0) and table.getn(gConsole.Clipboard) > 0 then
- for i = 1,table.getn(gConsole.Clipboard) do
- if table.getn(Typing) >= 25 then
- break
- end
- table.insert(Typing,gConsole.Clipboard[i])
- end
- ReBuild = true
- while not IBBR(1,0) do Wait(0) end
- end
- end
- if ReBuild then
- local Current = 0
- while true do
- Current = Current + 1
- if Current > table.getn(Typing) then
- break
- else
- if Current > 1 then
- PrintOut = PrintOut..""..Typing[Current]
- else
- PrintOut = Typing[Current]
- end
- end
- end
- ReBuild = false
- end
- Sequence,ConsoleHistory = function(Table,Option)
- if Option == 1 then
- return Table[table.getn(Table) - 1]..""..Table[table.getn(Table)]..""..Table[Option]..""..Table[Option + 1]..""..Table[Option + 2]
- elseif Option == 2 then
- return Table[table.getn(Table)]..""..Table[Option - 1]..""..Table[Option]..""..Table[Option + 1]..""..Table[Option + 2]
- elseif Option == table.getn(Table) then
- return Table[table.getn(Table) - 2]..""..Table[table.getn(Table) - 1]..""..Table[Option]..""..Table[1]..""..Table[2]
- elseif Option == table.getn(Table) - 1 then
- return Table[table.getn(Table) - 3]..""..Table[table.getn(Table) - 2]..""..Table[Option]..""..Table[table.getn(Table)]..""..Table[1]
- else
- return Table[Option - 2]..""..Table[Option - 1]..""..Table[Option]..""..Table[Option + 1]..""..Table[Option + 2]
- end
- end,function()
- if gConsole.IsHistoryEnabled then
- local HistoryNum = table.getn(gConsole.History.Commands)
- if HistoryNum > 0 then
- if table.getn(gConsole.History.Commands) > 3 then
- return gConsole.History.Commands[HistoryNum - 2][2].."\n"..gConsole.History.Commands[HistoryNum - 1][2].."\n"..gConsole.History.Commands[HistoryNum][2]
- end
- if HistoryNum == 1 then
- return gConsole.History.Commands[1][2]
- elseif HistoryNum == 2 then
- return gConsole.History.Commands[1][2].."\n"..gConsole.History.Commands[2][2]
- elseif HistoryNum == 3 then
- return gConsole.History.Commands[1][2].."\n"..gConsole.History.Commands[2][2].."\n"..gConsole.History.Commands[3][2]
- end
- end
- end
- return ""
- end
- CC_Print(Title.."\n\n> "..PrintOut..""..InsertionPoint().."\n\n| "..gConsole.Alphabet[gConsole.Option].." |\n"..Sequence(gConsole.Alphabet,gConsole.Option),0,1)
- if type(Note) == "string" then
- if type(ExtraMessage) == "table" then
- CC_Print(ExtraMessage[1].."\n^\n"..Note,0,2)
- if ExtraMessage[2] + (ExtraMessage[3] * 1000) <= GetTimer() then
- ExtraMessage = nil
- end
- else
- CC_Print(Note,0,2)
- end
- end
- if IBBP(14,0) then
- while not IBBR(14,0) do Wait(0) end
- Executor(Typing,PrintOut)
- if Once then
- break
- end
- end
- _G["IsButtonPressed"],_G["IsButtonBeingPressed"],_G["IsButtonBeingReleased"] = FAKE_Button,FAKE_Button,FAKE_Button
- _G["TextPrintString"] = FAKE_TextPrintString
- PlayerSetControl(0)
- Wait(0)
- until IBBR(4,0)
- while IBBR(4,0) or IBBR(8,0) do
- Wait(0)
- end
- gConsole.ColumnFill = {}
- if Title == gConsole.Name and gConsole.Pause[1] then
- for k,v in ipairs(gConsole.Pause[2]) do
- if PedIsValid(v[1]) then
- GameSetPedStat(v[1],20,v[2])
- end
- end
- for i = 1,table.getn(gConsole.Pause[2]) do table.remove(gConsole.Pause[2],i) end
- end
- _G["IsButtonPressed"],_G["IsButtonBeingPressed"],_G["IsButtonBeingReleased"] = IBP,IBBP,IBBR
- _G["TextPrintString"] = CC_Print
- PlayerSetControl(1)
- end
- -------------------------------------------------------------------------------
- -- Decoder / Converter
- -------------------------------------------------------------------------------
- function F_StringToObj(String)
- local Peds = {
- gPlayer = 0,
- gZoe = {2,48},
- gBeatrice = {3,95},
- gAlgernon = {4,208},
- gFatty = {5,122,155},
- gMelvin = 6,
- gThad = {7,174,210,224},
- gBucky = {8,209},
- gCornelius = 9,
- gEarnest = {10,215},
- gDonald = {11,162},
- gDamon = {12,112,168,205},
- gKirby = {13,109,207},
- gMandy = {14,93,230},
- gDan = {15,111},
- gLuis = {16,92},
- gCasey = {17,164,232},
- gBo = {18,204,231},
- gTed = {19,110,216},
- gJuri = {20,206},
- gPeanut = {21,202},
- gHal = {22,200},
- gJohnny = {23,217},
- gLefty = 24,
- gLola = {25,96},
- gLucky = {26,161},
- gVance = {27,173,203},
- gRicky = 28,
- gNorton = {29,201},
- gGord = {30,214},
- gTad = {31,177,213},
- gChad = {32,117,241,242},
- gBif = {33,133,172,243},
- gJustin = {34,118,179,212,244,245},
- gBryce = {35,36,178,239,240},
- gDarby = {37,218},
- gPinky = {38,94,167,175,182},
- gAngie = {39,166,180},
- gParker = {40,119,163,211,246,247},
- gJerry = {41,198},
- gOtto = {42,150},
- gLeon = {43,153,199},
- gDuncan = 44,
- gHenry = {45,154},
- gGurney = {46,197},
- gOmar = 47,
- gMax = 49,
- gSeth = 50,
- gEdward = 51,
- gKarl = 52,
- gTheo = 53,
- gPeabody = 54,
- gBurton = {55,229},
- gLuntz = 56,
- gGalloway = {57,129},
- gEdna = {58,221},
- gWinston = 59,
- gMcRae = 60,
- gHattrick = 61,
- gCarvin = 62,
- gPhillips = 63,
- gSlawter = 64,
- gCrabblesnitch = 65,
- gSheldon = {66,225},
- gChristy = {67,90,181},
- gGloria = 68,
- gPedro = {69,159,226,258},
- gConstantinos = {70,235},
- gRay = 71,
- gIvan = {72,170,227},
- gTrevor = {73,171,228},
- gEunice = {74,256},
- gRussell = {75,176},
- gBambillo = 76,
- gSullivan = 77,
- gKopke = 78,
- gRushinski = 79,
- gIsaacs = 80,
- gBethany = 81,
- gORourke = 82,
- gMonson = {83,234},
- gOwens = 84,
- gTrent = 85,
- gTobias = 86,
- gGrant = 87,
- gMascot = 88,
- gOh = 89,
- gEdgar = {91,196},
- gWilliams = {97,238},
- gOWrest = 98,
- gDavis = 99,
- gBreckindale = 100,
- gDoolin = 101,
- gTroy = 102,
- gNate = 103,
- gCarmichael = 104,
- gNicky = 105,
- gWatts = 106,
- gAbby = 107,
- gMihailovich = 108,
- gFreeley = 113,
- gDorsey = 114,
- gHector = 115,
- gOsbourne = 116,
- gMaria = 120,
- gBob = 121,
- gChuck = 123,
- gIan = 124,
- gFenwick = 125,
- gNeil = 126,
- gSvenson = 127,
- gDenny = 128,
- gGary = {130,160},
- gKrakauer = 131,
- gMoratti = 132,
- gPeter = {134,165,255},
- gSmith = 135,
- gRat = 136,
- gMelody = {137,257},
- gKaren = 138,
- gGordon = {139,169},
- gBrandy = 140,
- gPitbull = {141,219,220},
- gLance = 142,
- gCrystal = 143,
- gMartin = 144,
- gEthan = 145,
- gWade = 146,
- gTom = 147,
- gRamirez = 148,
- gHuntingdon = 149,
- gWiggins = 151,
- gFloyd = 152,
- gStan = 156,
- gHandy = 157,
- gGregory = 158,
- gBuba = 183,
- gMrGordon = 184,
- gLisburn = 185,
- gBetty = 187,
- gLightning = 188,
- gZeke = 189,
- gAlfred = 190,
- gParis = 191,
- gCourtney = 192,
- gDelilah = 193,
- gDrew = 194,
- gCastillo = 195,
- gMcInnis = {222,236,237},
- gJohnson = 223,
- gPunchBag = 233,
- gMatthews = 248,
- gPeters = 249,
- gElfF = 250,
- gElfM = 251,
- gRudy = 252,
- gSanta = {253,254},
- gGay = {85,13,109,207}, -- bonus!, you already know who's who
- }
- if Peds[String] then
- if String == "gPlayer" then
- return gPlayer
- end
- for i,Ped in {PedFindInAreaXYZ(0,0,0,99999)} do
- if PedIsValid(Ped) then
- if type(Peds[String]) == "table" then
- for Index = 1,table.getn(Peds[String]) do
- if PedIsModel(Ped,Peds[String][Index]) then
- return Ped
- end
- end
- else
- if PedIsModel(Ped,Peds[String]) then
- return Ped
- end
- end
- end
- end
- end
- local Vehicles = {
- vGreen = 272,
- vRetro = 273,
- vCrap = 274,
- vBan = 279,
- vRed = 278,
- vBlue = 277,
- vMountain = 280,
- vLady = 281,
- vAqua = 283,
- vRacer = 282,
- vScooter = 276,
- vMower = 284,
- vGoCart = 289,
- vTaxi = 286,
- vLimo = 290,
- vForeign = 292,
- vRegular = 293,
- v70Wagon = 294,
- vDomestic = 296,
- vTruck = 297,
- vDozer = 288,
- vPBike = 275,
- vPCar = 295,
- vArc1 = 298,
- vArc2 = 287,
- vArc3 = 285,
- -- shorter name
- vGRN = 272,
- vRTR = 273,
- vMTN = 280,
- vSCTR = 276,
- vGC = 289,
- vFRGN = 292,
- vRGLR = 293,
- vWGN = 294,
- vDMST = 296,
- vPB = 275,
- vPC = 295,
- }
- if Vehicles[String] then
- local Result = VehicleFindInAreaXYZ(0,0,0,999999)
- if type(Result) == "table" then
- for I,V in ipairs(Result) do
- if VehicleIsValid(V) and VehicleIsModel(V,Vehicles[String]) then
- return V
- end
- end
- end
- end
- return nil
- end
- function F_FuncGetResult(String,Arguments)
- local Func = {
- AreaGetTransitionTime = 1,
- AreaGetPlayerPositionBeforeStore = 5,
- AreaGetPopulationCullDistance = 1,
- AreaPOIGetGender = 1,
- AreaPOIGetMaxNumber = 1,
- AreaPOIGetFaction = 1,
- AreaPOIGetInterestType = 1,
- AreaPOIGetPosition = 3,
- AreaGetScriptedPOIPointToActivate = 1,
- AreaGetVisible = 1,
- ButtonHistoryGetFromHistory = 1,
- CameraGet169Mode = 1,
- CameraGetActive = 1,
- CameraGetFOV = 1,
- WeatherGet = 1,
- CarnivalBallTossGetCount = 1,
- CarnivalDunkTankGetCount = 1,
- CarnivalDunkTankGetTargetPos = 3,
- CarnivalStrikerMeterGetLevel = 1,
- ClassBiologyGetScorePercentage = 1,
- ClassChemGetActionJustFailed = 1,
- ClassChemGetActionJustFinished = 1,
- ClassChemGetActionJustStarted = 1,
- ClassChemGetLastAction = 1,
- ClassChemGetPerformance = 1,
- ClassEnglishGetLastSubmittedWord = 1,
- ClassEnglishGetLastSubmittedWordLength = 1,
- ClassEnglishGetScorePercentage = 1,
- ClassGeographyGetScorePercentage = 1,
- ClassMathAnswerGiven = 1,
- ClassMathGetScore = 1,
- ClassMathGetScorePercentage = 1,
- ClassMusicGetWinner = 1,
- CompareHashIDs = 1,
- ClockGet = 1,
- ClothingGetPlayersHair = 1,
- ClothingGetPlayerOutfit = 1,
- ClothingGetPlayer = 1,
- CollectiblesGetNumCollected = 1,
- CollectiblesGetNumCollectable = 1,
- DemoBuildGetSelectedMission = 1,
- GetCutsceneRunning = 1,
- GetCutsceneTime = 1,
- CounterGetCurrent = 1,
- CounterGetMax = 1,
- GetPointFromPath = 3,
- GetPointListSize = 1,
- GetPointFromPointList = 3,
- GetPointList = 3,
- PathGetLastNode = 1,
- ItemGetCurrentNum = 1,
- GetStickValue = 1,
- MissionGetUserStartResponse = 1,
- GetFactionRespect = 1,
- GetCurrentDay = 1,
- GetWeaponLOD = 1,
- ChapterGet = 1,
- FireGetHealth = 1,
- GetMissionCount = 1,
- MissionGetCurrentName = 1,
- MissionGetName = 1,
- MissionGetIndex = 1,
- GetTotalMissionSuccessCount = 1,
- GetMissionCurrentSuccessCount = 1,
- GetMissionCurrentAttemptCount = 1,
- GetMissionSuccessCount = 1,
- GetMissionAttemptCount = 1,
- MissionTimerGetTimeRemaining = 1,
- ObjectGetModelIndex = 1,
- PAnimGetHealth = 1,
- PAnimGetPathFollowSpeed = 1,
- PAnimGetPoolIndex = 1,
- PAnimGetPosition = 3,
- PAnimGetPropFlag = 1,
- PAnimGetSocketXYZ = 3,
- PedGetGrappleTargetPed = 1,
- PedGetDamageTakenMultiplier = 1,
- PedGetDamageGivenMultiplier = 1,
- PedGetName = 1,
- PedGetNameHashID = 1,
- PedGetAmmoCount = 1,
- PedGetTargetPed = 1,
- PedGetFaction = 1,
- PedGetPedCountWithModel = 1,
- PedGetLastVehicle = 1,
- PedGetImmortalFlag = 1,
- PedGetOffsetInWorldCoords = 3,
- PedGetWeapon = 1,
- PedGetHeadPos = 3,
- PedGetUniqueModelStatus = 1,
- PedGetEmotionTowardsPed = 1,
- PedGetAllyFollower = 1,
- PedGetAllyLeader = 1,
- PedGetLastHitWeapon = 1,
- PedGetHeading = 1,
- PedGetFlag = 1,
- PedGetPedToTypeAttitude = 1,
- PedGetTypeToTypeAttitude = 1,
- PedGetRandomModelId = 1,
- PedGetHitRecordDamage = 1,
- PedGetMoney = 1,
- PedGetHealth = 1,
- PedGetMaxHealth = 1,
- PedGetVehicleWhoHitMeLast = 1,
- PedGetWhoHitMeLast = 1,
- PedGetPosXYZ = 3,
- WeaponGetType = 1,
- PickupGetXYZ = 3,
- PlayerGetPhysicalState = 1,
- PlayerGetScriptSavedData = 1,
- PlayerGetNumTimesBusted = 1,
- PlayerGetPunishmentPoints = 1,
- PlayerGetLastBikeId = 1,
- PlayerGetBikeId = 1,
- PlayerGetMoney = 1,
- PlayerGetHealth = 1,
- PlayerGetPosXYZ = 3,
- POIGetPosXYZ = 3,
- ShopGetClerkID = 1,
- StatGetGameCompletion = 1,
- StatGetPrincipalDiffAsFloat = 1,
- StatGetPrincipalDiffAsInt = 1,
- StatGetAsFloat = 1,
- StatGetAsInt = 1,
- GameGetPedStat = 1,
- SystemGetSavedPositionInformation = 6,
- GetLanguage = 1,
- GetCurrentNumOfAmbientBikes = 1,
- VehicleGetHealth = 1,
- CarGetDamageNumber = 1,
- VehicleGetModelId = 1,
- VehicleGetPosXYZ = 3,
- AreaIsCollisionLoaded = 1,
- AreaIsDoorLocked = 1,
- AreaIsDoorLockedToPeds = 1,
- AreaIsDoorOpen = 1,
- AreaIsLoading = 1,
- AreaTriggerIsValid = 1,
- CameraIsPointVisible = 1,
- CarnivalStrikerMeterIsRunning = 1,
- ClassBiologyIsBadMove = 1,
- ClassBiologyIsGrossOut = 1,
- ClassEnglishWordWasDuplicate = 1,
- ClassEnglishWordWasNaughty = 1,
- ClassEnglishWordWasNotValid = 1,
- ClassEnglishWordWasTooShort = 1,
- ClassEnglishWordWasValid = 1,
- ClassMathValidAnswer = 1,
- ClassMathInvalidAnswer = 1,
- ClockIsPaused = 1,
- ClothingIsWearingAnyOutfit = 1,
- ClothingIsWearingOutfit = 1,
- EffectIsRunning = 1,
- GetIsMissionSpecific = 1,
- IsActionTreeLoaded = 1,
- IsButtonBeingPressed = IBBP,
- IsButtonBeingReleased = IBBR,
- IsButtonPressed = IBP,
- IsCutsceneLoaded = 1,
- IsDemoBuildEnabled = 1,
- IsInTitleMenu = 1,
- IsItemAWeapon = 1,
- IsMissionAvailable = 1,
- IsMissionCompleated = 1,
- IsMissionDebugFailure = 1,
- IsMissionDebugSuccess = 1,
- IsMissionFromDebug = 1,
- IsMissionFromRestart = 1,
- IsMissionRestartable = 1,
- IsMissionSimpleFade = 1,
- IsStreamingBusy = 1,
- MinigameIsActive = 1,
- MinigameIsFadingCompletion = 1,
- MinigameIsHighScore = 1,
- MinigameIsReady = 1,
- MinigameIsShowingCompletion = 1,
- MinigameIsShowingGrades = 1,
- MinigameIsSuccess = 1,
- ObjectIsDestroyed = 1,
- ObjectIsInAreaObject = 1,
- ObjectIsInAreaXYZ = 1,
- ObjectIsModel = 1,
- ObjectTypeIsInTrigger = 1,
- PAnimIsDestroyed = 1,
- PAnimIsOpen = 1,
- PAnimIsPlaying = 1,
- PAnimIsPlayingNode = 1,
- PAnimIsUsed = 1,
- POIIsValid = 1,
- PedIsAlerted = 1,
- PedIsAnimFlagSet = 1,
- PedIsCurrentAnim = 1,
- PedIsDead = 1,
- PedIsDoingTask = 1,
- PedIsFacingObject = 1,
- PedIsFacingXYZ = 1,
- PedIsFemale = 1,
- PedIsHit = 1,
- PedIsInAnyVehicle = 1,
- PedIsInAreaObject = 1,
- PedIsInAreaXYZ = 1,
- PedIsInCombat = 1,
- PedIsInTrigger = 1,
- PedIsInVehicle = 1,
- PedIsModel = 1,
- PedIsOnScreen = 1,
- PedIsOnVehicle = 1,
- PedIsPedInBox = 1,
- PedIsPlayer = 1,
- PedIsPlaying = 1,
- PedIsPropAttached = 1,
- PedIsSocializing = 1,
- PedIsSpotted = 1,
- PedIsStandingOnVehicle = 1,
- PedIsTargetable = 1,
- PedIsUsingProp = 1,
- PedIsValid = 1,
- PedIsWantingToSocialize = 1,
- PickupIsInAreaXYZ = 1,
- PickupIsPickedUp = 1,
- PlayerIsInAnyVehicle = 1,
- PlayerIsInAreaObject = 1,
- PlayerIsInAreaXYZ = 1,
- PlayerIsInStealthProp = 1,
- PlayerIsInTrigger = 1,
- PlayerIsInVehicle = 1,
- SoundIsPreloadReady = 1,
- SoundIsSpeechPreloaded = 1,
- SystemIsReady = 1,
- VehicleIsInAreaXYZ = 1,
- VehicleIsInTrigger = 1,
- VehicleIsModel = 1,
- VehicleIsValid = 1,
- YearbookIsFull = 1,
- rawget = 1,
- getfenv = 1,
- getmetatable = 1,
- xpcall = 1,
- pcall = 1,
- -- string
- ["string.find"] = string.find,
- -- table
- ["table.getn"] = table.getn,
- ["table.concat"] = table.concat,
- -- arithmetic
- ["math.sin"] = math.sin,
- ["math.cos"] = math.cos,
- ["math.tan"] = math.tan,
- ["math.abs"] = math.abs,
- ["math.randomseed"] = math.randomseed,
- ["math.random"] = math.random,
- ["math.floor"] = math.floor,
- ["math.ceil"] = math.ceil,
- ["math.sqrt"] = math.sqrt,
- ["math.atan"] = math.atan,
- ["math.atan2"] = math.atan2,
- ["math.acos"] = math.acos,
- ["math.asin"] = math.asin,
- ["math.pow"] = math.pow,
- ["math.deg"] = math.deg,
- ["math.rad"] = math.rad,
- ["math.exp"] = math.exp,
- ["math.mod"] = math.mod, -- 5.0.2
- -- debug
- ["debug.getupvalue"] = debug.getupvalue,
- ["debug.gethook"] = debug.gethook,
- --["debug.getinfo"] = debug.getinfo, -- returns a table which can't be read
- ["debug.getlocal"] = debug.getlocal,
- }
- if Func[String] then
- local Output
- if Arguments then
- Output = {
- (type(Func[String]) == "function" and Func[String] or _G[String])(type(Arguments) == "table" and unpack(Arguments) or Arguments)
- }
- else
- Output = {(type(Func[String]) == "function" and Func[String] or _G[String])()}
- end
- local Text = ""
- if table.getn(Output) > 1 then
- local function F_Coma(Current,Max) if Current == Max then return "" end return "," end
- for K = 1,table.getn(Output) do
- Text = Text..""..tostring(Output[K])..""..F_Coma(K,table.getn(Output))
- end
- else
- Text = tostring(Output[1])
- end
- while not IBBP(8,0) do
- CC_Print("#RESULT\n> "..Text.."\n\n~JUMP~ CONFIRM",0,1) Wait(0)
- end
- return true
- end
- return false
- end
- function SET_VARIABLES(Type,Variable,Value,TableVal)
- local ArgExpressions,Identified = {
- {"true",true},{"not false",true},{"false",false},{"not true",false},{"nil",nil},{"not nil",true},{"{}",{}}
- },false
- if Type == "_G " then
- local F_GlobalSet = function(Var,Val)
- local Type = type(Var)
- if Type == "table" then
- local TableEnd = table.getn(Var)
- for i = 1,table.getn(Var) do
- for Number = 1,5000 do
- if Var[i] == tostring(Number) then Var[i] = Number end
- end
- end
- if TableEnd == 2 then
- _G[Var[1]][Var[2]] = Val
- elseif TableEnd == 3 then
- _G[Var[1]][Var[2]][Var[3]] = Val
- elseif TableEnd == 4 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]] = Val
- elseif TableEnd == 5 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]] = Val
- elseif TableEnd == 6 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]][Var[6]] = Val
- elseif TableEnd == 7 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]][Var[6]][Var[7]] = Val
- elseif TableEnd == 8 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]][Var[6]][Var[7]][Var[8]] = Val
- elseif TableEnd == 9 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]][Var[6]][Var[7]][Var[8]][Var[9]] = Val
- elseif TableEnd == 10 then
- _G[Var[1]][Var[2]][Var[3]][Var[4]][Var[5]][Var[6]][Var[7]][Var[8]][Var[9]][Var[10]] = Val
- else
- ER_MESSAGE("error: table is unreachable",2)
- end
- else
- _G[Var] = F_StringToObj(Val) or Val
- end
- end
- for i,Exp in ipairs(ArgExpressions) do
- if Value == Exp[1] then
- F_GlobalSet(Variable,Exp[2]) Identified = true
- break
- end
- end
- if TableVal ~= nil then
- local Arithmetic = F_Arithmetical(TableVal,Value)
- if Arithmetic ~= nil then
- F_GlobalSet(Variable,Arithmetic) Identified = true
- end
- end
- if not Identified then
- local STRINGS,IsString = {
- "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",
- "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"," "
- },false
- for i,v in ipairs(STRINGS) do
- if string.find(Value,v,1) then
- IsString = true
- end
- end
- if IsString then
- local IsNotGlobal = true
- local NewValue = type(TableVal) == "table" and F_ToVariable(F_StringToVar(TableVal,1,table.getn(TableVal))) or _G[Value]
- if type(NewValue) ~= "nil" then
- F_GlobalSet(Variable,NewValue) IsNotGlobal = false
- end
- if IsNotGlobal then F_GlobalSet(Variable,Value) end
- else
- F_GlobalSet(Variable,tonumber(Value))
- end
- end
- elseif Type == "_L " then
- -- this was merely hypothetical even though i implemented it correctly according to https://www.lua.org/pil/23.1.1.html
- if type(Variable) == "string" then
- local Index = 1
- while true do
- local Name,Val = debug.getlocal(2,Index)
- if not Name then break end
- if Name == Variable then
- for i,Exp in ipairs(ArgExpressions) do
- if Value == Exp[1] then
- debug.setlocal(2,Index,Exp[2]) Identified = true
- break
- end
- end
- if not Identified then
- if TableVal then
- local Arithmetic = F_Arithmetical(TableVal,Value)
- if Arithmetic ~= nil then
- debug.setlocal(2,Index,Arithmetic) break
- end
- end
- local STRINGS,IsString = {
- "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",
- "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"," "
- },false
- for i,v in ipairs(STRINGS) do
- if string.find(Value,v,1) then
- IsString = true
- end
- end
- if IsString then
- local IsNotGlobal = true
- local NewValue = type(TableVal) == "table" and F_ToVariable(F_StringToVar(TableVal,1,table.getn(TableVal))) or _G[Value]
- if type(NewValue) ~= "nil" then
- debug.setlocal(2,Index,NewValue) IsNotGlobal = false
- end
- if IsNotGlobal then debug.setlocal(2,Index,F_StringToObj(Value) or Value) end
- else
- debug.setlocal(2,Index,tonumber(Value))
- end
- end
- end
- Index = Index + 1
- Wait(0)
- end
- else
- ER_MESSAGE("string expected for _L",2)
- end
- else
- ER_MESSAGE("expected '_G' or '_L'",2)
- end
- end
- function F_TableToVar(Table)
- if type(Table) == "table" then
- local TotalArg = table.getn(Table)
- for i = 1,table.getn(Table) do
- for Number = 1,5000 do
- if Table[i] == tostring(Number) then
- Table[i] = Number
- end
- end
- end
- if TotalArg == 2 then
- return _G[Table[1]][Table[2]]
- elseif TotalArg == 3 then
- return _G[Table[1]][Table[2]][Table[3]]
- elseif TotalArg == 4 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]]
- elseif TotalArg == 5 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]]
- elseif TotalArg == 6 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]][Table[6]]
- elseif TotalArg == 7 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]][Table[6]][Table[7]]
- elseif TotalArg == 8 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]][Table[6]][Table[7]][Table[8]]
- elseif TotalArg == 9 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]][Table[6]][Table[7]][Table[8]][Table[9]]
- elseif TotalArg == 10 then
- return _G[Table[1]][Table[2]][Table[3]][Table[4]][Table[5]][Table[6]][Table[7]][Table[8]][Table[9]][Table[10]]
- else
- ER_MESSAGE("error: table is unreachable",2)
- end
- else
- ER_MESSAGE("expected argument of type table, got "..type(Table),2)
- end
- return nil
- end
- function F_TableToStr(Table)
- local Text,PrevIsNumber = "",false
- for i = 1,table.getn(Table) do
- if i == table.getn(Table) then
- if PrevIsNumber then Text,PrevIsNumber = Text.."]"..Table[i],false
- else
- Text = Text.."."..Table[i]
- end
- else
- local IsNumber = false
- for number = 1,5000 do
- if Table[i] == tostring(number) then
- Text,PrevIsNumber,IsNumber = Text.."["..Table[i],true,true
- break
- end
- end
- if not IsNumber then
- if PrevIsNumber then Text,PrevIsNumber = Text.."]"..Table[i],false
- else
- if i ~= 1 then Text = Text.."."..Table[i]
- else
- Text = Text..""..Table[i]
- end
- end
- end
- end
- end
- return Text
- end
- function F_StringToVar(Table,Min,Max)
- local Separator,NewTable,Text = {},{},""
- for TableNumber = Min,Max do
- Text = Text..""..Table[TableNumber]
- table.insert(NewTable,Table[TableNumber])
- end
- if (string.find(Text,"[",1) and string.find(Text,"]",1)) or string.find(Text,".",1) then
- Text = {}
- for Number = 1,table.getn(NewTable) do
- if NewTable[Number] == "." or NewTable[Number] == "[" or NewTable[Number] == "]" then
- table.insert(Separator,Number)
- end
- end
- local TEMP_Var,Current = "",0
- while true do
- Current = Current + 1
- if Current > table.getn(NewTable) then
- break
- else
- if Current > 1 then
- local SkipThisOne = false
- for i = 1,table.getn(Separator) do
- if Current == Separator[i] then
- table.insert(Text,TEMP_Var)
- TEMP_Var,SkipThisOne = "",true
- end
- end
- if not SkipThisOne then
- TEMP_Var = TEMP_Var..""..NewTable[Current]
- if Current == table.getn(NewTable) then
- table.insert(Text,TEMP_Var)
- end
- end
- else
- TEMP_Var = NewTable[Current]
- end
- end
- end
- end
- return Text
- end
- function F_StringToArg(Table,String)
- local ArgExpressions,Identified = {
- {"true",true},{"not false",true},{"false",false},{"not true",false},{"nil",nil},{"not nil",true},{"{}",{}},
- },false
- for i,Exp in ipairs(ArgExpressions) do
- if String == Exp[1] then
- return Exp[2]
- end
- end
- local Arithmetic = F_Arithmetical(Table,String)
- if Arithmetic ~= nil then
- return Arithmetic
- end
- local STRINGS,IsString = {
- "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",
- "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"," "
- },false
- for i,v in ipairs(STRINGS) do
- if string.find(String,v,1) then
- IsString = true
- end
- end
- if IsString then
- local Value = type(Table) == "table" and F_ToVariable(F_StringToVar(Table,1,table.getn(Table))) or _G[String]
- if type(Value) ~= "nil" then
- return Value
- end
- local Thing = F_StringToObj(String)
- if Thing ~= nil then
- return Thing
- end
- return String -- the real string
- else
- return tonumber(String)
- end
- end
- function F_Arithmetical(Table,String)
- local Math,IsArithmeticOperation = {
- Char = {"*","/","+","-"},Separator = {},Table = {},Temp = {},NewSequence = {},Result = {},
- Calculate = function(V1,Char,V2)
- local Operation = {
- {"*",V1 * V2},{"/",V1 / V2},{"+",V1 + V2},{"-",V1 - V2}
- }
- for I,V in ipairs(Operation) do
- if Char == V[1] then
- return V[2]
- end
- end
- ER_MESSAGE("unexpected symbol char '"..Char.."'",2)
- return nil
- end
- },false
- for Index = 1,table.getn(Math.Char) do
- if string.find(String,Math.Char[Index],1) then
- IsArithmeticOperation = true
- end
- end
- if IsArithmeticOperation then
- local Text = ""
- for Index = 1,table.getn(Table) do
- if type(Math.Table[table.getn(Math.Separator) + 1]) ~= "table" then
- Math.Table[table.getn(Math.Separator) + 1] = {}
- end
- if Table[Index] == "*" or Table[Index] == "/" or Table[Index] == "+" or Table[Index] == "-" then
- for I,Char in ipairs(Math.Char) do
- if Table[Index] == Char then
- table.insert(Math.Separator,{Char,Index})
- end
- end
- table.insert(Math.Temp,Text)
- Text = ""
- else
- Text = Text..""..Table[Index]
- table.insert(Math.Table[table.getn(Math.Separator) + 1],Table[Index])
- if Index == table.getn(Table) then
- table.insert(Math.Temp,Text)
- end
- end
- end
- for Index = 1,table.getn(Math.Separator) do
- if Math.Separator[Index][1] == "*" or Math.Separator[Index][1] == "/" then
- table.insert(Math.NewSequence,Index)
- end
- end
- local F_AddNewResults = function(Int)
- local Alphabet,ProbablyMathLib = {
- "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",
- "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",
- },{false,false}
- for I,V in ipairs(Alphabet) do
- if string.find(Math.Temp[Int],V,1) then
- ProbablyMathLib[1] = true
- elseif string.find(Math.Temp[Int + 1],V,1) then
- ProbablyMathLib[2] = true
- end
- end
- local Value = {}
- local F_GetResults = function(Index,TableIndex)
- if ProbablyMathLib[Index] then
- local Var = F_ToVariable(
- ((string.find(Math.Temp[TableIndex],"[",1) and string.find(Math.Temp[TableIndex],"]",1)) or string.find(Math.Temp[TableIndex],".",1)) and Math.Table[TableIndex] or Math.Temp[TableIndex]
- )
- return Var ~= nil and tonumber(Var) or F_MathLib(Math.Table[TableIndex],Math.Temp[TableIndex])
- end
- return nil
- end
- Value[1] = F_GetResults(1,Int) or tonumber(Math.Temp[Int])
- Value[2] = F_GetResults(2,Int + 1) or tonumber(Math.Temp[Int + 1])
- if table.getn(Math.NewSequence) > 1 and Math.Separator[Int][1] == "*" or Math.Separator[Int][1] == "/" then
- if Value[1] == 0 then
- Value[1] = type(Math.Result[table.getn(Math.Result)]) ~= "nil" and Math.Result[table.getn(Math.Result)] or Value[1]
- end
- Math.Result[table.getn(Math.Result)] = Value[1] ~= 0 and 0 or Math.Result[table.getn(Math.Result)]
- end
- table.insert(Math.Result,
- Math.Calculate(
- Value[1],Math.Separator[Int][1],Value[2]
- )
- )
- Math.Temp[Int],Math.Temp[Int + 1] = 0,0 -- reset the temporary results to get a minus number in subtraction
- end
- if table.getn(Math.NewSequence) > 0 then
- for i = 1,table.getn(Math.NewSequence) do
- F_AddNewResults(Math.NewSequence[i])
- end
- end
- if table.getn(Math.Separator) > table.getn(Math.NewSequence) then
- for I = 1,table.getn(Math.Separator) do
- if table.getn(Math.NewSequence) > 0 then
- for K = 1,table.getn(Math.NewSequence) do
- if I ~= Math.NewSequence[K] then F_AddNewResults(I) end
- end
- else
- F_AddNewResults(I)
- end
- end
- end
- local Output = 0
- for K = 1,table.getn(Math.Result) do
- Output = Output + Math.Result[K]
- end
- return Output
- else
- return F_MathLib(Table,String) or nil
- end
- end
- function F_MathLib(Table,String)
- -- sin, cos, tan, arcsin, arccos, arctan, square root, ceil, floor, degree, radian
- local Reference,Index = {
- {Func = "asin",Spell = {"a","s","i","n"}},
- {Func = "acos",Spell = {"a","c","o","s"}},
- {Func = "atan",Spell = {"a","t","a","n"}},
- {Func = "sin",Spell = {"s","i","n"}},
- {Func = "cos",Spell = {"c","o","s"}},
- {Func = "tan",Spell = {"t","a","n"}},
- {Func = "sqrt",Spell = {"s","q","r","t"}},
- {Func = "ceil",Spell = {"c","e","i","l"}},
- {Func = "floor",Spell = {"f","l","o","o","r"}},
- {Func = "deg",Spell = {"d","e","g"}},
- {Func = "rad",Spell = {"r","a","d"}},
- },nil
- for I = 1,table.getn(Reference) do
- if string.find(String,Reference[I].Func,1) then
- Index = I
- for K = 1,table.getn(Table) do
- if K > table.getn(Reference[I].Spell) then
- break
- else
- if Reference[I].Spell[K] ~= Table[K] then Index = nil break end
- end
- end
- end
- end
- if type(Index) == "number" then
- if table.getn(Reference[Index].Spell) ~= table.getn(Table) then
- local Value = ""
- for I = table.getn(Reference[Index].Spell) + 1,table.getn(Table) do
- Value = Value..""..Table[I]
- end
- return math[Reference[Index].Func](tonumber(Value))
- else
- ER_MESSAGE("expected number after '"..Reference[Index].Func.."'",2)
- end
- end
- -- factorial, http://www.codecodex.com/wiki/Calculate_the_factorial_of_a_number
- if string.find(String,"!",-1) then
- local F_Factorial = function(Number)
- if math.floor(Number) == Number then
- local Result = 1
- for Mul = 2,Number do
- Result = Result * Mul
- end
- return Result
- else
- ER_MESSAGE("expected an integer value",2)
- return nil
- end
- end
- local Value = ""
- for I = 1,table.getn(Table) - 1 do
- Value = Value..""..Table[I]
- end
- return F_Factorial(tonumber(Value))
- end
- -- Pi
- if String == "Pi" or String == "pi" then
- return math.pi
- end
- return nil
- end
- function F_ToggleSwitchBoolean(Var)
- local VariableType = type(F_ToVariable(Var))
- if VariableType ~= "boolean" then
- ER_MESSAGE("expected argument of type boolean, got "..VariableType,2)
- else
- SET_VARIABLES("_G ",Var,tostring(not F_ToVariable(Var)))
- end
- end
- function F_ToVariable(Item)
- local Type = type(Item)
- if Type == "table" or Type == "string" then
- if Type == "table" then
- return F_TableToVar(Item)
- end
- return _G[Item]
- end
- ER_MESSAGE("unexpected type '"..Type.."'",2)
- return nil
- end
- function F_ToString(Variable)
- local Type = type(Variable)
- if Type == "table" or Type == "string" then
- if Type == "table" then
- return F_TableToStr(Variable)
- end
- return Variable
- end
- ER_MESSAGE("unexpected type '"..Type.."'",2)
- return nil
- end
- function F_ImportTable(Table)
- local NewTable = {}
- if type(Table) == "table" then
- for i = 1,table.getn(Table) do
- table.insert(NewTable,Table[i])
- end
- return NewTable
- end
- ER_MESSAGE("expected argument of type table, got "..type(Table),2)
- return nil
- end
- function F_BooleanToString(Boolean)
- if Boolean then
- return "ON"
- end
- return "OFF"
- end
- -------------------------------------------------------------------------------
- -- Other utilities
- -------------------------------------------------------------------------------
- function F_CreateAnIndependentLoop(Loop)
- for _threadindex = 1,1000 do
- if type(_G["EXT_SCRIPT_".._threadindex]) ~= "function" then
- _G["EXT_SCRIPT_".._threadindex] = function()
- Loop()
- end
- CreateThread("EXT_SCRIPT_".._threadindex) break
- end
- end
- end
- function F_Wait(MS,Skippable)
- local Timer = GetTimer()
- if MS ~= 0 then
- while Timer + MS > GetTimer() do
- if Skippable and IBBP(7,0) then break end Wait(0)
- end
- else
- Wait(0)
- end
- end
- function ER_MESSAGE(Text,Duration)
- local T = GetTimer()
- while T + (Duration * 1000) > GetTimer() do
- CC_Print(Text,0,1) Wait(0)
- end
- end
- -------------------------------------------------------------------------------
- -- Key button
- -------------------------------------------------------------------------------
- function F_Navigate(tab,opt,prev,nxt,ctrl)
- if not IBP(9,0) then
- if F_Controller(prev,ctrl) or F_Scroll(prev,ctrl) then
- return F_Selection(tab,opt,0)
- elseif F_Controller(nxt,ctrl) or F_Scroll(nxt,ctrl) then
- return F_Selection(tab,opt,1)
- end
- end
- return opt
- end
- function F_Scroll(b,c)
- if IBP(b,c) then
- if gConsole.ScrollFaster + 800 <= GetTimer() then
- return true
- end
- end
- if IBBR(b,c) then
- gConsole.ScrollFaster = GetTimer()
- end
- return false
- end
- function F_Controller(b,c)
- if IBBP(b,c) then
- SoundPlay2D("ButtonDown")
- gConsole.ScrollFaster = GetTimer()
- return true
- end
- return false
- end
- function F_Selection(tab,var,pm)
- if pm == 1 then
- var = var + 1
- if var > table.getn(tab) then var = 1 end
- elseif pm == 0 then
- var = var - 1
- if var < 1 then var = table.getn(tab) end
- end
- return var
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement