Weapon Anticheat
#1

I have already created a custom function for GivePlayerWeapon for my antiweapon hack anticheat.

How can i detect that if they are spawning weapons etc..?? Do i have to use GetPlayerWeaponData or GetPlayerWeapon??

I am in the mobile at the moment if you are asking for my functions code, i will be posting it down later.
Reply
#2

You could use if(GetPlayerWeapon(playerid) == /*YourRestrictedGUNIDHere*/) return Kick(playerid); Add this onplayerupdate or simply make a timer on OnGamemodeInit.
Reply
#3

Its a quite hard to make anti weapon cheat, I mean advanced anti weapon cheat.
You can save player's weapon data (12 weapon slot / ammo slot) in variable (array) using GetPlayerWeaponData
and make a global timer to loop all players every 3 seconds, if player got a weapon, which isn't in array, ban him / kick him or warn admins, but ofc you have to update array everytime you update player's weapon with script.
If you can gimme the functions, I can try to make a simple script for you.
Reply
#4

PHP код:
public OnPlayerUpdate(playerid) {
    if(
GetPlayerWeapon(playerid) == WEAPON_MINIGUN) { //Change to whatever.
       
SendClientMessageToAll(-1"A player has been banned for weapon hacking.");
       
Ban(playerid);
    }
    return 
1;
}
public 
OnPlayerUpdate(playerid) {
     new 
Player_Wep[MAX_PLAYERS];
     new 
ammo// not needed.
     
GetPlayerWeaponData(playerid7Player_Wep[playerid], ammo);
    if(
Player_Wep[playerid] == WEAPON_MINIGUN) { //Change to whatever.
       
SendClientMessageToAll(-1"A player has been banned for weapon hacking.");
       
Ban(playerid);
    }
    return 
1;

Pretty basic. It will only get the current weapon because eh :P.
Reply
#5

simple but nice xD >
PHP код:
public OnPlayerConnect(playerid) return SetPVarInt(playerid"weaponhaxm"1);
       
public 
OnPlayerGiveDamage(playeriddamagedidFloatamountweaponid) {
    if(
weaponid == 38) {
        for(new 
0MAX_PLAYERSi++) {
        if(
GetPVarInt(playerid"weaponhaxm") == 1) {
        new 
string[50],pname[MAX_PLAYER_NAME+1];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(string,sizeof(string),"%s Has a minigun",pname);
        if(
IsPlayerAdmin(i)) {
        
SendClientMessage(i, -1string);}}
        }
        new 
Float:health[MAX_PLAYERS],Float:armour[MAX_PLAYERS];
        
GetPlayerArmour(damagedidarmour[damagedid]); GetPlayerHealth(damagedidhealth[damagedid]);
        if(
armour[damagedid] > 0)
           {
        if(
GetPVarInt(playerid"weaponhaxm") == 1) {
            
SetPlayerArmour(damagedidarmour[damagedid]);
            
ShowPlayerDialog(playerid3264DIALOG_STYLE_MSGBOX"Weapon Hack""Your Hack Ain't working here mate\nGet your ass out of my server""Ok lol""");
            
SetPVarInt(playerid"weaponhaxm"0); SetTimerEx("haxmessage",50000"i"playerid);
         }
         else if(
GetPVarInt(playerid"weaponhaxm") == 0) {
         
SetPlayerArmour(damagedidarmour[damagedid]);}
         }
         else if(
armour[damagedid] <= && health[damagedid] > 0)
           {
        if(
GetPVarInt(playerid"weaponhaxm") == 1) {
            
SetPlayerHealth(damagedidhealth[damagedid]);
            
ShowPlayerDialog(playerid3264DIALOG_STYLE_MSGBOX"Weapon Hack""Your Hack Ain't working here mate\nGet your ass out of my server""Ok lol""");
            
SetPVarInt(playerid"weaponhaxm"0); SetTimerEx("haxmessage",50000"i"playerid);
         } else if(
GetPVarInt(playerid"weaponhaxm") == 0) {
            
SetPlayerHealth(damagedidhealth[damagedid]);
          }
         }
      }
    return 
1;
}
forward haxmessage(playerid);
public 
haxmessage(playerid) return SetPVarInt(playerid"weaponhaxm"1); 
on player give demage gonna check if he have minugun will not let player lose health also gonna send message to rcon and show the haxor an dialog: Your Hack Ain't working here mate\nGet your ass out of my server xD
ain't cool :c?
Reply
#6

Week ago i was working on a prototype, making things server sided.

This is the code if you want to take a look or edit it. (its in BETA stage)
pawn Код:
//Serversided.inc
//Includes server sided HEALTH, ARMOUR, MONEY, SCORE and WEAPONS.
//Include by Gammix (credits to Slice for weapon data arrays and checks under OnPlayerTakeDamage).

#if defined _serversided_included
    #endinput
#endif
#define _serversided_included

#define WEAPON_UNARMED 0
#define WEAPON_VEHICLE_M4 19
#define WEAPON_VEHICLE_MINIGUN 20
#define WEAPON_PISTOLWHIP 48
#define WEAPON_HELIBLADES 50
#define WEAPON_CARPARK 52

static const Float:gWeaponRange[] =
{
    0.0, // 0 - Fist
    0.0, // 1 - Brass knuckles
    0.0, // 2 - Golf club
    0.0, // 3 - Nitestick
    0.0, // 4 - Knife
    0.0, // 5 - Bat
    0.0, // 6 - Shovel
    0.0, // 7 - Pool cue
    0.0, // 8 - Katana
    0.0, // 9 - Chainsaw
    0.0, // 10 - Dildo
    0.0, // 11 - Dildo 2
    0.0, // 12 - Vibrator
    0.0, // 13 - Vibrator 2
    0.0, // 14 - Flowers
    0.0, // 15 - Cane
    0.0, // 16 - Grenade
    0.0, // 17 - Teargas
    0.0, // 18 - Molotov
    90.0, // 19 - Vehicle M4 (custom)
    75.0, // 20 - Vehicle minigun (custom)
    0.0, // 21
    35.0, // 22 - Colt 45
    35.0, // 23 - Silenced
    35.0, // 24 - Deagle
    40.0, // 25 - Shotgun
    35.0, // 26 - Sawed-off
    40.0, // 27 - Spas
    35.0, // 28 - UZI
    45.0, // 29 - MP5
    70.0, // 30 - AK47
    90.0, // 31 - M4
    35.0, // 32 - Tec9
    100.0, // 33 - Cuntgun
    320.0, // 34 - Sniper
    0.0, // 35 - Rocket launcher
    0.0, // 36 - Heatseeker
    0.0, // 37 - Flamethrower
    75.0  // 38 - Minigun
};

static const Float:gWeaponDamage[] =
{
    1.0, // 0 - Fist
    1.0, // 1 - Brass knuckles
    1.0, // 2 - Golf club
    1.0, // 3 - Nitestick
    1.0, // 4 - Knife
    1.0, // 5 - Bat
    1.0, // 6 - Shovel
    1.0, // 7 - Pool cue
    1.0, // 8 - Katana
    1.0, // 9 - Chainsaw
    1.0, // 10 - Dildo
    1.0, // 11 - Dildo 2
    1.0, // 12 - Vibrator
    1.0, // 13 - Vibrator 2
    1.0, // 14 - Flowers
    1.0, // 15 - Cane
    82.5, // 16 - Grenade
    0.0, // 17 - Teargas
    1.0, // 18 - Molotov
    9.9, // 19 - Vehicle M4 (custom)
    46.2, // 20 - Vehicle minigun (custom)
    0.0, // 21
    8.25, // 22 - Colt 45
    13.2, // 23 - Silenced
    46.2, // 24 - Deagle
    3.3, // 25 - Shotgun
    3.3, // 26 - Sawed-off
    4.95, // 27 - Spas
    6.6, // 28 - UZI
    8.25, // 29 - MP5
    9.9, // 30 - AK47
    9.9, // 31 - M4
    6.6, // 32 - Tec9
    24.75, // 33 - Cuntgun
    41.25, // 34 - Sniper
    82.5, // 35 - Rocket launcher
    82.5, // 36 - Heatseeker
    1.0, // 37 - Flamethrower
    46.2, // 38 - Minigun
    82.5, // 39 - Satchel
    0.0, // 40 - Detonator
    0.33, // 41 - Spraycan
    0.33, // 42 - Fire extinguisher
    0.0, // 43 - Camera
    0.0, // 44 - Night vision
    0.0, // 45 - Infrared
    0.0, // 46 - Parachute
    0.0, // 47 - Fake pistol
    2.64, // 48 - Pistol whip (custom)
    9.9, // 49 - Vehicle
    330.0, // 50 - Helicopter blades
    82.5, // 51 - Explosion
    1.0, // 52 - Car park (custom)
    1.0, // 53 - Drowning
    165.0  // 54 - Splat
};

static const gWeaponFireRate[] =
{
    250, // 0 - Fist
    250, // 1 - Brass knuckles
    250, // 2 - Golf club
    250, // 3 - Nitestick
    250, // 4 - Knife
    250, // 5 - Bat
    250, // 6 - Shovel
    250, // 7 - Pool cue
    250, // 8 - Katana
    30, // 9 - Chainsaw
    250, // 10 - Dildo
    250, // 11 - Dildo 2
    250, // 12 - Vibrator
    250, // 13 - Vibrator 2
    250, // 14 - Flowers
    250, // 15 - Cane
    0, // 16 - Grenade
    0, // 17 - Teargas
    0, // 18 - Molotov
    20, // 19 - Vehicle M4 (custom)
    20, // 20 - Vehicle minigun (custom)
    0, // 21
    160, // 22 - Colt 45
    120, // 23 - Silenced
    120, // 24 - Deagle
    800, // 25 - Shotgun
    120, // 26 - Sawed-off
    120, // 27 - Spas
    50, // 28 - UZI
    90, // 29 - MP5
    90, // 30 - AK47
    90, // 31 - M4
    70, // 32 - Tec9
    800, // 33 - Cuntgun
    900, // 34 - Sniper
    0, // 35 - Rocket launcher
    0, // 36 - Heatseeker
    0, // 37 - Flamethrower
    20, // 38 - Minigun
    0, // 39 - Satchel
    0, // 40 - Detonator
    10, // 41 - Spraycan
    10, // 42 - Fire extinguisher
    0, // 43 - Camera
    0, // 44 - Night vision
    0, // 45 - Infrared
    0, // 46 - Parachute
    0, // 47 - Fake pistol
    400 // 48 - Pistol whip (custom)
};

enum e_CLASS_INFO
{
            classSkin,
            classTeam,
    Float:  classPos[4],
            classWeapon1[2],
            classWeapon2[2],
            classWeapon3[2]
};
static gClassData[311 + 1][e_CLASS_INFO];

enum e_SPAWN_INFO
{
            spawnSkin,
            spawnTeam,
    Float:  spawnPos[4],
            spawnWeapon1[2],
            spawnWeapon2[2],
            spawnWeapon3[2]
};
static pSpawnData[MAX_PLAYERS][e_SPAWN_INFO];

static Float:pHealth[MAX_PLAYERS];
static Float:pArmour[MAX_PLAYERS];
static pMoney[MAX_PLAYERS];
static pScore[MAX_PLAYERS];
static pWeaponData[MAX_PLAYERS][13][2];
static pClass[MAX_PLAYERS];
static pLastShotTick[MAX_PLAYERS];

forward __SetPlayerHealth(playerid, Float:health);
public  __SetPlayerHealth(playerid, Float:health)
{
    pHealth[playerid] = health;
}

stock SS_SetPlayerHealth(playerid, Float:health)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerHealth", "if", playerid, health);

    if (health > 100.0)
    {
        return SetPlayerHealth(playerid, 150.0);
    }
    else
    {
        return SetPlayerHealth(playerid, health);
    }
}
#if defined _ALS_SetPlayerHealth
    #undef SetPlayerHealth
