Jump to content

Recommended Posts

Posted

float *flashDuration = (float*)((DWORD)Base.gMe->BaseEnt() + (DWORD)0xFD8);

// We need this so if we get flashed while we're already flashed
// we can see if we got flashed again by checking to see if
// *flashDuration != lastDurationValue
// If that returns true then what we do is add on the newest *flashDuration
// to our timer.
static float lastDurationValue = *flashDuration; 

static float fakeDuration = -1.0f;
static bool set = false;

if((*flashDuration != 0.0f && !set)
|| lastDurationValue != *flashDuration)
{
lastDurationValue = *flashDuration;
fakeDuration += lastDurationValue;
set = true;
}

if(fakeDuration > 0.0f)
{
static float flNextReset = Base.gGlobals->curtime + 0.05f;

if(flNextReset <= Base.gGlobals->curtime)
{
	// When we get flashed a first time flNextReset doesn't change, but
	// when we get flashed a second time it tries to catch up to ->curtime.
	// Make sure that if the difference of the two is greater than 0.1 seconds
	// to reset our value to the default
	if(Base.gGlobals->curtime - flNextReset > 0.05f)
		flNextReset = Base.gGlobals->curtime + 0.05f;
	else
		flNextReset += 0.05f;
	fakeDuration -= 0.05f;
}

clamp(fakeDuration, 0, 9999);

float time = Base.gGlobals->curtime - fakeDuration;
time -= Base.gGlobals->curtime;

if(time < 0.0f)
{
	Base.gNeeded->DrawString(Base.gNeeded->hEspFont, gScreen.w / 2, 50, COLORCODE(255, 0, 0, 255), true, "You have been flashed for %2.1f seconds!", abs(time));

	Base.gMatSurface->DrawSetColor(RGBA(COLORCODE(235, 180, 0, 255)));
	Base.gMatSurface->DrawOutlinedRect((gScreen.w / 2) - 252, 98, (gScreen.w / 2) + 252, 112);

	float flRatio = 500 / abs(*flashDuration); // 500 is the width of our progress bar
	float flProgressSize = (abs(*flashDuration) - abs(time)) * flRatio;

	Base.gNeeded->FillRGBA((gScreen.w / 2) - 250, 100, (int)flProgressSize, 10, COLORCODE(255, 200, 0, 200));
}
}
else
{
fakeDuration = 0.0f;
*flashDuration = 0.0f;
set = false;
lastDurationValue = 0.0f;
}

 

1g6l4g.jpg

 

kangaroux

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


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock