Post: [SPRX] Timer for hooks (instead of using sleep)
07-16-2016, 02:29 AM #1
Swaqq
Professional Thanker
(adsbygoogle = window.adsbygoogle || []).push({}); Hello everyone, been working on a project, and needed a timer for my project so I made one. It's quite simple, and meant for hooking because you can't use sleeps.

Here is the struct to add to your header because we can't use classes Smile
    
struct Timer
{
void Start();
void Init(int ms);
void Reset();
bool Ready();
void Run(int Time);
bool running;
int interval;
int beginTime;
int time;
};



Here is the functions
    
void Timer::Start()
{
running = true;
}

void Timer::Init(int ms)
{
interval = ms;
}

bool Timer::Ready()
{
return time >= beginTime + interval;
}

void Timer::Reset()
{
beginTime = time;
}

void Timer::Run(int Time)
{
time = Time;
}


And to use it (Put this in your hook):
    
Timer timer; //Keep this outside your hook, put it in the globals
timer.Init(0.1);
timer.Start();
sys_time_sec_t t;
sys_time_get_current_time(&t, NULL);
timer.Run(t);
if(timer.Ready())
{
//do stuff
timer.Reset();
}



As you can see it's very simple to use. If you use this, please credit me and don't claim it as your own.
Permission to post this on other forums is denied.


CREDITS TO BITWISE FOR INVENTING C++
Last edited by Swaqq ; 07-17-2016 at 08:52 PM.

The following 11 users say thank you to Swaqq for this useful post:

2much4u, Basic_Code, DSG24, Father Luckeyy, K51, Kryptus, modzlife2000, ParadoxSPRX, Sabotage, TheGreenPlanet, UGz-
07-16-2016, 03:08 AM #2



Mine is better, scrub

The following 3 users say thank you to John for this useful post:

DSG24, filon1001, Right
07-16-2016, 03:40 AM #3
ParadoxSPRX
Do a barrel roll!
Ezpz, Too ghetto
07-16-2016, 04:27 AM #4
Swaqq
Professional Thanker
Originally posted by zExileModz View Post
Ezpz, Too ghetto


if it works, it works lol don't care about it being ghetto
07-17-2016, 01:48 PM #5
lmao pls credit me dis iz mah bist c0de pls dun cp wit no cridit I wil cri

The following user thanked Bitwise for this useful post:

mrtn
07-17-2016, 08:51 PM #6
Swaqq
Professional Thanker
Originally posted by Bitwise View Post
lmao pls credit me dis iz mah bist c0de pls dun cp wit no cridit I wil cri


ugh fine
07-20-2016, 04:56 PM #7
Originally posted by Swaqq View Post
ugh fine


.If you use this, please credit me and don't claim it as your own.
Permission to post this on other forums is denied.
07-20-2016, 05:13 PM #8
XenonLegend
Gym leader
Originally posted by Swaqq View Post

CREDITS TO BITWISE FOR INVENTING C++


true af
07-20-2016, 05:27 PM #9
ONESHOTMODZ
Save Point
i need a eboot anti bab bypass for ghost & black ops 2
09-28-2016, 09:45 AM #10
DSG24
Do a barrel roll!
so good!!!bro...

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo