Jump to content
RCPOLSKI

Prefix buttons (ON and OFF)

Recommended Posts

Wasup everyone, RCPOLSKI here.

In this topic you guys are about to learn how to create prefixes like [ON] and [OFF]

Why to use this? Well, you can keep you script menu clean and still use it for others things like showing results got by prompt (numbers, words, etc...)

 

There are 2 ways of doing it:

  • Calling and refreshing the stuff right on the menu
  • Creating a function that will be called after the cheat function being read

 

So then, let's go!

 

1. First you need to store the ON and OFF info as string and then set the function "cstatus" as off

on = '[ON]'
off = '[OFF]'
cstatus = off

 

2. Here we create our menu and set some things up...

- Before every button, if you're going to put the prefix, you'll need to put the string var created up there (Here is cstatus) then 2 dots (..) and finally your text

function main()
  menu = gg.choice({
    cstatus .. ' Some random trick', -- cstatus + .. and 'the text'
    'Exit'},
    nil,
    'Cheat menu')
  if menu == 1 then
    if cstatus == on then -- Checks if cstatus is [ON]
	  cstatus = off -- If yes, then sets it to [OFF]
	else
	  cstatus = on -- If it's not, then sets it to [ON]
	end
    doCheat()  -- After doing the check things, regardless of outcome it call the doCheat function
  elseif menu == 2 then
    os.exit()
end

3. As you are using vars with data stored in, you can also call 1 function only to enable and disable the cheat

function doCheat()
  if cstatus == on then -- Check if the cstatus is [ON]
    print('Cheat enabled!') -- If yes, then add the activation code here
  else
    print('Cheat disabled!') -- If it's not, then add the desactivation code here
  end
end

 

There is a lua script to download with both first and second method

Feel free to use the code!

Sorry for my english, still learning tho ?

Prefix Tutorial.lua

Edited by RCPOLSKI

Share this post


Link to post
Share on other sites

Hi,

Im stuck at second method.

Can you help me how to do it?

Share this post


Link to post
Share on other sites
Posted (edited)
local on = '[ON]'
local off = '[OFF]'
cstatus1 = off
cstatus2 = off
cstatus3 = off

function showmenu()
local choices = gg.choice({cstatus1..'A',cstatus2..'B',cstatus3..'C','EXIT'})

if choices == nil then
gg.toast("CANCELLED")
elseif  choices == 1 then

if cstatus1 == on then
    cstatus1 = off
    else
    cstatus1 = on 
    end
    
    if cstatus1 == on then
    gg.alert("DO ON A?")
    
    else
   gg.alert("DO OFF A?")
   
   
   end
   
   elseif  choices == 2 then

if cstatus2 == on then
    cstatus2 = off
    else
    cstatus2  = on 
    end
    
    if cstatus2 == on then
    --PUT YOUR CODE HERE =ON
    
    gg.alert("DO ON B?")
    
    else
    
    --PUT YOUR CODE HERE =OFF
   gg.alert("DO OFF B?")
   
   
   end
   elseif  choices == 3 then

if cstatus3 == on then
    cstatus3 = off
    else
    cstatus3 = on 
    end
    
    if cstatus3 == on then
    
      --PUT YOUR CODE HERE =ON
    gg.alert("DO ON C?")
    
    
    else
   gg.alert("DO OFF C?")
   
     --PUT YOUR CODE HERE =OFF
   
   end
   elseif choices == 4 then
   os.exit()--EXIT FROM SCRIPT
   
   
   end
   end
   
   gg.isVisible(true)
   while true do
  if gg.isVisible() then
    gg.setVisible(false)
    showmenu()
  else
    gg.sleep(100) 
    end
    end
6 hours ago, KomPo said:

Hi,

Im stuck at second method.

Can you help me how to do it?

local on = '[ON]'
local off = '[OFF]'
cstatus1 = off
cstatus2 = off
cstatus3 = off

function showmenu()
local choices = gg.choice({cstatus1..'A',cstatus2..'B',cstatus3..'C','EXIT'})

if choices == nil then
elseif  choices == 1 then

if cstatus1 == on then
    cstatus1 = off
    else
    cstatus1 = on 
    end
    
    if cstatus1 == on then
    gg.alert("DO ON A?")
    
    else
   gg.alert("DO OFF A?")
   
   
   end
   
   elseif  choices == 2 then

if cstatus2 == on then
    cstatus2 = off
    else
    cstatus2  = on 
    end
    
    if cstatus2 == on then
    --PUT YOUR CODE HERE =ON
    
    gg.alert("DO ON B?")
    
    else
    
    --PUT YOUR CODE HERE =OFF
   gg.alert("DO OFF B?")
   
   
   end
   elseif  choices == 3 then

if cstatus3 == on then
    cstatus3 = off
    else
    cstatus3 = on 
    end
    
    if cstatus3 == on then
    
      --PUT YOUR CODE HERE =ON
    gg.alert("DO ON C?")
    
    
    else
   gg.alert("DO OFF C?")
   
     --PUT YOUR CODE HERE =OFF
   
   end
   elseif choices == 4 then
   os.exit()--EXIT FROM SCRIPT
   
   
   end
   end
   
   while true do
  if gg.isVisible() then
    gg.setVisible(false)
    showmenu()
  else
    gg.sleep(100) 
    end
    end

 

Edited by Ioexception

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Rohil
      Hiiiii Everyone I Have Made A Telegram Group For GameGuardian In Which We Will Post New Script I Need Pros For The Group  We Will Clear Doubts Of Everyone I Will Make U Admin Who Is Pro Link @TopGEOYT
      LINK To Join :::
      https://t.me/joinchat/NUqTyRdVfIZp0gt2jxgc_w
      🔥 *We Provide Lua Encrypt And Decrypt Scripts And More That You Want  No Noobs Allowed Join If You Are Pro At Lua Scripting Or Coading  At GameGuardian
    • By Rama7772017
      View File Mega Script
      A collection of 25-game scripts is now available in English.
      Scenarios are taken from different authors. To make it a user. Unfortunately, not all authors are listed. As the script says, "Particularly kind to these people who had a lot of different scripts !"
      Link to my YouTube channel -  https://www.youtube.com/c/RamaProduction2
      Link to an open group in Telegram -  https://t.me/ramaproduction
      Link to the group in VKontakte - https://vk.com/rama_production2019
      Submitter Rama7772017 Submitted 08/28/2018 Category LUA scripts  
    • By Rama7772017
      A collection of 25-game scripts is now available in English.
      Scenarios are taken from different authors. To make it a user. Unfortunately, not all authors are listed. As the script says, "Particularly kind to these people who had a lot of different scripts !"
      Link to my YouTube channel -  https://www.youtube.com/c/RamaProduction2
      Link to an open group in Telegram -  https://t.me/ramaproduction
      Link to the group in VKontakte - https://vk.com/rama_production2019
    • By Glazed420x
      Here is a tutorial video for finding values using my script to find values and change them for many games..
      Here is the link for the topic below
      https://gameguardian.net/forum/topic/24573-search-different-value-types/
       
      1.Easy quick way you can search for what ever you want
      2.Helps So your SD card don't get filled with a bunch of scripts you don't really need.
      3.You can also break the code appart and create your own game mod menus..
      credits for it are included but their are still many more I have missed thank you and enjoy everyone.
      Notes..Not all games or values work I will update more to it in the future.
      Any questions feel free to hit me up
      Subscribe to my channel or follow for updates to all my stuff...don't forget to LIKE....☮️
×
×
  • Create New...