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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • 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