[FilterScript] Unoccupied Vehicle Damage[NEW]
#9

pawn Код:
#include <a_samp>

#define FILTERSCRIPT

new Float:WeaponDamages[53] =
{
    0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    15.0,       // Pistol.
    0.0,
    60.0,       // Desert Eagle.
    52.0,       // Shotgun.
    35.0,       // Sawn-Off Shotgun.
    52.0,       // Combat Shotgun.
    0.0,
    28.0,       // MP5.
    30.0,       // AK47.
    35.0,       // M4.
    0.0,
    38.0,       // Rifle.
    45.0,       // Sniper Rifle.
    0.0, 0.0, 0.0,
    500.0,      // Minigun.
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
};

public OnFilterScriptInit()
{
    printf("Unoccupied Vehicle Damage Loaded");
    return 1;
}

public OnFilterScriptExit()
{
    printf("Unoccupied Vehicle Damage UnLoaded");
    return 1;
}

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_VEHICLE)
    {
        if(!IsAnOccupiedVehicle(hitid))
        {
            new Float:VehHealth;
            GetVehicleHealth(hitid, Float:VehHealth);
           
            new Float:damage = WeaponDamages[weaponid];
            SetVehicleHealth(hitid, VehHealth - damage);
        }
    }
    return 1;
}

stock IsAnOccupiedVehicle(vehicleid)
{
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            if(GetPlayerVehicleID(i) == vehicleid)return 0;
            else return 1;
        }
    }
    return 0;
}
I could've done something in OnPlayerWeaponShot to detect just the weapons I've specified in the table at the top of the script, but I am not going to do it, since you guys can edit weapon damages for every weapon with that code by simply editing the data values in the table. First 0.0 value is Punching damage, next one is brassknuckle etc. following the order from here: https://sampwiki.blast.hk/wiki/Weapons
Reply


Messages In This Thread
Unoccupied Vehicle Damage[NEW] - by R0 - 21.06.2014, 12:08
Re: Unoccupied Vehicle Damage[NEW] - by AIped - 21.06.2014, 12:19
Re: Unoccupied Vehicle Damage[NEW] - by Jawz - 21.06.2014, 12:20
Re: Unoccupied Vehicle Damage[NEW] - by R0 - 21.06.2014, 12:25
Re: Unoccupied Vehicle Damage[NEW] - by iBots - 23.06.2014, 13:31
Re: Unoccupied Vehicle Damage[NEW] - by DaniceMcHarley - 23.06.2014, 19:31
Re: Unoccupied Vehicle Damage[NEW] - by iAnonymous - 23.06.2014, 19:39
Re: Unoccupied Vehicle Damage[NEW] - by jop9888 - 29.10.2014, 21:27
Re: Unoccupied Vehicle Damage[NEW] - by Riddick94 - 30.10.2014, 20:23
Re: Unoccupied Vehicle Damage[NEW] - by n0minal - 31.10.2014, 14:21

Forum Jump:


Users browsing this thread: 1 Guest(s)