Post: [C#] Set Clock + Timer
05-11-2014, 02:40 PM #1
Shark
Retired.
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys, another release today for BO2 Smile!
This one allows you to set timers and hud clocks!, so instead of doing a ghetto countdown timer you can make the game run a timer for you, like moveovertime and stuff, anyway lets get to the good stuff.

Pastebin Link: You must login or register to view this content.

The Code
    
public class HudStruct
{
public static uint
ElemIndex = Offsets.G_HudElems,
HudsLength = 0x88,
X = 0x00,
Y = 0x04,
Z = 0x08,
FontSize = 0xC,
fromFontScale = 0x10,
fontScaleStartTime = 0x14,
color = 0x18,
fromColor = 0x1C,
fadeStartTime = 0x20,
scaleStartTime = 0x24,
fromX = 0x28,
fromY = 0x2C,
moveStartTime = 0x30,
time = 0x34,
duration = 0x38,
value = 0x3C,
sort = 0x40,
glowColor = 0x44,
fxBirthTime = 0x48,
flags = 0x4C,
targetEntNum = 0x50,
fontScaleTime = 0x52,
fadeTime = 0x54,
label = 0x56,
Width = 0x58,
Height = 0x5A,
fromWidth = 0x5C,
fromHeight = 0x5E,
scaleTime = 0x60,
moveTime = 0x62,
text = 0x64,
fxLetterTime = 0x66,
fxDecayStartTime = 0x68,
fxDecayDuration = 0x6A,
fxRedactDecayStartTime = 0x6C,
fxRedactDecayDuration = 0x6E,
type = 0x70,
Font = 0x71,
alignOrg = 0x72,
alignScreen = 0x73,
materialIndex = 0x74,
offscreenMaterialIndex = 0x75,
fromAlignOrg = 0x76,
fromAlignScreen = 0x77,
soundID = 0x78,
ui3dWindow = 0x79,
flag2 = 0x7A,
clientOffset = 0x7C,
team = 0x80,
abilityFlag = 0x84;
}

public static UInt32 GetLevelTime()
{
public static uint
level_locals_t = 0x1608100,
LevelTime = level_locals_t + 0x798;

return Lib.ReadUInt32(LevelTime);
}

public static int SetTimer(UInt32 elemIndex, Int32 Time = 60, String Direction = "Up", Boolean Tenths = true)
{
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x8 && Direction == "Up" && !Tenths)
{ Lib.WriteByte(elemIndex + HudStruct.type, 0xA); }
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x8 && Direction == "Up" && Tenths)
{ Lib.WriteByte(elemIndex + HudStruct.type, 0xC); }
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x8 && Direction == "Down" && !Tenths)
{ Lib.WriteByte(elemIndex + HudStruct.type, 0x9); }
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x8 && Direction == "Down" && Tenths)
{ Lib.WriteByte(elemIndex + HudStruct.type, 0xB); }

if (Direction == "Up")
{ Lib.WriteInt32(elemIndex + HudStruct.time, (Int32)GetLevelTime() - (Time * 1000)); return (Int32)GetLevelTime() - (Time * 1000); }
if (Direction == "Down")
{ Lib.WriteInt32(elemIndex + HudStruct.time, (Int32)GetLevelTime() + (Time * 1000)); return (Int32)GetLevelTime() + (Time * 1000); }
return 0;
}

public static int SetClock(UInt32 elemIndex, Int32 Duration = 60, Int32 Time = 60, String Direction = "Up")
{
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x1 && Direction == "Up")
{ Lib.WriteByte(elemIndex + HudStruct.type, 0xE); }
if (Lib.ReadByte(elemIndex + HudStruct.type) != 0x1 && Direction == "Down")
{ Lib.WriteByte(elemIndex + HudStruct.type, 0xD); }
if (Direction == "Up")
{
Lib.WriteInt32(elemIndex + HudStruct.duration, Duration * 1000);
Lib.WriteInt32(elemIndex + HudStruct.time, (Int32)GetLevelTime() - (Time * 1000));
return (Int32)GetLevelTime() - (Time * 1000);
}
if (Direction == "Down")
{
Lib.WriteInt32(elemIndex + HudStruct.duration, Duration * 1000);
Lib.WriteInt32(elemIndex + HudStruct.time, (Int32)GetLevelTime() + (Time * 1000));
return (Int32)GetLevelTime() + (Time * 1000);
}
return 0;
}


