Eduardo_AC icon

[INC] Anti-Weapon/Ammo Hack (Hook) [Updated - 18/07/2017]

Eduardo_AC | PRO | 07/19/17 02:02:56 AM UTC | 0 ⭐ | 524 👁️ | Never ⏰ | []
Pawn |

7.18 KB

|

None

|

0 👍

/

0 👎

/*
    * CALLBACK'S
        - CheckPlayerWeaponHack(playerid)
        - OnPlayerWeaponHackDetected(playerid, detectionid, weaponid, ammo)
    ______________________________________________
 
    * STOCK'S
        - ACW_GivePlayerWeapon(playerid, weaponid, ammo)
        - ACW_SetPlayerWeaponAmmo(playerid, weaponid, ammo)
        - ACW_RemovePlayerWeapon(playerid, weaponid)
        - ACW_ResetPlayerWeapons(playerid)
    ______________________________________________
*/
// -- Macros
#define WEAPON_HACK_CHECK_TIME              (3) // Segundos
// ______________________________________________
// -- Variáveis do jogador
static
    dataWeapon[MAX_PLAYERS][13],
    dataAmmo[MAX_PLAYERS][13],
    dataTime[MAX_PLAYERS]
;
new
    serverAirVehicles[] =
    {
        417, 425, 447, 460, 469,
        476, 487, 488, 497, 511,
        512, 513, 519, 520, 548,
        553, 563, 577, 592, 593
    }
