Konu

#1
strafe engelleyici var tüm strafeleri engelliyor ancak  +left ve +right i kapatıyor  ve ateş edince xxxx oyuncu strafe kullanıyor şeklinde yazı atıyor normalde sadece strafe bastıklarında bu yazıyı atıyordu şimdi ateş edenleride strafe oalrak algılıyor saydan yazı geçiyor. bunu düzeltebilirmiyiz veya strafe engelleyici yapabilirmiyiz.

Kod:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

#define PLUGIN "StrafeHack Detector"
#define VERSION "0.1"
#define AUTHOR "Mistrick"

#pragma semicolon 1

const PITCH = 0;
const YAW = 1;

const LEFT = 1;
const RIGHT = 2;

stock const m_afButtonPressed = 246;
stock const m_afButtonReleased = 247;
stock const m_pPlayer = 41;
stock const XO_CBASEPLAYER = 5;
stock const XO_CBASEPLAYERWEAPON = 4;

#define LOGFILE "strafehack_detector.log"

#define MIN_LOG_TIME 3.0
#define MAX_BADFRAMES 5
#define MAX_KEYWARNING 5
#define MAX_STRAFES 16
#define STRAFE_CHECK_TIME 0.2
#define MAX_ANGLE_CHECK 90.0
#define MIN_STRAFE_ANGLE_DIFF 1.0
#define MAX_STRAFE_ANGLE_WARNINGS 15
#define MIN_STRAFE_ANGLE_WARNINGS_TO_LOG 5
#define IGNORE_TIME 0.5

enum _:PLAYER_DATA
{
    m_BadFrame,
    m_Strafes,
    m_WarningStrafeAngle,
    Float:m_fLastStrafeCheck,
    Float:m_fLastWeaponDeploy
};
new g_ePlayerInfo[33][PLAYER_DATA];

enum _:LOG_DATA
{
    Float:m_LastForwardMoveLog,
    Float:m_LastSideMoveLog,
    Float:m_LastValueLog,    
    Float:m_LastKeyLog,
    Float:m_LastStrafeAngleLog,
    Float:m_LastChatLog,
    m_CountForwardMoveLog,
    m_CountSideMoveLog,
    m_CountValueLog,    
    m_CountKeyLog,
    m_CountStrafeAngleLog,
    m_CountChatLog
};
new g_ePlayerLog[33][LOG_DATA];

enum _:KEYS
{
    KEY_W, KEY_S, KEY_A, KEY_D
}
enum _:BUTTONS_DATA
{
    BUTTON, KEY
}
new g_ePlayerButtons[][BUTTONS_DATA] =
{
    {IN_FORWARD, KEY_W}, {IN_BACK, KEY_S}, {IN_MOVELEFT, KEY_A}, {IN_MOVERIGHT, KEY_D}
};
new g_szKeyName[KEYS][] =
{
    "[W]", "[S]", "[A]", "[D]"
};
new g_iKeyFrames[33][KEYS], g_iOldKeyFrames[33][KEYS], g_iKeyWarning[33][KEYS];