How To Use
    
[B]SetTimer[/B]
-----------------------
SetTimer(elemIndex, Time, Direction, Tenths);

[B]SetClock[/B]
-----------------------
SetClock(elemIndex, Duration, Time, Direction);


In-Depth Explanation of The Args
    
[B]SetTimer[/B]
----------------------
elemIndex = The element you are applying a timer to (must be a text element)
Time = The time the timer starts from (example 60 = 1 minute)
Direction = "Up" or "Down", sets the direction the timer counts.
Tenths = If true the timer will show as 00.00.00 instead of 00.00

[B]SetClock[/B]
----------------------
elemIndex = The element you are applying a timer to (must be a shader)
Time = The time the clock takes to do a full circle
Duration = The speed the clock spins at
Direction = "Up" makes the clock count up, "Down" makes the clock countdown, when it reaches 0 it stops.
More information here (https://www.zeroy.com/script/hud/setclock.htm)


How To Know When The Timer/Clock Reaches 0 or A Selected Point
    
//In these examples I use timers but its the same thing for clocks.
[B]Example 1[/B]
--------------------
int Time = SetTimer(elemIndex, 60, "Down", false); //Set Timer At 1 Minute Counting Down
while (true)
{
if (GetLevelTime() == Time)
{
MessageBox.Show("Timer/Clock Reached 0");
break;
}
}

[B]Example 2[/B]
--------------------
int Time = SetTimer(elemIndex, 60, "", false); //Set Timer At 1 Minute Counting Down
while (true)
{
if (GetLevelTime() == (Time + 60000))//60,000 ms = 60 seconds
{
MessageBox.Show("Timer/Clock Reached 60 Seconds");
break;
}
}


Enjoy Ninja
(adsbygoogle = window.adsbygoogle || []).push({});

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

ALI ALHILFI, Asian, B777x, iMoDz-Baptiste, Mango_Knife, Notorious, smashedya, Hash847, Fatality, xxAussiefella69
05-11-2014, 03:02 PM #2
Fatality
1337 H4x0r
1st usefull thread i saw today Enzo
05-12-2014, 08:23 PM #3
CyberNomadic
Web Developer
All this and yet only one response wow. Good Job shark Winky Winky Thank You for your submission!
05-12-2014, 08:39 PM #4
SC58
Former Staff
Originally posted by NomadsBoy View Post
All this and yet only one response wow. Good Job shark Winky Winky Thank You for your submission!


They prob don't even know what it does lmao

The following user thanked SC58 for this useful post:

Hash847
05-12-2014, 08:56 PM #5
brooklyn77
I am error
Thanks heaps Shark! Great stuff. Now for my V.I.P Tools I can put a timer on so when the time runs out on trial run, they have to buy the activation code Happy
05-12-2014, 10:31 PM #6
Hash847
Purple God
Originally posted by brooklyn77 View Post
Thanks heaps Shark! Great stuff. Now for my V.I.P Tools I can put a timer on so when the time runs out on trial run, they have to buy the activation code Happy


brooklyn, once the game ends so does the timer so you'd have to detect whether the user is in game or not, then save the current time to a file somewhere (or on a server) plus your tool would most likely just have what every other fucking tool has, therefore you wont make much money off it.
05-12-2014, 10:32 PM #7
Hash847
Purple God
Originally posted by SC58 View Post
They prob don't even know what it does lmao


Shark releases this stuff knowing that no one will know how to use it, so he writes a example code for everyone to use.
05-13-2014, 11:44 AM #8
brooklyn77
I am error
I knew all that.
05-13-2014, 11:50 AM #9
smashedya
I’m too L33T
nice man keep ur good work up Snail

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo