Jump to content
  • 0

Need help pls


YeetMeister

Question

hello,

i need help with this function here

so the idea is, when i check for example FoV it will first search the value and save it to the table and then automatically check the "[DO NOT CHECK] FoV Value",

and now i want to press fov again and it will check if "[DO NOT CHECK] FoV Value" is checked and it will proceed to the FoV() function

but i end up with an error and i dont know how to fix it

"Script ended:
Script error: luaj.LuaError: load /storage/emulated/0/Download/Lua/Scripts/My Scripts/CriticalOpsTrainer.lua: luaj.LuaError: /storage/emulated/0/Download/Lua/Scripts/My Scripts/CriticalOpsTrainer.lua:87
`pm[4] == true`
syntax error near '=='
    at luaj.LuaValue.error(LuaValue.java:1083)
    at luaj.Globals.loadfile(Globals.java:219)
    at android.ext.Script.runScript(Script.java:5244)
    at android.ext.Script$ScriptThread.run(Script.java:5081)
Caused by: luaj.LuaError: /storage/emulated/0/Download/Lua/Scripts/My Scripts/CriticalOpsTrainer.lua:87
`pm[4] == true`
syntax error near '=='
    at luaj.compiler.LexState.lexerror(LexState.java:289)
    at luaj.compiler.LexState.syntaxerror(LexState.java:293)
    at luaj.compiler.LexState.check_condition(LexState.java:878)
    at luaj.compiler.LexState.exprstat(LexState.java:2045)
    at luaj.compiler.LexState.statement(LexState.java:2139)
    at luaj.compiler.LexState.statlist(LexState.java:2156)
    at luaj.compiler.LexState.body(LexState.java:1315)
    at luaj.compiler.LexState.funcstat(LexState.java:2029)
    at luaj.compiler.LexState.statement(LexState.java:2112)
    at luaj.compiler.LexState.statlist(LexState.java:2156)
    at luaj.compiler.LexState.block(LexState.java:1655)
    at luaj.compiler.LexState.whilestat(LexState.java:1798)
    at luaj.compiler.LexState.statement(LexState.java:2094)
    at luaj.compiler.LexState.statlist(LexState.java:2156)
    at luaj.compiler.LexState.mainfunc(LexState.java:2172)
    at luaj.compiler.LuaC$CompileState.luaY_parser(LuaC.java:129)
    at luaj.compiler.LuaC.compile(LuaC.java:99)
    at luaj.Globals.compilePrototype(Globals.java:278)
    at luaj.Globals.loadPrototype(Globals.java:265)
    at luaj.Globals.load(Globals.java:231)
    at luaj.Globals.loadfile(Globals.java:213)
    ... 2 more"

can someone help me or Improove the code?

thanks in advance.

"function playerMenu()
  local pm = gg.prompt({
    "FoV",
    "Crosshair Always Visible",
    "Chams",
    "[DO NOT CHECK] FoV Value",
    "[DO NOT CHECK] Crosshair Value",
    "[DO NOT CHECK] Chams Value"
    }, nil, {"checkbox", "checkbox", "checkbox", "checkbox", "checkbox", "checkbox"},{[1]=false, [2]=false, [3]=false, [4]=false, [5]=false, [6]=false})
if pm[1] == true
  and
   pm[4] == false
  then
    fovS()
  end
if pm[1] == true
  and
   pm[4] == true
  then
   FoV()
  end
if pm[2] == true
  and
   pm[5] == false
  then
    crosshairS()
  end
if pm[2] == true
  and
   pm[5] == true
  then
   crosshair()
  end
if pm[3] == true
  and
   pm[6] == false
  then
    chamsS()
  end
if pm[3] == true
  and
   pm[6] == true
  then
   Chams()
  end
  UI =-1
end

function fovS()
gg.toast("test")
pm[4] == true
playerMenu()
end

function FoV()
gg.toast("test")
end

function crosshairS()
gg.toast("test")
pm[5] == true
playerMenu()
end

function crosshair()
gg.toast("test")
end

function chamsS()
gg.toast("test")
pm[6] == true
playerMenu()
end

function Chams()
gg.toast("test")
end"

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

8 hours ago, YeetMeister said:

so the idea is, when i check for example FoV it will first search the value and save it to the table and then automatically check the "[DO NOT CHECK] FoV Value",