new Float:g_fOldAngles[33][3];
new g_iOldTurning[33];
new Float:g_fOldStrafeAngles[33][3];
new Float:g_fOldAnglesDiff[33];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    
    register_forward(FM_CmdStart, "FM_CmdStart_Pre", false);
    register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_Pre", false);
    
    for(new iId = CSW_P228, szWeaponName[32]; iId <= CSW_P90; iId++)
    {
        if(get_weaponname(iId, szWeaponName, charsmax(szWeaponName)))
        {
            RegisterHam(Ham_Item_Deploy, szWeaponName, "Ham_Item_Deploy_Pre", false);
        }
    }
}
public Ham_Item_Deploy_Pre(weapon)
{
    new id = get_pdata_cbase(weapon, m_pPlayer, XO_CBASEPLAYERWEAPON);
    g_ePlayerInfo[id][m_fLastWeaponDeploy] = _:get_gametime();
}
public FM_CmdStart_Pre(id, uc_handle, seed)
{
    if(!is_user_alive(id)) return FMRES_IGNORED;
    
    new Float:fForwardMove; get_uc(uc_handle, UC_ForwardMove, fForwardMove);
    new Float:fSideMove; get_uc(uc_handle, UC_SideMove, fSideMove);
        
    if(fForwardMove == 0.0 && fSideMove == 0.0) return FMRES_IGNORED;
    
    new Float:fTime = get_gametime();
    
    if(fTime < g_ePlayerInfo[id][m_fLastWeaponDeploy] + IGNORE_TIME) return FMRES_IGNORED;
    
    new bBlockSpeed = false;
    
    new bButtons = get_uc(uc_handle, UC_Buttons);    
    
    new Float:fAngles[3]; pev(id, pev_angles, fAngles);
    new Float:fAnglesDiff[3]; vec_diff(fAnglesDiff, fAngles, g_fOldAngles[id]);
    
    new Float:fValue = floatsqroot(fForwardMove * fForwardMove + fSideMove * fSideMove);
    
    if(!(equal_null(fAnglesDiff) && fValue > 115.0))
    {
        // forwardmove without button
        if((fForwardMove > 0.0 && ~bButtons & IN_FORWARD || fForwardMove < 0.0 && ~bButtons & IN_BACK) && fAnglesDiff[PITCH] != 0.0)
        {
            bBlockSpeed = true;
            if(fTime >= g_ePlayerLog[id][m_LastForwardMoveLog])
            {
                g_ePlayerLog[id][m_LastForwardMoveLog] = _:(fTime + MIN_LOG_TIME);
                UTIL_LogUser(id, "CheatMoves: [%d] forward move without button[%.1f]", g_ePlayerLog[id][m_CountForwardMoveLog], fForwardMove);
                g_ePlayerLog[id][m_CountForwardMoveLog] = 0;
            }
            g_ePlayerLog[id][m_CountForwardMoveLog]++;
        }
        // sidemove without button
        if(fSideMove > 0.0 && ~bButtons & IN_MOVERIGHT || fSideMove < 0.0 && ~bButtons & IN_MOVELEFT)
        {
            bBlockSpeed = true;
            if(fTime >= g_ePlayerLog[id][m_LastSideMoveLog])
            {
                g_ePlayerLog[id][m_LastSideMoveLog] = _:(fTime + MIN_LOG_TIME);
                UTIL_LogUser(id, "CheatMoves: [%d] side move without button[%.1f]", g_ePlayerLog[id][m_CountSideMoveLog], fSideMove);
                g_ePlayerLog[id][m_CountSideMoveLog] = 0;
            }
            g_ePlayerLog[id][m_CountSideMoveLog]++;
        }
    }
    
    new Float:fMaxSpeed = get_user_maxspeed(id);
    
    // value can't be more maxspeed
    if(fValue > fMaxSpeed && fMaxSpeed > 100.0)
    {
        bBlockSpeed = true;
        if(fTime >= g_ePlayerLog[id][m_LastValueLog])
        {
            g_ePlayerLog[id][m_LastValueLog] = _:(fTime + MIN_LOG_TIME);
            UTIL_LogUser(id, "CheatMoves: [%d] value[%.1f], fw[%.1f], sd[%.1f], maxspeed[%.1f]", g_ePlayerLog[id][m_CountValueLog], fValue, fForwardMove, fSideMove, fMaxSpeed);
            g_ePlayerLog[id][m_CountValueLog] = 0;
        }
        g_ePlayerLog[id][m_CountValueLog]++;
    }
    
    // block scripts with +right, +left
    if(bButtons & (IN_LEFT | IN_RIGHT))
    {
        bBlockSpeed = true;
    }
    
    fForwardMove = floatabs(fForwardMove);
    fSideMove = floatabs(fSideMove);
    
    // cl_forwardspeed != cl_sidespeed
    if(fForwardMove && fSideMove && fForwardMove != fSideMove)
    {
        if(++g_ePlayerInfo[id][m_BadFrame] >= MAX_BADFRAMES)
        {            
            bBlockSpeed = true;
            g_ePlayerInfo[id][m_BadFrame] = 0;
        }
    }
    else
    {
        g_ePlayerInfo[id][m_BadFrame] = 0;
    }
    
    new iTurning = 0;    
    new Float:fDiff = fAngles[YAW] - g_fOldAngles[id][YAW];
    
    if(fDiff >= 180.0) fDiff -= 360.0;
    if(fDiff < -180.0) fDiff += 360.0;
    
    
    if(fDiff < 0.0)
    {
        iTurning = RIGHT;
        if(g_iOldTurning[id] == LEFT)
        {
            g_ePlayerInfo[id][m_Strafes]++;
            StrafeForward(id, fAngles);
        }
    }
    else if(fDiff > 0.0)
    {
        iTurning = LEFT;
        if(g_iOldTurning[id] == RIGHT)
        {
            g_ePlayerInfo[id][m_Strafes]++;
            StrafeForward(id, fAngles);
        }
    }
    
    if(fTime >= g_ePlayerInfo[id][m_fLastStrafeCheck])
    {        
        if(g_ePlayerInfo[id][m_Strafes] >= MAX_STRAFES)
        {
            bBlockSpeed = true;            
            UTIL_LogUser(id, "CheatStrafes: %d strafes in %.1f sec", g_ePlayerInfo[id][m_Strafes], STRAFE_CHECK_TIME);
        }
        g_ePlayerInfo[id][m_Strafes] = 0;
        g_ePlayerInfo[id][m_fLastStrafeCheck] = _:(fTime + STRAFE_CHECK_TIME);
    }
    
    g_iOldTurning[id] = iTurning;
    
    
    if(bBlockSpeed)
    {
        new Float:fVelocity[3]; pev(id, pev_velocity, fVelocity);
        fVelocity[0] *= 0.2; fVelocity[1] *= 0.2;
        set_pev(id, pev_velocity, fVelocity);
    }
    
    g_fOldAngles[id] = fAngles;
    
    return FMRES_IGNORED;
}
public FM_PlayerPreThink_Pre(id)
{
    if(!is_user_alive(id)) return FMRES_IGNORED;
        
    new bBlockSpeed = false;
    
    new bButtons = pev(id, pev_button);
    new bOldButton = pev(id, pev_oldbuttons);
    
    for(new i; i < sizeof(g_ePlayerButtons); i++)
    {
        new CheckButton = g_ePlayerButtons[i][BUTTON];
        new CheckKey = g_ePlayerButtons[i][KEY];
        
        if(bButtons & CheckButton)
        {
            g_iKeyFrames[id][CheckKey]++;
        }
        
        if(~bButtons & CheckButton && bOldButton & CheckButton)
        {
            if(g_iKeyFrames[id][CheckKey] == g_iOldKeyFrames[id][CheckKey])
            {
                if(g_iKeyFrames[id][CheckKey] == 1) g_iKeyWarning[id][CheckKey]++;
                
                if(++g_iKeyWarning[id][CheckKey] >= MAX_KEYWARNING)
                {
                    bBlockSpeed = true;
                    g_iKeyWarning[id][CheckKey] = 0;
                    
                    new Float:fTime = get_gametime();
                    
                    if(fTime >= g_ePlayerLog[id][m_LastKeyLog])
                    {
                        g_ePlayerLog[id][m_LastKeyLog] = _:(fTime + MIN_LOG_TIME);
                        UTIL_LogUser(id, "CheatKeys: [%d] keyframe agreement[%d], key %s", g_ePlayerLog[id][m_CountKeyLog], g_iKeyFrames[id][CheckKey], g_szKeyName[CheckKey]);
                        g_ePlayerLog[id][m_CountKeyLog] = 0;
                    }
                    g_ePlayerLog[id][m_CountKeyLog]++;
                }            
            }
            else if(g_iKeyWarning[id][CheckKey])
            {
                g_iKeyWarning[id][CheckKey]--;
            }
            //console_print(id, "key frame %s is %d, warn [%d]", g_szKeyName[CheckKey], g_iKeyFrames[id][CheckKey], g_iKeyWarning[id][CheckKey]);
            g_iOldKeyFrames[id][CheckKey] = g_iKeyFrames[id][CheckKey];
            g_iKeyFrames[id][CheckKey] = 0;
        }
    }
    
    if(bBlockSpeed)
    {
        new Float:fVelocity[3]; pev(id, pev_velocity, fVelocity);
        fVelocity[0] *= 0.2; fVelocity[1] *= 0.2;
        set_pev(id, pev_velocity, fVelocity);
    }
    
    return FMRES_IGNORED;
}
StrafeForward(id, Float:angles[3])
{
    new Float:fAnglesDiff[3]; vec_diff(fAnglesDiff, angles, g_fOldStrafeAngles[id]);
    
    if(fAnglesDiff[YAW] >= 180) fAnglesDiff[YAW] -= 360.0;
    if(fAnglesDiff[YAW] < -180) fAnglesDiff[YAW] += 360.0;    
    
    fAnglesDiff[YAW] = floatabs(fAnglesDiff[YAW]);
    
    //console_print(id, "strafe angle diff %f, old angle diff %f, turning [%d]", fAnglesDiff[YAW], g_fOldAnglesDiff[id], turning);
    
    if(fAnglesDiff[YAW] < MAX_ANGLE_CHECK)
    {
        new Float:fDiff = floatabs(fAnglesDiff[YAW] - g_fOldAnglesDiff[id]);
        new iOldWarn = g_ePlayerInfo[id][m_WarningStrafeAngle];
        
        if( fDiff < 0.1 )
        {
            g_ePlayerInfo[id][m_WarningStrafeAngle] += 5;
        }
        else if( fDiff < MIN_STRAFE_ANGLE_DIFF )
        {
            g_ePlayerInfo[id][m_WarningStrafeAngle]++;
        }
        else if(g_ePlayerInfo[id][m_WarningStrafeAngle])
        {
            g_ePlayerInfo[id][m_WarningStrafeAngle]--;
        }
        
        new Float:fTime = get_gametime();
        
        if(g_ePlayerInfo[id][m_WarningStrafeAngle] > iOldWarn)
        {            
            //console_print(id, " time %f, last time %f, count %d", fTime, g_ePlayerLog[id][m_LastStrafeAngleLog], g_ePlayerLog[id][m_CountStrafeAngleLog]);
            if( fTime <= g_ePlayerLog[id][m_LastStrafeAngleLog] + MIN_LOG_TIME)
            {
                if(++g_ePlayerLog[id][m_CountStrafeAngleLog] >= MIN_STRAFE_ANGLE_WARNINGS_TO_LOG)
                {
                    UTIL_LogUser(id, "CheatStrafes: diff %f, cur angle %f, old angle %f", fDiff, fAnglesDiff[YAW], g_fOldAnglesDiff[id]);
                }
            }
            else
            {
                g_ePlayerLog[id][m_CountStrafeAngleLog] = 0;
            }
            g_ePlayerLog[id][m_LastStrafeAngleLog] = _:fTime;
        }
        
        if(g_ePlayerInfo[id][m_WarningStrafeAngle] >= MAX_STRAFE_ANGLE_WARNINGS)
        {
            if(fTime >= g_ePlayerLog[id][m_LastChatLog])
            {
                g_ePlayerLog[id][m_LastChatLog] = _:(fTime + MIN_LOG_TIME);
                PunishPlayer(id, "StrafeMacros");
                UTIL_LogUser(id, "Strafe: [%d] Strafe Kullaniyor", g_ePlayerLog[id][m_CountChatLog]);
                g_ePlayerLog[id][m_CountChatLog] = 0;
            }
            g_ePlayerLog[id][m_CountChatLog]++;
            g_ePlayerInfo[id][m_WarningStrafeAngle] = 0;
        }
    }
    
    g_fOldAnglesDiff[id] = fAnglesDiff[YAW];
    g_fOldStrafeAngles[id] = angles;
}
vec_diff(Float:vec[3], Float:new_vec[3], Float:old_vec[3])
{
    vec[0] = new_vec[0] - old_vec[0];
    vec[1] = new_vec[1] - old_vec[1];
    vec[2] = new_vec[2] - old_vec[2];
}
equal_null(Float:vec[3])
{
    return (vec[0] == 0.0 && vec[1] == 0.0) ? true : false;
}
stock PunishPlayer(id, reason[])
{
    new szName[32]; get_user_name(id, szName, charsmax(szName));
    client_print(0, print_chat, "[StrafeDedektor] %s Strafe Kullaniyor.", szName, reason);
}
stock UTIL_LogUser(const id, const szCvar[], any:...)
{
    static szLogFile[128];
    if(!szLogFile[0])
    {
        get_localinfo("amxx_logs", szLogFile, charsmax(szLogFile));
        format(szLogFile, charsmax(szLogFile), "/%s/%s", szLogFile, LOGFILE);
    }
    new iFile;
    if( (iFile = fopen(szLogFile, "a")) )
    {
        new szName[32], szAuthid[32], szIp[32], szTime[22];
        new message[128]; vformat(message, charsmax(message), szCvar, 3);
        
        get_user_name(id, szName, charsmax(szName));
        get_user_authid(id, szAuthid, charsmax(szAuthid));
        get_user_ip(id, szIp, charsmax(szIp), 1);
        get_time("%m/%d/%Y - %H:%M:%S", szTime, charsmax(szTime));
        
        fprintf(iFile, "L %s: <%s><%s><%s> %s^n", szTime, szName, szAuthid, szIp, message);
        fclose(iFile);
    }
}

#2
Aşağıda vereceğim kodu silerseni "+left" ve "+right" düzelir ancak diğerleri için kalıcı bir çözüm bulamayız.

Kod:
// block scripts with +right, +left
    if(bButtons & (IN_LEFT | IN_RIGHT))
    {
        bBlockSpeed = true;
    }

#3
Teşekkürler Çözülmüş İsteklere Taşıyabilirsiniz.
Son Düzenleme: 02-02-2020, 21:52, Düzenleyen: Kell_Adam.
#4
Konunuz "Çözülmüş İsteklere" taşınmıştır.

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task
Kayıt Ol