;
// ______________________________________________
// -- Forwards
forward CheckPlayerWeaponHack(playerid);
forward OnPlayerWeaponHackDetected(playerid, detectionid, weaponid, ammo);
// ______________________________________________
// -- Callback's
public OnPlayerUpdate(playerid)
{
    if(dataTime[playerid] < gettime())
    {
        dataTime[playerid] = gettime() + WEAPON_HACK_CHECK_TIME;
 
        CheckPlayerWeaponHack(playerid);
    }
 
    #if defined ACW_OnPlayerUpdate
        return ACW_OnPlayerUpdate(playerid);
    #else
        return true;
    #endif
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
    new
        getModel = GetVehicleModel(vehicleid)
    ;
 
    dataTime[playerid] += 1;
 
    for(new x = 0; x < sizeof serverAirVehicles; ++ x)
    {
        if(getModel == serverAirVehicles[x])
        {
            dataWeapon[playerid][11] = 46;
            dataAmmo[playerid][11] = 1;
 
            break;
        }
    }
 
    #if defined ACW_OnPlayerExitVehicle
        return ACW_OnPlayerExitVehicle(playerid, vehicleid);
    #else
        return true;
    #endif
}
public OnPlayerDeath(playerid, killerid, reason)
{
    ACW_ResetPlayerWeapons(playerid);
 
    #if defined ACW_OnPlayerDeath
        return ACW_OnPlayerDeath(playerid, killerid, reason);
    #else
        return true;
    #endif
}
public CheckPlayerWeaponHack(playerid)
{
    new
        w,
        a
    ;
 
    for(new x = 0; x < 13; ++ x)
    {
        GetPlayerWeaponData(playerid, x, w, a);
 
        if(dataWeapon[playerid][x] == 40)
        {
            if(dataWeapon[playerid][8] == 39) continue;
            else 
            {
                ACW_RemovePlayerWeapon(playerid, 40);
 
                continue;
            }
        }
 
        if(dataWeapon[playerid][x] != w)
        {
            if(dataWeapon[playerid][x] == 46)
            {
                if(w == 0)
                {
                    dataWeapon[playerid][x] = 0;
                    dataAmmo[playerid][x] = 0;
 
                    continue;
                }
            }
 
            if(dataWeapon[playerid][x] == 40)
            {
                if(dataWeapon[playerid][8]) continue;
            }
 
            OnPlayerWeaponHackDetected(playerid, 1, w, a);
        }
 
        if(a > dataAmmo[playerid][x]) OnPlayerWeaponHackDetected(playerid, 2, w, a);
        else dataAmmo[playerid][x] = a;
    }
 
    return true;
}
// ______________________________________________
// -- Stock's
stock ACW_GivePlayerWeapon(playerid, weaponid, ammo)
{
    ACW_RemovePlayerAmmo(playerid, weaponid);
 
    switch(weaponid)
    {
        case 0,1: 
        {
            dataWeapon[playerid][0] = weaponid;
            dataAmmo[playerid][0] = ammo;
        }
        case 2..9: 
        {
            dataWeapon[playerid][1] = weaponid;
            dataAmmo[playerid][1] = ammo;
        }
        case 22..24: 
        {
            dataWeapon[playerid][2] = weaponid;
            dataAmmo[playerid][2] = ammo;
        }
        case 25..27: 
        {
            dataWeapon[playerid][3] = weaponid;
            dataAmmo[playerid][3] = ammo;
        }
        case 28,29,32: 
        {
            dataWeapon[playerid][4] = weaponid;
            dataAmmo[playerid][4] = ammo;
        }
        case 30,31: 
        {
            dataWeapon[playerid][5] = weaponid;
            dataAmmo[playerid][5] = ammo;
        }
        case 33,34: 
        {
            dataWeapon[playerid][6] = weaponid;
            dataAmmo[playerid][6] = ammo;
        }
        case 35..38: 
        {
            dataWeapon[playerid][7] = weaponid;
            dataAmmo[playerid][7] = ammo;
        }
        case 16..18: 
        {
            dataWeapon[playerid][8] = weaponid;
            dataAmmo[playerid][8] = ammo;
        }
        case 39:
        {
            dataWeapon[playerid][8] = weaponid;
            dataAmmo[playerid][8] = ammo;
 
            //WEAPON_BOMB (Detonator)
            dataWeapon[playerid][12] = 40;
            dataAmmo[playerid][12] = ammo;
        }
        case 41..43: 
        {
            dataWeapon[playerid][9] = weaponid;
            dataAmmo[playerid][9] = ammo;
        }
        case 10..15: 
        {
            dataWeapon[playerid][10] = weaponid;
            dataAmmo[playerid][10] = ammo;
        }
        case 44..46: 
        {
            dataWeapon[playerid][11] = weaponid;
            dataAmmo[playerid][11] = ammo;
        }
        case 40: 
        {
            dataWeapon[playerid][12] = weaponid;
            dataAmmo[playerid][12] = ammo;
        }
        default: return false;
    }
 
    return GivePlayerWeapon(playerid, weaponid, ammo);
}
static stock ACW_RemovePlayerAmmo(playerid, weaponid)
{
    new
        w,
        a
    ;
 
    for(new x = 0; x < 13; ++ x)
    {
        GetPlayerWeaponData(playerid, x, w, a);
 
        if(w == weaponid)
        {
            GivePlayerWeapon(playerid, weaponid, -a);
 
            break;
        }
    }
 
    return true;
}
stock ACW_SetPlayerWeaponAmmo(playerid, weaponid, ammo)
{
    new
        w,
        a
    ;
 
    for(new x = 0; x < 13; ++ x)
    {
        GetPlayerWeaponData(playerid, x, w, a);
 
        if(w == weaponid)
        {
            GivePlayerWeapon(playerid, weaponid, -a);
            GivePlayerWeapon(playerid, weaponid, ammo);
 
            dataAmmo[playerid][x] = ammo;
 
            break;
        }
    }
 
    return true;
}
stock ACW_RemovePlayerWeapon(playerid, weaponid)
{
    new
        w[13],
        a[13]
    ;
 
    for(new x = 0; x < 13; ++ x)
    {
        GetPlayerWeaponData(playerid, x, w[x], a[x]);
    }
 
    ResetPlayerWeapons(playerid);
 
    for(new x = 0; x < 13; ++ x)
    {
        if(w[x] != weaponid)
        {
            GivePlayerWeapon(playerid, w[x], a[x]);
        }
        else if(w[x] == weaponid)
        {
            dataWeapon[playerid][x] = 0;
            dataAmmo[playerid][x] = 0;
        }
    }
 
    return true;
}
stock ACW_ResetPlayerWeapons(playerid)
{
    for(new x = 0; x < 13; ++ x)
    {
        dataWeapon[playerid][x] = 0;
        dataAmmo[playerid][x] = 0;
    }
    
    return ResetPlayerWeapons(playerid);
}
// ______________________________________________
// -- Hook's
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate ACW_OnPlayerUpdate
#if defined ACW_OnPlayerUpdate
    forward ACW_OnPlayerUpdate(playerid);
#endif
//
#if defined _ALS_OnPlayerExitVehicle
    #undef OnPlayerExitVehicle
#else
    #define _ALS_OnPlayerExitVehicle
#endif
#define OnPlayerExitVehicle ACW_OnPlayerExitVehicle
#if defined ACW_OnPlayerExitVehicle
    forward ACW_OnPlayerExitVehicle(playerid, vehicleid);
#endif
//
#if defined _ALS_OnPlayerDeath
    #undef OnPlayerDeath
#else
    #define _ALS_OnPlayerDeath
#endif
#define OnPlayerDeath ACW_OnPlayerDeath
#if defined ACW_OnPlayerDeath
    forward ACW_OnPlayerDeath(playerid, killerid, reason);
#endif
//
#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon ACW_GivePlayerWeapon
#if defined ACW_GivePlayerWeapon
    forward ACW_GivePlayerWeapon(playerid, weaponid, ammo);
#endif
//
#if defined _ALS_ResetPlayerWeapons
    #undef ResetPlayerWeapons
#else
    #define _ALS_ResetPlayerWeapons
#endif
#define ResetPlayerWeapons ACW_ResetPlayerWeapons
#if defined ACW_ResetPlayerWeapons
    forward ACW_ResetPlayerWeapons(playerid);
#endif

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