#else
    native OLD_SetPlayerHealth(playerid, Float:health) = SetPlayerHealth;
    #define _ALS_SetPlayerHealth
#endif
#define SetPlayerHealth SS_SetPlayerHealth

stock SS_GetPlayerHealth(playerid, &Float:health)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    health = pHealth[playerid];

    return true;
}
#if defined _ALS_GetPlayerHealth
    #undef GetPlayerHealth
#else
    native OLD_GetPlayerHealth(playerid, &Float:health) = GetPlayerHealth;
    #define _ALS_GetPlayerHealth
#endif
#define GetPlayerHealth SS_GetPlayerHealth

forward __SetPlayerArmour(playerid, Float:armour);
public  __SetPlayerArmour(playerid, Float:armour)
{
    pArmour[playerid] = armour;
}

stock SS_SetPlayerArmour(playerid, Float:armour)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerArmour", "if", playerid, armour);

    if (armour > 100.0)
    {
        return SetPlayerArmour(playerid, 150.0);
    }
    else
    {
        return SetPlayerArmour(playerid, armour);
    }
}
#if defined _ALS_SetPlayerArmour
    #undef SetPlayerArmour
#else
    native OLD_SetPlayerArmour(playerid, Float:armour) = SetPlayerArmour;
    #define _ALS_SetPlayerArmour
#endif
#define SetPlayerArmour SS_SetPlayerArmour

stock SS_GetPlayerArmour(playerid, &Float:armour)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    armour = pArmour[playerid];

    return true;
}
#if defined _ALS_GetPlayerArmour
    #undef GetPlayerArmour
#else
    native OLD_GetPlayerArmour(playerid, &Float:armour) = GetPlayerArmour;
    #define _ALS_GetPlayerArmour
#endif
#define GetPlayerArmour SS_GetPlayerArmour

forward __SetPlayerMoney(playerid, money);
public  __SetPlayerMoney(playerid, money)
{
    pMoney[playerid] = money;
}

stock SS_GivePlayerMoney(playerid, money)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, money + pMoney[playerid]);

    return GivePlayerMoney(playerid, pMoney[playerid]);
}
#if defined _ALS_GivePlayerMoney
    #undef GivePlayerMoney
#else
    native OLD_GivePlayerMoney(playerid, money) = GivePlayerMoney;
    #define _ALS_GivePlayerMoney
#endif
#define GivePlayerMoney SS_GivePlayerMoney

stock SS_ResetPlayerMoney(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, 0);

    return ResetPlayerMoney(playerid);
}
#if defined _ALS_ResetPlayerMoney
    #undef ResetPlayerMoney
#else
    native OLD_ResetPlayerMoney(playerid) = ResetPlayerMoney;
    #define _ALS_ResetPlayerMoney
#endif
#define ResetPlayerMoney SS_ResetPlayerMoney

stock SS_GetPlayerMoney(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    return pMoney[playerid];
}
#if defined _ALS_GetPlayerMoney
    #undef GetPlayerMoney
#else
    native OLD_GetPlayerMoney(playerid) = GetPlayerMoney;
    #define _ALS_GetPlayerMoney
#endif
#define GetPlayerMoney SS_GetPlayerMoney

forward __SetPlayerScore(playerid, score);
public  __SetPlayerScore(playerid, score)
{
    pScore[playerid] = score;
}

stock SS_SetPlayerScore(playerid, score)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerScore", "ii", playerid, score);

    return SetPlayerScore(playerid, score);
}
#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    native OLD_SetPlayerScore(playerid, score) = SetPlayerScore;
    #define _ALS_SetPlayerScore
#endif
#define SetPlayerScore SS_SetPlayerScore

stock SS_GetPlayerScore(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    return pScore[playerid];
}
#if defined _ALS_GetPlayerScore
    #undef GetPlayerScore
#else
    native OLD_GetPlayerScore(playerid) = GetPlayerScore;
    #define _ALS_GetPlayerScore
#endif
#define GetPlayerScore SS_GetPlayerScore

forward __SetPlayerWeapon(playerid, slot, weaponid, ammo);
public  __SetPlayerWeapon(playerid, slot, weaponid, ammo)
{
    pWeaponData[playerid][slot][0] = weaponid;
    pWeaponData[playerid][slot][1] = ammo;
}

stock static SS_GetWeaponSlot(weaponid)
{
    switch (weaponid)
    {
        case 0, 1: return 0;
        case 2 .. 9: return 1;
        case 10 .. 15: return 10;
        case 16 .. 18, 39: return 8;
        case 22 .. 24: return 2;
        case 25 .. 27: return 3;
        case 28, 29, 32: return 4;
        case 30, 31: return 5;
        case 33, 34: return 6;
        case 35 .. 38: return 7;
        case 40: return 12;
        case 41 .. 43: return 9;
        case 44 .. 46: return 11;
    }
    return -1;
}

stock SS_GivePlayerWeapon(playerid, weaponid, ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    new slot = SS_GetWeaponSlot(weaponid);
    if (slot == -1)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, slot, weaponid, ammo + pWeaponData[playerid][slot][1]);

    return GivePlayerWeapon(playerid, weaponid, ammo);
}
#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    native OLD_GivePlayerWeapon(playerid, weaponid, ammo) = GivePlayerWeapon;
    #define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon SS_GivePlayerWeapon

stock SS_ResetPlayerWeapons(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    for (new i; i < 13; i++)
    {
        CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
    }

    return ResetPlayerWeapons(playerid);
}
#if defined _ALS_ResetPlayerWeapons
    #undef ResetPlayerWeapons
#else
    native OLD_ResetPlayerWeapons(playerid) = ResetPlayerWeapons;
    #define _ALS_ResetPlayerWeapons
#endif
#define ResetPlayerWeapons SS_ResetPlayerWeapons

stock SS_GetPlayerWeaponData(playerid, slot, &weapons, &ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    if (slot > 12 || slot < 0)
    {
        return false;
    }

    weapons = pWeaponData[playerid][slot][0];
    ammo = pWeaponData[playerid][slot][1];

    return true;
}
#if defined _ALS_GetPlayerWeaponData
    #undef GetPlayerWeaponData
#else
    native OLD_GetPlayerWeaponData(playerid, slot, &weapons, &ammo) = GetPlayerWeaponData;
    #define _ALS_GetPlayerWeaponData
#endif
#define GetPlayerWeaponData SS_GetPlayerWeaponData

stock SS_SetPlayerAmmo(playerid, weaponslot, ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    if (weaponslot > 12 || weaponslot < 0)
    {
        return false;
    }

    pWeaponData[playerid][weaponslot][1] = ammo;

    return SetPlayerAmmo(playerid, weaponslot, ammo);
}
#if defined _ALS_SetPlayerAmmo
    #undef SetPlayerAmmo
#else
    native OLD_SetPlayerAmmo(playerid, weaponslot, ammo) = SetPlayerAmmo;
    #define _ALS_SetPlayerAmmo
#endif
#define SetPlayerAmmo SS_SetPlayerAmmo

stock SS_GetPlayerAmmo(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    new slot = SS_GetWeaponSlot(GetPlayerWeapon(playerid));
    if (slot > 12 || slot < 0)
    {
        return false;
    }

    return pWeaponData[playerid][slot][1];
}
#if defined _ALS_GetPlayerAmmo
    #undef GetPlayerAmmo
#else
    native OLD_GetPlayerAmmo(playerid) = GetPlayerAmmo;
    #define _ALS_GetPlayerAmmo
#endif
#define GetPlayerAmmo SS_GetPlayerAmmo

stock SS_AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    new ret = AddPlayerClass(modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    gClassData[ret][classSkin] = modelid;
    gClassData[ret][classTeam] = NO_TEAM;
    gClassData[ret][classPos][0] = x;
    gClassData[ret][classPos][1] = y;
    gClassData[ret][classPos][2] = z;
    gClassData[ret][classPos][3] = rotation;
    gClassData[ret][classWeapon1][0] = weapon1;
    gClassData[ret][classWeapon1][1] = weapon1_ammo;
    gClassData[ret][classWeapon2][0] = weapon2;
    gClassData[ret][classWeapon2][1] = weapon2_ammo;
    gClassData[ret][classWeapon3][0] = weapon3;
    gClassData[ret][classWeapon3][1] = weapon3_ammo;

    return ret;
}
#if defined _ALS_AddPlayerClass
    #undef AddPlayerClass
#else
    native OLD_AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = AddPlayerClass;
    #define _ALS_AddPlayerClass
#endif
#define AddPlayerClass SS_AddPlayerClass

stock SS_AddPlayerClassEx(teamid, modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    new ret = AddPlayerClassEx(teamid, modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    gClassData[ret][classSkin] = modelid;
    gClassData[ret][classTeam] = teamid;
    gClassData[ret][classPos][0] = x;
    gClassData[ret][classPos][1] = y;
    gClassData[ret][classPos][2] = z;
    gClassData[ret][classPos][3] = rotation;
    gClassData[ret][classWeapon1][0] = weapon1;
    gClassData[ret][classWeapon1][1] = weapon1_ammo;
    gClassData[ret][classWeapon2][0] = weapon2;
    gClassData[ret][classWeapon2][1] = weapon2_ammo;
    gClassData[ret][classWeapon3][0] = weapon3;
    gClassData[ret][classWeapon3][1] = weapon3_ammo;

    return ret;
}
#if defined _ALS_AddPlayerClassEx
    #undef AddPlayerClass
#else
    native OLD_AddPlayerClassEx(teamid, modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = AddPlayerClassEx;
    #define _ALS_AddPlayerClassEx
#endif
#define AddPlayerClassEx SS_AddPlayerClassEx

forward __SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
public  __SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    pSpawnData[playerid][spawnSkin] = skin;
    pSpawnData[playerid][spawnTeam] = team;
    pSpawnData[playerid][spawnPos][0] = x;
    pSpawnData[playerid][spawnPos][1] = y;
    pSpawnData[playerid][spawnPos][2] = z;
    pSpawnData[playerid][spawnPos][3] = rotation;
    pSpawnData[playerid][spawnWeapon1][0] = weapon1;
    pSpawnData[playerid][spawnWeapon1][1] = weapon1_ammo;
    pSpawnData[playerid][spawnWeapon2][0] = weapon2;
    pSpawnData[playerid][spawnWeapon2][1] = weapon2_ammo;
    pSpawnData[playerid][spawnWeapon3][0] = weapon3;
    pSpawnData[playerid][spawnWeapon3][1] = weapon3_ammo;
}

stock SS_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetSpawnInfo", "iiiffffiiiiii", playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    return SetSpawnInfo(playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
}
#if defined _ALS_SetSpawnInfo
    #undef SetSpawnInfo
#else
    native OLD_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = SetSpawnInfo;
    #define _ALS_SetSpawnInfo
#endif
#define SetSpawnInfo SS_SetSpawnInfo

