Affichage des articles dont le libellé est Crosshair. Afficher tous les articles
Affichage des articles dont le libellé est Crosshair. Afficher tous les articles

lundi 10 mars 2014

[Source] Change crosshair color on low ammo topic




Has this been posted before? Who cares.
It's not fully optimized nor written pretty.
This only works perfect if you initially had cl_crosshaircolor 5.
If you want to use other cl_crosshaircolor's, you'll have to use something else to retrieve the colors (1-4 are hardcoded, easy as fuck).


Code:


//get local player
source_engine::CLocalPlayer* pLocalPlayer = (source_engine::CLocalPlayer*)
pClientEntityList->GetClientEntity(pEngineClient->GetLocalPlayerIndex());
if (!pLocalPlayer) return;

//get own weapon
source_engine::CBaseCombatWeapon* pOwnWeapon =
pClientEntityList->GetClientEntityFromHandle<source_engine::CBaseCombatWeapon*>(pLocalPlayer->GetActiveWeapon());
if (!pOwnWeapon) return;

//crosshair coloring
static bool bResetCrosshairColor = false;

std::string const sCmd[4] =
{
        "cl_crosshairalpha",
        "cl_crosshaircolor_r",
        "cl_crosshaircolor_g",
        "cl_crosshaircolor_b"
};

static source_engine::ConVar* pColorCvar[4];
for (int i = 0; i < 4; i++)
        pColorCvar[i] = pCVars->FindVar((char*)sCmd[i].c_str());

static float fCrosshairColorOrg[4];
static float fCrosshairColorSet[4] = { 255.f, 255.f, 0.f, 0.f };
static int iValueToTriggerColorSet = 5;

if (pOwnWeapon->GetAmmoFromClip1() <= iValueToTriggerColorSet)
{
        if (!bResetCrosshairColor)
        {
                for (int i = 0; i < 4; i++)
                        fCrosshairColorOrg[i] = pColorCvar[i]->GetFloat();

                pEngineClient->ClientCmd("cl_crosshaircolor 5");
                char szCommand[256];

                for (int i = 0; i < 4; i++)
                {
                        sprintf_s(szCommand, 256, "%s %f", sCmd[i].c_str(), fCrosshairColorSet[i]);
                        pEngineClient->ClientCmd(szCommand);
                }

                bResetCrosshairColor = true;
        }
}
else
{
        if (bResetCrosshairColor)
        {
                pEngineClient->ClientCmd("cl_crosshaircolor 5");
                char szCommand[256];

                for (int i = 0; i < 4; i++)
                {
                        sprintf_s(szCommand, 256, "%s %f", sCmd[i].c_str(), fCrosshairColorOrg[i]);
                        pEngineClient->ClientCmd(szCommand);
                }

                bResetCrosshairColor = false;
        }
}


Enjoy.





samedi 25 janvier 2014

[Coding] Moving crosshair externally topic




Hey I've been working on some external hacks from scratch and starting to get into aimbotting. I've encountered a problem where I'm unable to move my ingame crosshair using any type of SetPosition or Cursor.Position in C#, while it is working in any other desktop window.

Is it possible to move your crosshair without setting your view angle in memory as it is normally done?

Thanks in advance.