and now i want to press fov again and it will check if "[DO NOT CHECK] FoV Value" is checked and it will proceed to the FoV() function

There is no reason in creating checkboxes that will be displayed in prompt window, if the user is not supposed to change their state.

If you need to perform one action when checkbox is checked for the first time and another action otherwise, you can use a variable that will indicate, whether the checkbox was checked at least once.

Example: 

local option1Checked = false

-- Will be executed once when the checkbox is checked for the first time
local function option1Setup()
  gg.toast('Option 1 was checked for the first time')
end

-- Will be executed when the checkbox is checked for the second, third, fourth, etc time
local function option1Loop()
  gg.toast('Option 1 was checked')
end

local function menu()
  local choice = gg.prompt({'Option 1'}, {false}, {'checkbox'})
  if choice ~= nil then
    if choice[1] then
      if not option1Checked then
        option1Setup()
        option1Checked = true
      else
        option1Loop()
      end
    end
  end
end

while true do
  if gg.isVisible() then
    gg.setVisible(false)
    menu()
  end
  gg.sleep(100)
end

checkbox_example.lua

Link to comment
Share on other sites

pm is table [4] is index of table.

== is relational operator which is using to test for equality.

There is a lot of mistakes in your code, one of them is pm[4] == true. I am not good write the code, but maybe example below usefull for your code.

while true do
  local pm = gg.prompt({
    "FoV",
    "Crosshair Always Visible",
    "Chams",
    "[DO NOT CHECK] FoV Value",
    "[DO NOT CHECK] Crosshair Value",
    "[DO NOT CHECK] Chams Value"
    }, nil, {"checkbox", "checkbox", "checkbox", "checkbox", "checkbox", "checkbox"},{[1]=false, [2]=false, [3]=false, [4]=false, [5]=false, [6]=false})

if not pm then break end

if pm[1] == false then
p1 = uncheck
else
p1 = check
end
if pm[2] == false then
p2 = uncheck
else
p2 = check
end
if pm[3] == false then
p3 = uncheck
else
p3 = check
end
if pm[4] == false then
p4 = uncheck
else
p4 = check
end
if pm[5] == false then
p5 = uncheck
else
p5 = check
end
if pm[6] == false then
p6 = uncheck
else
p6 = check
end

function fovS()
gg.toast("test")
p4 = check
end

function FoV()
gg.toast("test")
end

function crosshairS()
gg.toast("test")
p5 = check
end

function crosshair()
gg.toast("test")
end

function chamsS()
gg.toast("test")
p6 = check
end

function Chams()
gg.toast("test")
end

if pm[1] == true and p4 == uncheck then
fovS()

elseif pm[1] == true and p4 == check then
FoV()

elseif pm[2] == true and p5 == uncheck then
crosshairS()

elseif pm[2] == true and p4 == check then
crosshair()

elseif pm[3] == true and p6 == uncheck then
chamS()

elseif pm[3] == true and p6 == check then
chams()
end

end

 

 

Link to comment
Share on other sites

Maybe can help to improve your script, sorry if doesn't help

st = {false, false, false, false, false, false}

function playerMenu()
local pm = gg.prompt({"FoV", "Crosshair Always Visible", "Chams", "[DO NOT CHECK] FoV Value", "[DO NOT CHECK] Crosshair Value", "[DO NOT CHECK] Chams Value"}, st, {"checkbox", "checkbox", "checkbox", "checkbox", "checkbox", "checkbox"})
if pm == nil then os.exit() end
if pm[1] == true then
if pm[4] == true then
-- Deactive
gg.toast("Test", true)
st[4] = false
else
-- Active
gg.toast("Test", true)
st[4] = true
end
end
if pm[2] == true then
if pm[5] == true then
-- Deactive
gg.toast("Test", true)
st[5] = false
else
-- Active
gg.toast("Test", true)
st[5] = true
end
end
if pm[3] == true then
if pm[6] == true then
-- Deactive
gg.toast("Test", true)
st[6] = false
else
-- Active
gg.toast("Test", true)
st[6] = true
end
end
playerMenu()
end

while true do
if gg.isVisible() then
 gg.setVisible(false)
 playerMenu()
else
 gg.sleep(100)
end
end

 

test.lua

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.