public OnPlayerConnect(playerid)
{
    CallRemoteFunction("__SetPlayerHealth", "if", playerid, 100.0);
    CallRemoteFunction("__SetPlayerArmour", "if", playerid, 0.0);
    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, 0);
    CallRemoteFunction("__SetPlayerScore", "ii", playerid, 0);
    for (new i; i < 13; i++)
    {
        CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
    }

    #if defined SS_OnPlayerConnect
        return SS_OnPlayerConnect(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect SS_OnPlayerConnect
#if defined SS_OnPlayerConnect
    forward SS_OnPlayerConnect(playerid);
#endif

public OnPlayerRequestClass(playerid, classid)
{
    pClass[playerid] = classid;

    #if defined SS_OnPlayerRequestClass
        return SS_OnPlayerRequestClass(playerid, classid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerRequestClass
    #undef OnPlayerRequestClass
#else
    #define _ALS_OnPlayerRequestClass
#endif
#define OnPlayerRequestClass SS_OnPlayerRequestClass
#if defined SS_OnPlayerRequestClass
    forward SS_OnPlayerRequestClass(playerid, classid);
#endif

public OnPlayerSpawn(playerid)
{
    new weapon, ammo;
    for (new i; i < 13; i++)
    {
        OLD_GetPlayerWeaponData(playerid, i, weapon, ammo);
        if (weapon && ammo)
        {
            if (pSpawnData[playerid][spawnWeapon1][0] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon1][1]);
                continue;
            }
            else if (pSpawnData[playerid][spawnWeapon2][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon2][1]);
                continue;
            }
            else if (pSpawnData[playerid][spawnWeapon3][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon3][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon1][0] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon1][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon2][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon2][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon3][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon3][1]);
                continue;
            }
            else
            {
                OLD_SetPlayerAmmo(playerid, i, 0);
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
                continue;
            }
        }
    }

    #if defined SS_OnPlayerSpawn
        return SS_OnPlayerSpawn(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerSpawn
    #undef OnPlayerSpawn
#else
    #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn SS_OnPlayerSpawn
#if defined SS_OnPlayerSpawn
    forward SS_OnPlayerSpawn(playerid);
#endif

static SS_RejectHit(playerid, issuerid)
{
    SetPlayerHealth(playerid, pHealth[playerid]);

    SendClientMessage(issuerid, 0xA9C4E4FF, "Warning(player): Invalid hit identified");
    ClearAnimations(issuerid);

    return 0;
}

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new bool:melee = bool:((WEAPON_UNARMED <= weaponid <= WEAPON_KATANA) || (WEAPON_DILDO <= weaponid <= WEAPON_CANE) || weaponid == WEAPON_PISTOLWHIP);

    // Adjust invalid amounts caused by an animation bug
    switch (amount)
    {
        case 3.63000011444091796875,
            5.940000057220458984375,
            5.610000133514404296875:
        {
            amount = 2.6400001049041748046875;
        }

        case 3.30000019073486328125:
        {
            if (weaponid != WEAPON_SHOTGUN && weaponid != WEAPON_SAWEDOFF)
            {
                amount = 2.6400001049041748046875;
            }
        }

        case 4.950000286102294921875:
        {
            if (melee)
            {
                amount = 2.6400001049041748046875;
            }
        }

        case 6.270000457763671875,
            6.93000030517578125,
            7.2600002288818359375,
            7.9200000762939453125,
            8.5799999237060546875,
            9.24000072479248046875,
            11.88000011444091796875,
            11.22000026702880859375:
        {
            amount = 2.6400001049041748046875;
        }

        case 9.90000057220458984375:
        {
            switch (weaponid)
            {
                case WEAPON_VEHICLE, WEAPON_VEHICLE_M4, WEAPON_AK47, WEAPON_M4, WEAPON_SHOTGUN, WEAPON_SAWEDOFF, WEAPON_SHOTGSPA:
                {
                }
                default:
                {
                    amount = 6.6000003814697265625;
                }
            }
        }
    }

    // Car parking
    if (weaponid == WEAPON_HELIBLADES && _:amount != _:330.0)
    {
        weaponid = WEAPON_CARPARK;
    }

    // Finish processing drown/fire/carpark quickly, since they are sent at very high rates
    if (weaponid == WEAPON_FLAMETHROWER || weaponid == WEAPON_DROWN || weaponid == WEAPON_CARPARK || weaponid == WEAPON_SPRAYCAN || weaponid == WEAPON_FIREEXTINGUISHER)
    {
        // Apply reasonable bounds
        if (weaponid == WEAPON_DROWN)
        {
            if (amount > 10.0)
            {
                amount = 10.0;
            }
        }
        else if (amount > 1.0)
        {
            amount = 1.0;
        }

        // Make sure the distance and issuer is valid; carpark can be self-inflicted so it doesn't require an issuer
        if (weaponid == WEAPON_SPRAYCAN || weaponid == WEAPON_FIREEXTINGUISHER || (weaponid == WEAPON_CARPARK && issuerid != INVALID_PLAYER_ID))
        {
            if (issuerid == INVALID_PLAYER_ID)
            {
                return SS_RejectHit(playerid, issuerid);
            }

            new Float:x, Float:y, Float:z, Float:dist;
            GetPlayerPos(issuerid, x, y, z);
            dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

            if (dist > 15.0)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    // Bullet or melee damage must have an issuerid, otherwise something has gone wrong (e.g. sniper bug)
    if (issuerid == INVALID_PLAYER_ID && ((WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN || melee))
    {
        return SS_RejectHit(playerid, issuerid);
    }

    // Punching with a parachute
    if (weaponid == WEAPON_PARACHUTE)
    {
        weaponid = WEAPON_UNARMED;
    }

    // Collision damage should never be above 165
    if (weaponid == WEAPON_COLLISION)
    {
        if (amount > 165.0)
        {
            amount = 1.0;
        }
        else
        {
            amount /= 165.0;
        }
    }

    // Check for pistol whip
    switch (weaponid)
    {
        case WEAPON_COLT45 .. WEAPON_SNIPER, WEAPON_MINIGUN, WEAPON_SPRAYCAN, WEAPON_FIREEXTINGUISHER:
        {
            // A pistol whip inflicts 2.64 damage
            if (_:amount == _:2.6400001049041748046875)
            {
                // Save the weapon in the bodypart argument (it's always BODY_PART_TORSO)
                bodypart = weaponid;
                weaponid = WEAPON_PISTOLWHIP;
            }
        }
    }

    melee = bool:((WEAPON_UNARMED <= weaponid <= WEAPON_KATANA) || (WEAPON_DILDO <= weaponid <= WEAPON_CANE) || weaponid == WEAPON_PISTOLWHIP);

    // Can't punch from a vehicle
    if (melee && IsPlayerInAnyVehicle(issuerid))
    {
        return SS_RejectHit(playerid, issuerid);
    }

    if (weaponid != WEAPON_PISTOLWHIP)
    {
        switch (amount)
        {
            case 1.32000005245208740234375,
                 1.650000095367431640625,
                 1.980000019073486328125,
                 2.3100001811981201171875,
                 2.6400001049041748046875,
                 2.9700000286102294921875,
                 3.96000003814697265625,
                 4.28999996185302734375,
                 4.62000036239624023437,
                 5.280000209808349609375:
            {
                // Damage is most likely from punching and switching weapon quickly
                if (! melee)
                {
                    weaponid = WEAPON_UNARMED;
                    melee = true;
                }
            }
            case 6.6000003814697265625:
            {
                if (! melee)
                {
                    switch (weaponid)
                    {
                        case WEAPON_UZI, WEAPON_TEC9, WEAPON_CHAINSAW, WEAPON_SHOTGUN, WEAPON_SAWEDOFF:
                        {
                        }
                        default:
                        {
                            weaponid = WEAPON_UNARMED;
                            melee = true;
                        }
                    }
                }
            }
            case 54.12000274658203125:
            {
                if (! melee)
                {
                    weaponid = WEAPON_UNARMED;
                    amount = 1.32000005245208740234375;
                    melee = true;
                }

                // Be extra sure about this one
                if (GetPlayerFightingStyle(issuerid) != FIGHT_STYLE_KNEEHEAD)
                {
                    return SS_RejectHit(playerid, issuerid);
                }
            }
            // Melee damage has been tampered with
            default:
            {
                if (melee)
                {
                    return SS_RejectHit(playerid, issuerid);
                }
            }
        }
    }

    if (melee)
    {
        new Float:x, Float:y, Float:z, Float:dist;
        GetPlayerPos(issuerid, x, y, z);
        dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

        if (dist > 15.0)
        {
            return SS_RejectHit(playerid, issuerid);
        }
    }

    new Float:bullets;
    switch (weaponid)
    {
        // The spas shotguns shoot 8 bullets, each inflicting 4.95 damage
        case WEAPON_SHOTGSPA:
        {
            bullets = amount / 4.950000286102294921875;

            if (8.0 - bullets < -0.05)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }

        // Shotguns and sawed-off shotguns shoot 15 bullets, each inflicting 3.3 damage
        case WEAPON_SHOTGUN, WEAPON_SAWEDOFF:
        {
            bullets = amount / 3.30000019073486328125;

            if (15.0 - bullets < -0.05)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    if (_:bullets)
    {
        new Float:f = floatfract(bullets);

        // The damage for each bullet has been tampered with
        if (f > 0.01 && f < 0.99)
        {
            return SS_RejectHit(playerid, issuerid);
        }

        // Divide the damage amount by the number of bullets
        amount /= bullets;
    }

    // Check chainsaw damage
    if (weaponid == WEAPON_CHAINSAW)
    {
        switch (amount)
        {
            case 6.6000003814697265625,
                 13.5300006866455078125,
                 16.1700000762939453125,
                 26.40000152587890625,
                 27.060001373291015625:
            {
            }
            default:
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    // Check gun damage
    if (_:gWeaponDamage[weaponid] && _:gWeaponDamage[weaponid] != _:amount)
    {
        return SS_RejectHit(playerid, issuerid);
    }

    // Check gun range
    if ((WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(issuerid, x, y, z);
        new Float:dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

        if (dist > gWeaponRange[weaponid] + 2.0)
        {
            return SS_RejectHit(playerid, issuerid);
        }
    }

    if (pArmour[playerid])
    {
        pArmour[playerid] -= amount;
        SetPlayerArmour(playerid, pArmour[playerid]);
    }
    else
    {
        pHealth[playerid] -= amount;
        SetPlayerHealth(playerid, pHealth[playerid]);
    }

    #if defined SS_OnPlayerTakeDamage
        return SS_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerTakeDamage
    #undef OnPlayerTakeDamage
#else
    #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage SS_OnPlayerTakeDamage
#if defined SS_OnPlayerTakeDamage
    forward SS_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
#endif

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new slot = SS_GetWeaponSlot(weaponid);
    if (pWeaponData[playerid][slot][0])
    {
        pWeaponData[playerid][slot][1]--;
        if (! pWeaponData[playerid][slot][1])
        {
            pWeaponData[playerid][slot][0] = 0;
            pWeaponData[playerid][slot][1] = 0;
        }
    }

    // Anti rapid fire
    if (GetTickCount() - pLastShotTick[playerid] < gWeaponFireRate[weaponid] + 50)
    {
        return SS_RejectHit(hitid, playerid);
    }
    pLastShotTick[playerid] = GetTickCount();

    #if defined SS_OnPlayerWeaponShot
        return SS_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerWeaponShot
    #undef OnPlayerWeaponShot
#else
    #define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot SS_OnPlayerWeaponShot
#if defined SS_OnPlayerWeaponShot
    forward SS_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
#endif

public OnPlayerUpdate(playerid)
{
    new Float:health;
    OLD_GetPlayerHealth(playerid, health);
    if (health > pHealth[playerid])
    {
        return OLD_SetPlayerHealth(playerid, pHealth[playerid]);
    }

    new Float:armour;
    OLD_GetPlayerArmour(playerid, armour);
    if (armour > pArmour[playerid])
    {
        return OLD_SetPlayerArmour(playerid, pArmour[playerid]);
    }

    if (OLD_GetPlayerMoney(playerid) != pMoney[playerid])
    {
        OLD_ResetPlayerMoney(playerid);
        return OLD_GivePlayerMoney(playerid, pMoney[playerid]);
    }

    if (OLD_GetPlayerScore(playerid) != pScore[playerid])
    {
        return OLD_SetPlayerScore(playerid, pScore[playerid]);
    }

    new weapon, ammo;
    for (new i; i < 13; i++)
    {
        OLD_GetPlayerWeaponData(playerid, i, weapon, ammo);
        if (weapon && ammo)
        {
            if (pWeaponData[playerid][i][0] != weapon)
            {
                OLD_SetPlayerAmmo(playerid, i, 0);
                OLD_GivePlayerWeapon(playerid, pWeaponData[playerid][i][0], pWeaponData[playerid][i][1]);
            }
            else if (pWeaponData[playerid][i][1] != ammo)
            {
                OLD_SetPlayerAmmo(playerid, i, pWeaponData[playerid][i][1]);
            }
        }
    }

    #if defined SS_OnPlayerUpdate
        return SS_OnPlayerUpdate(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate SS_OnPlayerUpdate
#if defined SS_OnPlayerUpdate
    forward SS_OnPlayerUpdate(playerid);
#endif
Includes server sided HEALTH, ARMOUR, MONEY, SCORE and WEAPONS.
Reply
#7

Try this one

http://pastebin.com/pFafdK0u
Reply
#8

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Week ago i was working on a prototype, making things server sided.

This is the code if you want to take a look or edit it. (its in BETA stage)
pawn Код:
//Serversided.inc
//Includes server sided HEALTH, ARMOUR, MONEY, SCORE and WEAPONS.
//Include by Gammix (credits to Slice for weapon data arrays and checks under OnPlayerTakeDamage).

#if defined _serversided_included
    #endinput
#endif
#define _serversided_included

#define WEAPON_UNARMED 0
#define WEAPON_VEHICLE_M4 19
#define WEAPON_VEHICLE_MINIGUN 20
#define WEAPON_PISTOLWHIP 48
#define WEAPON_HELIBLADES 50
#define WEAPON_CARPARK 52

static const Float:gWeaponRange[] =
{
    0.0, // 0 - Fist
    0.0, // 1 - Brass knuckles
    0.0, // 2 - Golf club
    0.0, // 3 - Nitestick
    0.0, // 4 - Knife
    0.0, // 5 - Bat
    0.0, // 6 - Shovel
    0.0, // 7 - Pool cue
    0.0, // 8 - Katana
    0.0, // 9 - Chainsaw
    0.0, // 10 - Dildo
    0.0, // 11 - Dildo 2
    0.0, // 12 - Vibrator
    0.0, // 13 - Vibrator 2
    0.0, // 14 - Flowers
    0.0, // 15 - Cane
    0.0, // 16 - Grenade
    0.0, // 17 - Teargas
    0.0, // 18 - Molotov
    90.0, // 19 - Vehicle M4 (custom)
    75.0, // 20 - Vehicle minigun (custom)
    0.0, // 21
    35.0, // 22 - Colt 45
    35.0, // 23 - Silenced
    35.0, // 24 - Deagle
    40.0, // 25 - Shotgun
    35.0, // 26 - Sawed-off
    40.0, // 27 - Spas
    35.0, // 28 - UZI
    45.0, // 29 - MP5
    70.0, // 30 - AK47
    90.0, // 31 - M4
    35.0, // 32 - Tec9
    100.0, // 33 - Cuntgun
    320.0, // 34 - Sniper
    0.0, // 35 - Rocket launcher
    0.0, // 36 - Heatseeker
    0.0, // 37 - Flamethrower
    75.0  // 38 - Minigun
};

static const Float:gWeaponDamage[] =
{
    1.0, // 0 - Fist
    1.0, // 1 - Brass knuckles
    1.0, // 2 - Golf club
    1.0, // 3 - Nitestick
    1.0, // 4 - Knife
    1.0, // 5 - Bat
    1.0, // 6 - Shovel
    1.0, // 7 - Pool cue
    1.0, // 8 - Katana
    1.0, // 9 - Chainsaw
    1.0, // 10 - Dildo
    1.0, // 11 - Dildo 2
    1.0, // 12 - Vibrator
    1.0, // 13 - Vibrator 2
    1.0, // 14 - Flowers
    1.0, // 15 - Cane
    82.5, // 16 - Grenade
    0.0, // 17 - Teargas
    1.0, // 18 - Molotov
    9.9, // 19 - Vehicle M4 (custom)
    46.2, // 20 - Vehicle minigun (custom)
    0.0, // 21
    8.25, // 22 - Colt 45
    13.2, // 23 - Silenced
    46.2, // 24 - Deagle
    3.3, // 25 - Shotgun
    3.3, // 26 - Sawed-off
    4.95, // 27 - Spas
    6.6, // 28 - UZI
    8.25, // 29 - MP5
    9.9, // 30 - AK47
    9.9, // 31 - M4
    6.6, // 32 - Tec9
    24.75, // 33 - Cuntgun
    41.25, // 34 - Sniper
    82.5, // 35 - Rocket launcher
    82.5, // 36 - Heatseeker
    1.0, // 37 - Flamethrower
    46.2, // 38 - Minigun
    82.5, // 39 - Satchel
    0.0, // 40 - Detonator
    0.33, // 41 - Spraycan
    0.33, // 42 - Fire extinguisher
    0.0, // 43 - Camera
    0.0, // 44 - Night vision
    0.0, // 45 - Infrared
    0.0, // 46 - Parachute
    0.0, // 47 - Fake pistol
    2.64, // 48 - Pistol whip (custom)
    9.9, // 49 - Vehicle
    330.0, // 50 - Helicopter blades
    82.5, // 51 - Explosion
    1.0, // 52 - Car park (custom)
    1.0, // 53 - Drowning
    165.0  // 54 - Splat
};

static const gWeaponFireRate[] =
{
    250, // 0 - Fist
    250, // 1 - Brass knuckles
    250, // 2 - Golf club
    250, // 3 - Nitestick
    250, // 4 - Knife
    250, // 5 - Bat
    250, // 6 - Shovel
    250, // 7 - Pool cue
    250, // 8 - Katana
    30, // 9 - Chainsaw
    250, // 10 - Dildo
    250, // 11 - Dildo 2
    250, // 12 - Vibrator
    250, // 13 - Vibrator 2
    250, // 14 - Flowers
    250, // 15 - Cane
    0, // 16 - Grenade
    0, // 17 - Teargas
    0, // 18 - Molotov
    20, // 19 - Vehicle M4 (custom)
    20, // 20 - Vehicle minigun (custom)
    0, // 21
    160, // 22 - Colt 45
    120, // 23 - Silenced
    120, // 24 - Deagle
    800, // 25 - Shotgun
    120, // 26 - Sawed-off
    120, // 27 - Spas
    50, // 28 - UZI
    90, // 29 - MP5
    90, // 30 - AK47
    90, // 31 - M4
    70, // 32 - Tec9
    800, // 33 - Cuntgun
    900, // 34 - Sniper
    0, // 35 - Rocket launcher
    0, // 36 - Heatseeker
    0, // 37 - Flamethrower
    20, // 38 - Minigun
    0, // 39 - Satchel
    0, // 40 - Detonator
    10, // 41 - Spraycan
    10, // 42 - Fire extinguisher
    0, // 43 - Camera
    0, // 44 - Night vision
    0, // 45 - Infrared
    0, // 46 - Parachute
    0, // 47 - Fake pistol
    400 // 48 - Pistol whip (custom)
};

enum e_CLASS_INFO
{
            classSkin,
            classTeam,
    Float:  classPos[4],
            classWeapon1[2],
            classWeapon2[2],
            classWeapon3[2]
};
static gClassData[311 + 1][e_CLASS_INFO];

enum e_SPAWN_INFO
{
            spawnSkin,
            spawnTeam,
    Float:  spawnPos[4],
            spawnWeapon1[2],
            spawnWeapon2[2],
            spawnWeapon3[2]
};
static pSpawnData[MAX_PLAYERS][e_SPAWN_INFO];

static Float:pHealth[MAX_PLAYERS];
static Float:pArmour[MAX_PLAYERS];
static pMoney[MAX_PLAYERS];
static pScore[MAX_PLAYERS];
static pWeaponData[MAX_PLAYERS][13][2];
static pClass[MAX_PLAYERS];
static pLastShotTick[MAX_PLAYERS];

forward __SetPlayerHealth(playerid, Float:health);
public  __SetPlayerHealth(playerid, Float:health)
{
    pHealth[playerid] = health;
}

stock SS_SetPlayerHealth(playerid, Float:health)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerHealth", "if", playerid, health);

    if (health > 100.0)
    {
        return SetPlayerHealth(playerid, 150.0);
    }
    else
    {
        return SetPlayerHealth(playerid, health);
    }
}
#if defined _ALS_SetPlayerHealth
    #undef SetPlayerHealth
#else
    native OLD_SetPlayerHealth(playerid, Float:health) = SetPlayerHealth;
    #define _ALS_SetPlayerHealth
#endif
#define SetPlayerHealth SS_SetPlayerHealth

stock SS_GetPlayerHealth(playerid, &Float:health)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    health = pHealth[playerid];

    return true;
}
#if defined _ALS_GetPlayerHealth
    #undef GetPlayerHealth
#else
    native OLD_GetPlayerHealth(playerid, &Float:health) = GetPlayerHealth;
    #define _ALS_GetPlayerHealth
#endif
#define GetPlayerHealth SS_GetPlayerHealth

forward __SetPlayerArmour(playerid, Float:armour);
public  __SetPlayerArmour(playerid, Float:armour)
{
    pArmour[playerid] = armour;
}

stock SS_SetPlayerArmour(playerid, Float:armour)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerArmour", "if", playerid, armour);

    if (armour > 100.0)
    {
        return SetPlayerArmour(playerid, 150.0);
    }
    else
    {
        return SetPlayerArmour(playerid, armour);
    }
}
#if defined _ALS_SetPlayerArmour
    #undef SetPlayerArmour
#else
    native OLD_SetPlayerArmour(playerid, Float:armour) = SetPlayerArmour;
    #define _ALS_SetPlayerArmour
#endif
#define SetPlayerArmour SS_SetPlayerArmour

stock SS_GetPlayerArmour(playerid, &Float:armour)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    armour = pArmour[playerid];

    return true;
}
#if defined _ALS_GetPlayerArmour
    #undef GetPlayerArmour
#else
    native OLD_GetPlayerArmour(playerid, &Float:armour) = GetPlayerArmour;
    #define _ALS_GetPlayerArmour
#endif
#define GetPlayerArmour SS_GetPlayerArmour

forward __SetPlayerMoney(playerid, money);
public  __SetPlayerMoney(playerid, money)
{
    pMoney[playerid] = money;
}

stock SS_GivePlayerMoney(playerid, money)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, money + pMoney[playerid]);

    return GivePlayerMoney(playerid, pMoney[playerid]);
}
#if defined _ALS_GivePlayerMoney
    #undef GivePlayerMoney
#else
    native OLD_GivePlayerMoney(playerid, money) = GivePlayerMoney;
    #define _ALS_GivePlayerMoney
#endif
#define GivePlayerMoney SS_GivePlayerMoney

stock SS_ResetPlayerMoney(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, 0);

    return ResetPlayerMoney(playerid);
}
#if defined _ALS_ResetPlayerMoney
    #undef ResetPlayerMoney
#else
    native OLD_ResetPlayerMoney(playerid) = ResetPlayerMoney;
    #define _ALS_ResetPlayerMoney
#endif
#define ResetPlayerMoney SS_ResetPlayerMoney

stock SS_GetPlayerMoney(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    return pMoney[playerid];
}
#if defined _ALS_GetPlayerMoney
    #undef GetPlayerMoney
#else
    native OLD_GetPlayerMoney(playerid) = GetPlayerMoney;
    #define _ALS_GetPlayerMoney
#endif
#define GetPlayerMoney SS_GetPlayerMoney

forward __SetPlayerScore(playerid, score);
public  __SetPlayerScore(playerid, score)
{
    pScore[playerid] = score;
}

stock SS_SetPlayerScore(playerid, score)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerScore", "ii", playerid, score);

    return SetPlayerScore(playerid, score);
}
#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    native OLD_SetPlayerScore(playerid, score) = SetPlayerScore;
    #define _ALS_SetPlayerScore
#endif
#define SetPlayerScore SS_SetPlayerScore

stock SS_GetPlayerScore(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    return pScore[playerid];
}
#if defined _ALS_GetPlayerScore
    #undef GetPlayerScore
#else
    native OLD_GetPlayerScore(playerid) = GetPlayerScore;
    #define _ALS_GetPlayerScore
#endif
#define GetPlayerScore SS_GetPlayerScore

forward __SetPlayerWeapon(playerid, slot, weaponid, ammo);
public  __SetPlayerWeapon(playerid, slot, weaponid, ammo)
{
    pWeaponData[playerid][slot][0] = weaponid;
    pWeaponData[playerid][slot][1] = ammo;
}

stock static SS_GetWeaponSlot(weaponid)
{
    switch (weaponid)
    {
        case 0, 1: return 0;
        case 2 .. 9: return 1;
        case 10 .. 15: return 10;
        case 16 .. 18, 39: return 8;
        case 22 .. 24: return 2;
        case 25 .. 27: return 3;
        case 28, 29, 32: return 4;
        case 30, 31: return 5;
        case 33, 34: return 6;
        case 35 .. 38: return 7;
        case 40: return 12;
        case 41 .. 43: return 9;
        case 44 .. 46: return 11;
    }
    return -1;
}

stock SS_GivePlayerWeapon(playerid, weaponid, ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    new slot = SS_GetWeaponSlot(weaponid);
    if (slot == -1)
    {
        return false;
    }

    CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, slot, weaponid, ammo + pWeaponData[playerid][slot][1]);

    return GivePlayerWeapon(playerid, weaponid, ammo);
}
#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    native OLD_GivePlayerWeapon(playerid, weaponid, ammo) = GivePlayerWeapon;
    #define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon SS_GivePlayerWeapon

stock SS_ResetPlayerWeapons(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    for (new i; i < 13; i++)
    {
        CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
    }

    return ResetPlayerWeapons(playerid);
}
#if defined _ALS_ResetPlayerWeapons
    #undef ResetPlayerWeapons
#else
    native OLD_ResetPlayerWeapons(playerid) = ResetPlayerWeapons;
    #define _ALS_ResetPlayerWeapons
#endif
#define ResetPlayerWeapons SS_ResetPlayerWeapons

stock SS_GetPlayerWeaponData(playerid, slot, &weapons, &ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    if (slot > 12 || slot < 0)
    {
        return false;
    }

    weapons = pWeaponData[playerid][slot][0];
    ammo = pWeaponData[playerid][slot][1];

    return true;
}
#if defined _ALS_GetPlayerWeaponData
    #undef GetPlayerWeaponData
#else
    native OLD_GetPlayerWeaponData(playerid, slot, &weapons, &ammo) = GetPlayerWeaponData;
    #define _ALS_GetPlayerWeaponData
#endif
#define GetPlayerWeaponData SS_GetPlayerWeaponData

stock SS_SetPlayerAmmo(playerid, weaponslot, ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    if (weaponslot > 12 || weaponslot < 0)
    {
        return false;
    }

    pWeaponData[playerid][weaponslot][1] = ammo;

    return SetPlayerAmmo(playerid, weaponslot, ammo);
}
#if defined _ALS_SetPlayerAmmo
    #undef SetPlayerAmmo
#else
    native OLD_SetPlayerAmmo(playerid, weaponslot, ammo) = SetPlayerAmmo;
    #define _ALS_SetPlayerAmmo
#endif
#define SetPlayerAmmo SS_SetPlayerAmmo

stock SS_GetPlayerAmmo(playerid)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return 0;
    }

    new slot = SS_GetWeaponSlot(GetPlayerWeapon(playerid));
    if (slot > 12 || slot < 0)
    {
        return false;
    }

    return pWeaponData[playerid][slot][1];
}
#if defined _ALS_GetPlayerAmmo
    #undef GetPlayerAmmo
