Jump to content
  • 0

Help global and local


MANDO01

Question

is there's a way to access the "menu" outside the function like to make it global

Because i don't want to rewrite my script

 

gg.alert(menu[1])

function hack()

menu = gg.choice({'fly','car'})

if menu == nil then os.exit() end

if menu == 1 then gg.alert("fly") end

if menu == 2 then gg.alert("car") end

end

hack()

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

You can declare the variable outside 

local menu 

function hack()
  menu = gg.choice({'fly','car'})
  if menu == nil then os.exit() end
  if menu == 1 then gg.alert("fly") end
  if menu == 2 then gg.alert("car") end
end 

hack()
gg.alert(menu)

And remember gg.choice return a number or nil 

You can not use index on it like you did if you really wanna do that the solution will be to declare your item separately

local menu 
local item = {"fly", "car"}

function hack()
  menu = gg.choice(item)
  if menu == nil then os.exit() end
  if menu == 1 then gg.alert("fly") end
  if menu == 2 then gg.alert("car") end
end 

hack()
gg.alert(menu and item[menu])

 

Link to comment
Share on other sites

1 hour ago, MAARS said:

You can declare the variable outside 

local menu 

function hack()
  menu = gg.choice({'fly','car'})
  if menu == nil then os.exit() end
  if menu == 1 then gg.alert("fly") end
  if menu == 2 then gg.alert("car") end
end 

hack()
gg.alert(menu)

And remember gg.choice return a number or nil 

You can not use index on it like you did if you really wanna do that the solution will be to declare your item separately

local menu 
local item = {"fly", "car"}

function hack()
  menu = gg.choice(item)
  if menu == nil then os.exit() end
  if menu == 1 then gg.alert("fly") end
  if menu == 2 then gg.alert("car") end
end 

hack()
gg.alert(menu and item[menu])

 

Thanks but this not what I want

I'm making script on and off and i made

Something like task manager anything equal to on it will be in section

no = ' '
on = ' [  ON ]'
off = ' [ OFF  ]'
carfly = no
carflyv2 = no
undergroundcar = no
fastspawncar = no
function menu()
me = gg.choice({"str", "task manager","exit"})
if me == nil then else
if me == 1 then ch() end
if me == 2 then task() end
if me == 3 then os.exit() end
end
end
function ch()
RK = gg.multiChoice({
'CAR FLY'..carfly,
'CAR FLY V2'..carflyv2,
'UNDERGROUND CAR'..undergroundcar,
'FAST SPAWN CAR'..fastspawncar,
' BACK '}, nil, 'CAR HACK\n'..os.date('TODAY : [%F / %r]')..'')
if RK == nil then else
if RK[1] == true then 
if carfly == no then carfly = on elseif carfly == off then carfly = on else carfly = off  end end     -- car fly 
if RK[2] == true then
if carflyv2 == no then carflyv2 = on elseif carflyv2 == off then carflyv2 = on else carflyv2 = off  end end    -- car fly v2
if RK[3] == true then 
if undergroundcar == no then undergroundcar = on elseif undergroundcar == off then undergroundcar = on else undergroundcar = off  end end    -- underground car
if RK[4] == true then
if fastspawncar == no then fastspawncar = on elseif fastspawncar == off then fastspawncar = on else fastspawncar = off  end end     -- fast spawn car
if RK[5] == true then menu() end
end
end
function task()
if carfly == on then 
RK1 = '➼ CAR FLY'..carfly
elseif carfly == off then 
RK1 = gg.clearResults()
end
if carflyv2 == on then 
RK2 = '➼ CAR FLY V2'..carflyv2
elseif carflyv2 == off then 
RK2 = gg.clearResults()
end
if undergroundcar == on then 
RK3 = '➼ UNDERGROUND CAR'..undergroundcar
elseif undergroundcar == off then 
RK3 = gg.clearResults()
end
if fastspawncar == on then 
RK4 = '➼ FAST SPAWN CAR'..fastspawncar
elseif fastspawncar == off then 
RK4 = gg.clearResults()
end
kk = gg.multiChoice({RK1,RK2,RK3,RK4})
if kk == nil then else
if kk[1] == true then carfly = off end
if kk[2] == true then carflyv2 = off end
if kk[3] == true then undergroundcar = off end
if kk[4] == true then fastspawncar = off end
end
end
while true do
menu()
end

As you can see it works

But if you have alot of hacks like 20 i think

It will be so hard to do it

okay i did before but now i want to add more hacks

And i think if i can write RK[1] instead of RK1 i think it will be helpful 

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.