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 to make a counter into a trainer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
0Bx
How do I cheat?
Reputation: 0

Joined: 01 Jun 2021
Posts: 5

PostPosted: Sun Mar 27, 2022 6:16 pm    Post subject: How to make a counter into a trainer? Reply with quote

I want to make a timer that displays the time that the trainer has been
on? How could I achieve this?

EXAPMLE

Time in trainer: 1 m 49 sec

OR

Time in trainer: 2306 seconds

etc. Practically anything is good : )
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4722

PostPosted: Sun Mar 27, 2022 7:07 pm    Post subject: Reply with quote

Create a label and write to the label's Caption property

To get the time, use os.time() and os.difftime()
Code:
local trainer_start_time = os.time()

function UDF1_CETimer1Timer(sender)
  local current_time = os.time()
  local time_since_on = os.difftime(current_time, trainer_start_time)

  local seconds = time_since_on % 60
  local minutes = (time_since_on // 60) % 60
  local hours = (time_since_on // 60 // 60) % 24
  local days = time_since_on // 60 // 60 // 24

  local t = {}
  if days > 0 then
    t[#t+1] = ('%d days '):format(days)
  end
  if days > 0 or hours > 0 then
    t[#t+1] = ('%02d:'):format(hours)
  end
  t[#t+1] = ('%02d:%02d'):format(minutes, seconds)
  UDF1.CELabel1.Caption = table.concat(t,'')
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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