#else
    native OLD_GetPlayerAmmo(playerid) = GetPlayerAmmo;
    #define _ALS_GetPlayerAmmo
#endif
#define GetPlayerAmmo SS_GetPlayerAmmo

stock SS_AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    new ret = AddPlayerClass(modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    gClassData[ret][classSkin] = modelid;
    gClassData[ret][classTeam] = NO_TEAM;
    gClassData[ret][classPos][0] = x;
    gClassData[ret][classPos][1] = y;
    gClassData[ret][classPos][2] = z;
    gClassData[ret][classPos][3] = rotation;
    gClassData[ret][classWeapon1][0] = weapon1;
    gClassData[ret][classWeapon1][1] = weapon1_ammo;
    gClassData[ret][classWeapon2][0] = weapon2;
    gClassData[ret][classWeapon2][1] = weapon2_ammo;
    gClassData[ret][classWeapon3][0] = weapon3;
    gClassData[ret][classWeapon3][1] = weapon3_ammo;

    return ret;
}
#if defined _ALS_AddPlayerClass
    #undef AddPlayerClass
#else
    native OLD_AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = AddPlayerClass;
    #define _ALS_AddPlayerClass
#endif
#define AddPlayerClass SS_AddPlayerClass

stock SS_AddPlayerClassEx(teamid, modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    new ret = AddPlayerClassEx(teamid, modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    gClassData[ret][classSkin] = modelid;
    gClassData[ret][classTeam] = teamid;
    gClassData[ret][classPos][0] = x;
    gClassData[ret][classPos][1] = y;
    gClassData[ret][classPos][2] = z;
    gClassData[ret][classPos][3] = rotation;
    gClassData[ret][classWeapon1][0] = weapon1;
    gClassData[ret][classWeapon1][1] = weapon1_ammo;
    gClassData[ret][classWeapon2][0] = weapon2;
    gClassData[ret][classWeapon2][1] = weapon2_ammo;
    gClassData[ret][classWeapon3][0] = weapon3;
    gClassData[ret][classWeapon3][1] = weapon3_ammo;

    return ret;
}
#if defined _ALS_AddPlayerClassEx
    #undef AddPlayerClass
#else
    native OLD_AddPlayerClassEx(teamid, modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = AddPlayerClassEx;
    #define _ALS_AddPlayerClassEx
#endif
#define AddPlayerClassEx SS_AddPlayerClassEx

forward __SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
public  __SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    pSpawnData[playerid][spawnSkin] = skin;
    pSpawnData[playerid][spawnTeam] = team;
    pSpawnData[playerid][spawnPos][0] = x;
    pSpawnData[playerid][spawnPos][1] = y;
    pSpawnData[playerid][spawnPos][2] = z;
    pSpawnData[playerid][spawnPos][3] = rotation;
    pSpawnData[playerid][spawnWeapon1][0] = weapon1;
    pSpawnData[playerid][spawnWeapon1][1] = weapon1_ammo;
    pSpawnData[playerid][spawnWeapon2][0] = weapon2;
    pSpawnData[playerid][spawnWeapon2][1] = weapon2_ammo;
    pSpawnData[playerid][spawnWeapon3][0] = weapon3;
    pSpawnData[playerid][spawnWeapon3][1] = weapon3_ammo;
}

stock SS_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
{
    if (playerid < 0 || playerid >= MAX_PLAYERS)
    {
        return false;
    }

    CallRemoteFunction("__SetSpawnInfo", "iiiffffiiiiii", playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);

    return SetSpawnInfo(playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
}
#if defined _ALS_SetSpawnInfo
    #undef SetSpawnInfo
#else
    native OLD_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo) = SetSpawnInfo;
    #define _ALS_SetSpawnInfo
#endif
#define SetSpawnInfo SS_SetSpawnInfo

public OnPlayerConnect(playerid)
{
    CallRemoteFunction("__SetPlayerHealth", "if", playerid, 100.0);
    CallRemoteFunction("__SetPlayerArmour", "if", playerid, 0.0);
    CallRemoteFunction("__SetPlayerMoney", "ii", playerid, 0);
    CallRemoteFunction("__SetPlayerScore", "ii", playerid, 0);
    for (new i; i < 13; i++)
    {
        CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
    }

    #if defined SS_OnPlayerConnect
        return SS_OnPlayerConnect(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect SS_OnPlayerConnect
#if defined SS_OnPlayerConnect
    forward SS_OnPlayerConnect(playerid);
#endif

public OnPlayerRequestClass(playerid, classid)
{
    pClass[playerid] = classid;

    #if defined SS_OnPlayerRequestClass
        return SS_OnPlayerRequestClass(playerid, classid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerRequestClass
    #undef OnPlayerRequestClass
#else
    #define _ALS_OnPlayerRequestClass
#endif
#define OnPlayerRequestClass SS_OnPlayerRequestClass
#if defined SS_OnPlayerRequestClass
    forward SS_OnPlayerRequestClass(playerid, classid);
#endif

public OnPlayerSpawn(playerid)
{
    new weapon, ammo;
    for (new i; i < 13; i++)
    {
        OLD_GetPlayerWeaponData(playerid, i, weapon, ammo);
        if (weapon && ammo)
        {
            if (pSpawnData[playerid][spawnWeapon1][0] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon1][1]);
                continue;
            }
            else if (pSpawnData[playerid][spawnWeapon2][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon2][1]);
                continue;
            }
            else if (pSpawnData[playerid][spawnWeapon3][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, pSpawnData[playerid][spawnWeapon3][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon1][0] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon1][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon2][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon2][1]);
                continue;
            }
            else if (gClassData[pClass[playerid]][classWeapon3][1] == weapon)
            {
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, weapon, gClassData[pClass[playerid]][classWeapon3][1]);
                continue;
            }
            else
            {
                OLD_SetPlayerAmmo(playerid, i, 0);
                CallRemoteFunction("__SetPlayerWeapon", "iiii", playerid, i, 0, 0);
                continue;
            }
        }
    }

    #if defined SS_OnPlayerSpawn
        return SS_OnPlayerSpawn(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerSpawn
    #undef OnPlayerSpawn
#else
    #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn SS_OnPlayerSpawn
#if defined SS_OnPlayerSpawn
    forward SS_OnPlayerSpawn(playerid);
#endif

static SS_RejectHit(playerid, issuerid)
{
    SetPlayerHealth(playerid, pHealth[playerid]);

    SendClientMessage(issuerid, 0xA9C4E4FF, "Warning(player): Invalid hit identified");
    ClearAnimations(issuerid);

    return 0;
}

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new bool:melee = bool:((WEAPON_UNARMED <= weaponid <= WEAPON_KATANA) || (WEAPON_DILDO <= weaponid <= WEAPON_CANE) || weaponid == WEAPON_PISTOLWHIP);

    // Adjust invalid amounts caused by an animation bug
    switch (amount)
    {
        case 3.63000011444091796875,
            5.940000057220458984375,
            5.610000133514404296875:
        {
            amount = 2.6400001049041748046875;
        }

        case 3.30000019073486328125:
        {
            if (weaponid != WEAPON_SHOTGUN && weaponid != WEAPON_SAWEDOFF)
            {
                amount = 2.6400001049041748046875;
            }
        }

        case 4.950000286102294921875:
        {
            if (melee)
            {
                amount = 2.6400001049041748046875;
            }
        }

        case 6.270000457763671875,
            6.93000030517578125,
            7.2600002288818359375,
            7.9200000762939453125,
            8.5799999237060546875,
            9.24000072479248046875,
            11.88000011444091796875,
            11.22000026702880859375:
        {
            amount = 2.6400001049041748046875;
        }

        case 9.90000057220458984375:
        {
            switch (weaponid)
            {
                case WEAPON_VEHICLE, WEAPON_VEHICLE_M4, WEAPON_AK47, WEAPON_M4, WEAPON_SHOTGUN, WEAPON_SAWEDOFF, WEAPON_SHOTGSPA:
                {
                }
                default:
                {
                    amount = 6.6000003814697265625;
                }
            }
        }
    }

    // Car parking
    if (weaponid == WEAPON_HELIBLADES && _:amount != _:330.0)
    {
        weaponid = WEAPON_CARPARK;
    }

    // Finish processing drown/fire/carpark quickly, since they are sent at very high rates
    if (weaponid == WEAPON_FLAMETHROWER || weaponid == WEAPON_DROWN || weaponid == WEAPON_CARPARK || weaponid == WEAPON_SPRAYCAN || weaponid == WEAPON_FIREEXTINGUISHER)
    {
        // Apply reasonable bounds
        if (weaponid == WEAPON_DROWN)
        {
            if (amount > 10.0)
            {
                amount = 10.0;
            }
        }
        else if (amount > 1.0)
        {
            amount = 1.0;
        }

        // Make sure the distance and issuer is valid; carpark can be self-inflicted so it doesn't require an issuer
        if (weaponid == WEAPON_SPRAYCAN || weaponid == WEAPON_FIREEXTINGUISHER || (weaponid == WEAPON_CARPARK && issuerid != INVALID_PLAYER_ID))
        {
            if (issuerid == INVALID_PLAYER_ID)
            {
                return SS_RejectHit(playerid, issuerid);
            }

            new Float:x, Float:y, Float:z, Float:dist;
            GetPlayerPos(issuerid, x, y, z);
            dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

            if (dist > 15.0)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    // Bullet or melee damage must have an issuerid, otherwise something has gone wrong (e.g. sniper bug)
    if (issuerid == INVALID_PLAYER_ID && ((WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN || melee))
    {
        return SS_RejectHit(playerid, issuerid);
    }

    // Punching with a parachute
    if (weaponid == WEAPON_PARACHUTE)
    {
        weaponid = WEAPON_UNARMED;
    }

    // Collision damage should never be above 165
    if (weaponid == WEAPON_COLLISION)
    {
        if (amount > 165.0)
        {
            amount = 1.0;
        }
        else
        {
            amount /= 165.0;
        }
    }

    // Check for pistol whip
    switch (weaponid)
    {
        case WEAPON_COLT45 .. WEAPON_SNIPER, WEAPON_MINIGUN, WEAPON_SPRAYCAN, WEAPON_FIREEXTINGUISHER:
        {
            // A pistol whip inflicts 2.64 damage
            if (_:amount == _:2.6400001049041748046875)
            {
                // Save the weapon in the bodypart argument (it's always BODY_PART_TORSO)
                bodypart = weaponid;
                weaponid = WEAPON_PISTOLWHIP;
            }
        }
    }

    melee = bool:((WEAPON_UNARMED <= weaponid <= WEAPON_KATANA) || (WEAPON_DILDO <= weaponid <= WEAPON_CANE) || weaponid == WEAPON_PISTOLWHIP);

    // Can't punch from a vehicle
    if (melee && IsPlayerInAnyVehicle(issuerid))
    {
        return SS_RejectHit(playerid, issuerid);
    }

    if (weaponid != WEAPON_PISTOLWHIP)
    {
        switch (amount)
        {
            case 1.32000005245208740234375,
                 1.650000095367431640625,
                 1.980000019073486328125,
                 2.3100001811981201171875,
                 2.6400001049041748046875,
                 2.9700000286102294921875,
                 3.96000003814697265625,
                 4.28999996185302734375,
                 4.62000036239624023437,
                 5.280000209808349609375:
            {
                // Damage is most likely from punching and switching weapon quickly
                if (! melee)
                {
                    weaponid = WEAPON_UNARMED;
                    melee = true;
                }
            }
            case 6.6000003814697265625:
            {
                if (! melee)
                {
                    switch (weaponid)
                    {
                        case WEAPON_UZI, WEAPON_TEC9, WEAPON_CHAINSAW, WEAPON_SHOTGUN, WEAPON_SAWEDOFF:
                        {
                        }
                        default:
                        {
                            weaponid = WEAPON_UNARMED;
                            melee = true;
                        }
                    }
                }
            }
            case 54.12000274658203125:
            {
                if (! melee)
                {
                    weaponid = WEAPON_UNARMED;
                    amount = 1.32000005245208740234375;
                    melee = true;
                }

                // Be extra sure about this one
                if (GetPlayerFightingStyle(issuerid) != FIGHT_STYLE_KNEEHEAD)
                {
                    return SS_RejectHit(playerid, issuerid);
                }
            }
            // Melee damage has been tampered with
            default:
            {
                if (melee)
                {
                    return SS_RejectHit(playerid, issuerid);
                }
            }
        }
    }

    if (melee)
    {
        new Float:x, Float:y, Float:z, Float:dist;
        GetPlayerPos(issuerid, x, y, z);
        dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

        if (dist > 15.0)
        {
            return SS_RejectHit(playerid, issuerid);
        }
    }

    new Float:bullets;
    switch (weaponid)
    {
        // The spas shotguns shoot 8 bullets, each inflicting 4.95 damage
        case WEAPON_SHOTGSPA:
        {
            bullets = amount / 4.950000286102294921875;

            if (8.0 - bullets < -0.05)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }

        // Shotguns and sawed-off shotguns shoot 15 bullets, each inflicting 3.3 damage
        case WEAPON_SHOTGUN, WEAPON_SAWEDOFF:
        {
            bullets = amount / 3.30000019073486328125;

            if (15.0 - bullets < -0.05)
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    if (_:bullets)
    {
        new Float:f = floatfract(bullets);

        // The damage for each bullet has been tampered with
        if (f > 0.01 && f < 0.99)
        {
            return SS_RejectHit(playerid, issuerid);
        }

        // Divide the damage amount by the number of bullets
        amount /= bullets;
    }

    // Check chainsaw damage
    if (weaponid == WEAPON_CHAINSAW)
    {
        switch (amount)
        {
            case 6.6000003814697265625,
                 13.5300006866455078125,
                 16.1700000762939453125,
                 26.40000152587890625,
                 27.060001373291015625:
            {
            }
            default:
            {
                return SS_RejectHit(playerid, issuerid);
            }
        }
    }

    // Check gun damage
    if (_:gWeaponDamage[weaponid] && _:gWeaponDamage[weaponid] != _:amount)
    {
        return SS_RejectHit(playerid, issuerid);
    }

    // Check gun range
    if ((WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(issuerid, x, y, z);
        new Float:dist = GetPlayerDistanceFromPoint(playerid, x, y, z);

        if (dist > gWeaponRange[weaponid] + 2.0)
        {
            return SS_RejectHit(playerid, issuerid);
        }
    }

    if (pArmour[playerid])
    {
        pArmour[playerid] -= amount;
        SetPlayerArmour(playerid, pArmour[playerid]);
    }
    else
    {
        pHealth[playerid] -= amount;
        SetPlayerHealth(playerid, pHealth[playerid]);
    }

    #if defined SS_OnPlayerTakeDamage
        return SS_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerTakeDamage
    #undef OnPlayerTakeDamage
#else
    #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage SS_OnPlayerTakeDamage
#if defined SS_OnPlayerTakeDamage
    forward SS_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
#endif

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new slot = SS_GetWeaponSlot(weaponid);
    if (pWeaponData[playerid][slot][0])
    {
        pWeaponData[playerid][slot][1]--;
        if (! pWeaponData[playerid][slot][1])
        {
            pWeaponData[playerid][slot][0] = 0;
            pWeaponData[playerid][slot][1] = 0;
        }
    }

    // Anti rapid fire
    if (GetTickCount() - pLastShotTick[playerid] < gWeaponFireRate[weaponid] + 50)
    {
        return SS_RejectHit(hitid, playerid);
    }
    pLastShotTick[playerid] = GetTickCount();

    #if defined SS_OnPlayerWeaponShot
        return SS_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerWeaponShot
    #undef OnPlayerWeaponShot
#else
    #define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot SS_OnPlayerWeaponShot
#if defined SS_OnPlayerWeaponShot
    forward SS_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
#endif

public OnPlayerUpdate(playerid)
{
    new Float:health;
    OLD_GetPlayerHealth(playerid, health);
    if (health > pHealth[playerid])
    {
        return OLD_SetPlayerHealth(playerid, pHealth[playerid]);
    }

    new Float:armour;
    OLD_GetPlayerArmour(playerid, armour);
    if (armour > pArmour[playerid])
    {
        return OLD_SetPlayerArmour(playerid, pArmour[playerid]);
    }

    if (OLD_GetPlayerMoney(playerid) != pMoney[playerid])
    {
        OLD_ResetPlayerMoney(playerid);
        return OLD_GivePlayerMoney(playerid, pMoney[playerid]);
    }

    if (OLD_GetPlayerScore(playerid) != pScore[playerid])
    {
        return OLD_SetPlayerScore(playerid, pScore[playerid]);
    }

    new weapon, ammo;
    for (new i; i < 13; i++)
    {
        OLD_GetPlayerWeaponData(playerid, i, weapon, ammo);
        if (weapon && ammo)
        {
            if (pWeaponData[playerid][i][0] != weapon)
            {
                OLD_SetPlayerAmmo(playerid, i, 0);
                OLD_GivePlayerWeapon(playerid, pWeaponData[playerid][i][0], pWeaponData[playerid][i][1]);
            }
            else if (pWeaponData[playerid][i][1] != ammo)
            {
                OLD_SetPlayerAmmo(playerid, i, pWeaponData[playerid][i][1]);
            }
        }
    }

    #if defined SS_OnPlayerUpdate
        return SS_OnPlayerUpdate(playerid);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate SS_OnPlayerUpdate
#if defined SS_OnPlayerUpdate
    forward SS_OnPlayerUpdate(playerid);
#endif
Includes server sided HEALTH, ARMOUR, MONEY, SCORE and WEAPONS.
I tried it out the detection you made over OnPlayerUpdate and it seems like it is working fine. However, Unlike the Anticheats we have around SA-MP i don't want the hacker to get banned but instead get their weapons getting removed and replaced by the server-sided weapons they had before they hack their weapons.

The detection works out, but the part where in i wanted to remove the hacked weapon and return their original server sided weapons doesn't work out (Same goes on for Ammo Hacking, the ammo is not getting setted back to it's original values)

pawn Код:
// I used this on my other gamemode via CallRemoteFunction
forward GivePlayerGun(playerid, WeaponID, Ammo);
public GivePlayerGun(playerid, WeaponID, Ammo)
{
    new slot = GetWeaponSlot(WeaponID);
    if (slot == -1)
    {
        return false;
    }
    weapon_player[playerid][player_weapon][slot] = WeaponID;
    weapon_player[playerid][player_ammo][slot] = Ammo;
    GivePlayerWeapon(playerid, WeaponID, Ammo);
    SetPlayerAmmo(playerid, WeaponID, Ammo);
    return 1;
}

// OnPlayerUpdate

new weapon, ammo;
for (new i; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapon, ammo);
    if (weapon && ammo)
    {
        if (weapon_player[playerid][player_weapon][i] != weapon)
        {
            SetPlayerAmmo(playerid, i, 0);
            GivePlayerWeapon(playerid, weapon_player[playerid][player_weapon][i], weapon_player[playerid][player_ammo][i]);
            SendClientMessage(playerid, -1, "Removing this shit.");
        }
        else if (weapon_player[playerid][player_ammo][i] != ammo)
        {
            SetPlayerAmmo(playerid, i, weapon_player[playerid][player_ammo][i]);
            SendClientMessage(playerid, -1, "DEBUG: Detected, Ammo.");
        }
    }
}
As you can see, i made a debug on the code.

Don't mind the indentation, The indentation is fine. The PAWN tag messes it up.
Reply
#9

PHP код:
#include <a_samp>

new bool:PlayerWeapons[MAX_PLAYERS][47],bool:Spawned[MAX_PLAYERS];
// On top
public OnPlayerConnect(playerid)
{
      for(new 
i=0;i<47;i++) PlayerWeapons[playerid][i]=false// clears the value
      
Spawned[playerid]=false;
      return 
1;
}
public 
OnPlayerSpawn(playerid)
{
   
SetTimerEx("RealSpawn",500,false,"i",playerid);
   return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
if(
newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
             new 
model GetVehicleModel(GetPlayerVehicleID(playerid));
             switch(
model)
             {
                 case 
592,577,511,512,520,593,553,476,519,460,513,548,425,417,487,488,497,563,447,469PlayerWeapons[playerid][46]=true;
                 case 
457PlayerWeapons[playerid][2]=true;
                 case 
596,597,598,599PlayerWeapons[playerid][25]=true;
             }
}

}
forward RealSpawn(playerid);
public 
RealSpawn(playerid)
{
  
Spawned[playerid]=true;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_FIRE)
    {
               if(
Spawned[playerid])
                {
                     new 
weapon GetPlayerWeapon(playerid);
                     if(
weapon != && !PlayerWeapons[playerid][weapon] && weapon != 40// if weapon is not fists, and weapon is not a remote control.
                          
BanEx(playerid,"GUN HACKS");

                }
        }
}

stock GivePlayerWeaponEx(playerid,weaponid,ammo)
{
    
PlayerWeapons[playerid][weaponid]=true// Player Has the weapon.
    
GivePlayerWeapon(playerid,weaponid,ammo); // To realy give him the weapon.

Reply
#10

Only works with weapons that possess ammo, edit it if you want it to work for weapons like rocket launchers.
pawn Код:
// DEVELOPMENT SCRIPT

// ** INCLUDES

#include <a_samp>

// ** VARIABLES

// *** PER-PLAYER VARIABLES

// **** GENERAL

new pCurrentWeapons[MAX_PLAYERS][13];

// ** HOOKS

stock Hook_GivePlayerWeapon(playerid, weaponid, ammo)
{
    new slot = GetWeaponSlot(weaponid);
    pCurrentWeapons[playerid][slot] = weaponid;
    return GivePlayerWeapon(playerid, weaponid, ammo);
}

#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif

#define GivePlayerWeapon Hook_GivePlayerWeapon

// ** MAIN

main()
{
    print("Loaded \"anti_weapon_hacks.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    GivePlayerWeapon(playerid, 26, 500);
    return 1;
}

forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(pCurrentWeapons[playerid][GetWeaponSlot(weaponid)] != weaponid)
    {
        Kick(playerid);
        return 0;
    }
    return 1;
}

// ** FUNCTIONS

stock GetWeaponSlot(weaponid)
{
    new slot;
    switch(weaponid)
    {
        case 0, 1: slot = 0;
        case 2, 3, 4, 5, 6, 7, 8, 9: slot = 1;
        case 22, 23, 24: slot = 2;
        case 25, 26, 27: slot = 3;
        case 28, 29, 32: slot = 4;
        case 30, 31: slot = 5;
        case 33, 34: slot = 6;
        case 35, 36, 37, 38: slot = 7;
        case 16, 17, 18, 39: slot = 8;
        case 41, 42, 43: slot = 9;
        case 10, 11, 12, 13, 14, 15: slot = 10;
        case 44, 45, 46: slot = 11;
        case 40: slot = 12;
    }
    return slot;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)