Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How use if else in this situation?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Wed Sep 06, 2017 2:55 pm    Post subject: How use if else in this situation? Reply with quote

Code:
function SearchChange(search, change);
aobs = AOBScan(search)
if (aobs == nil or aobs.Count < 0) then
return false
end
if(aobs ~= nil) then
j = stringlist_getCount(aobs);
for i = 1, j do
address=stringlist_getString(aobs,i-1);
for i = 1, string.len(change), 3 do
z = string.sub(change, i, i+2);
x, y = string.find(z, "%?+");
if (x == nil) then
script=[[
]]..address.."+"..(DEC_HEX((i-1)/3))..[[:
db ]]..z..[[
]]
autoAssemble(script); end end end
object_destroy(aobs);
aobs=nil
end end


function CEButton2Click(sender)
control_setCaption(FBE1_CEButton2, "10%")
search=("01 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 80 BF 00 00 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 16 15 C7 3F ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 7A 9E 71 A4 ?? ?? ?? ?? FF FF FF FF ")
control_setCaption(FBE1_CEButton2, "10%")
change=("01 00 00 02 00 00 00 E6 31 F0 17 E5 31 F0 17 4E 69 5E 68 63 69 5E 68 FF FF FF FF 00 00 80 BF 00 00 00 00 00")
SearchChange(search,change)
control_setCaption(FBE1_CEButton2, "ON")
beep()


end



hello guys I need a help with this doubt I want to make this cheat so that if it is not activated I can use the else and change the caption of the button to OFF but I do not know how to do it.



How I wish it worked

Code:
function CEButton2Click(sender)
control_setCaption(FBE1_CEButton2, "10%")
search=("01 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 80 BF 00 00 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 16 15 C7 3F ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 7A 9E 71 A4 ?? ?? ?? ?? FF FF FF FF ")
control_setCaption(FBE1_CEButton2, "10%")
change=("01 00 00 02 00 00 00 E6 31 F0 17 E5 31 F0 17 4E 69 5E 68 63 69 5E 68 FF FF FF FF 00 00 80 BF 00 00 00 00 00")
SearchChange(search,change)
control_setCaption(FBE1_CEButton2, "ON")
beep()
else
control_setCaption(FBE1_CEButton2, "OFF")
messageDialog("error failed",4,2);
end
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Sep 06, 2017 5:03 pm    Post subject: Reply with quote

have a variable that stores what the state is something like

Code:

CEButton2State = false -- presumably off at the start
function CEButton2Click(sender)
-- toggle state
CEButton2State = not CEButton2State
if(CEButton2State)
  ... -- do stuff for turning on
else
  ... -- do stuff for turning off
end


alternatively you could check the caption value and use that to determine what the new status should be (if you don't know how then watch a basic lua tutorial to find out, it's pretty simple but slightly harder than the variable shown above) or use a checkbox that already has a property you could access from the sender argument, I think it's called "Checked" but it's been awhile since I used one you could check in the form editor or the celua.txt file
Back to top
View user's profile Send private message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Wed Sep 06, 2017 5:24 pm    Post subject: Reply with quote

FreeER wrote:
have a variable that stores what the state is something like

Code:

CEButton2State = false -- presumably off at the start
function CEButton2Click(sender)
-- toggle state
CEButton2State = not CEButton2State
if(CEButton2State)
  ... -- do stuff for turning on
else
  ... -- do stuff for turning off
end


alternatively you could check the caption value and use that to determine what the new status should be (if you don't know how then watch a basic lua tutorial to find out, it's pretty simple but slightly harder than the variable shown above) or use a checkbox that already has a property you could access from the sender argument, I think it's called "Checked" but it's been awhile since I used one you could check in the form editor or the celua.txt file





Code:
function ExecuteHacks()
    Pause()
    HLS = listbox_getItemIndex(cyberGUI[15])
    LIST = listbox_getItems(cyberGUI[15])
    if HLS == -1 then return end
    i = HLS+1
    font=getProperty(cyberGUI[21], 'Font')
    control_setVisible(cyberGUI[18], false)
    control_setVisible(cyberGUI[19], false)
    control_setVisible(cyberGUI[20], false)
    control_setVisible(cyberGUI[21], true)
    control_setVisible(cyberGUI[22], false)
    if t[i][2]==nil then
         setProperty(font, 'Color', white)
         control_setCaption(cyberGUI[21], "You already enabled this hack !")
         unpause()
         return
    end
    control_setEnabled(cyberGUI[16], false)
    control_setEnabled(cyberGUI[17], false)

    control_setCaption(cyberGUI[21], "Executing hack...")
    control_setVisible(cyberGUI[22], true)
    control_setCaption(cyberGUI[22], '')
    control_setPosition(cyberGUI[22], 10, 250)
    strings_setString(LIST, HLS, t[i][1])
    processMessages()
    if TempSave[i][4] == 2 then
      Asm = autoAssemble(t[i][2])
      font=getProperty(cyberGUI[22], 'Font')
      control_setCaption(cyberGUI[21], "Executing hack. Finished.")
      unpause()
      if scanCheck~=true then
        TempText = t[i][1]..' - Failed'
        TempSave[i][5] = t[i][1]..' - Failed'
        strings_setString(LIST, HLS, TempText)
        setProperty(font, 'Color', red1)
        control_setCaption(cyberGUI[22], 'Failed to enable ')
        unpause()
 else
        TempText = t[i][1]..' - Enabled'
        TempSave[i][5] = t[i][1]..' - Enabled'
        strings_setString(LIST, HLS, TempText)
        setProperty(font, 'Color', green)
        control_setCaption(cyberGUI[22], 'Hack enabled. Enjoy it !')
unpause()
t[i][2] = nil
        TempSave[i][4] = 1
      end
    end
    if TempSave[i][4] == 0 then TempSave[i][4] = 2 end
    control_setEnabled(cyberGUI[16], true)
    control_setEnabled(cyberGUI[17], true)

end


Hello Friend. Thanks for answering. What I want to do is to have the button appear on if the aob was injected and OFF if it was not.
The way I'm using it anyway appears ON the end even though it has not activated.

I saw in this example that when activating it it says enable rather say said failed

Or if aob is written then ON else off
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Sep 06, 2017 10:06 pm    Post subject: Reply with quote

ah if it fails, hm, it looks like the SearchChange function you're using returns false if it fails to find the aob so check the result and if it's false then set it to OFF (or do nothing if you know it was already off) else set it to ON.

The example you gave uses the scanCheck variable but doesn't show where that's set (perhaps in the assembled script?) so...
Back to top
View user's profile Send private message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Thu Sep 07, 2017 3:15 pm    Post subject: Reply with quote

FreeER wrote:
ah if it fails, hm, it looks like the SearchChange function you're using returns false if it fails to find the aob so check the result and if it's false then set it to OFF (or do nothing if you know it was already off) else set it to ON.

The example you gave uses the scanCheck variable but doesn't show where that's set (perhaps in the assembled script?) so...


ok thanks a will see this. =)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites