[FilterScript] Unoccupied Vehicle Damage[NEW]
#1

Hey all,I have been told by alot of guys that the includes for this use arent working,so i am creating this simple filterscript to show the usage of OnPlayerWeaponShot and how to create this system.

Features:
*Unoccupied Vehicles Gets Damaged when you shoot at them.
*Vehicles Which has drivers,Lose Normal Damage,not the one that you set.

How to Add More guns:
Step 1:
Open the script,You will find few lines Like:
Код:
#define DEAGLE_DAMAGE 60
Step 2:
All you have to do is Just copying it/pasting it under it,And changing the Amount of the damage and The name of it

Step 3:
Go Under OnPlayerWeaponShot:
Add there:
pawn Код:
if(weaponid == weapon id here)
{
        SetVehicleHealth(hitid, hp-WEAPONNAME_DAMAGE);
}
Example:
I Want to add a damage for the Missle Launcher,All what i have to do is:
pawn Код:
#define DEAGLE_DAMAGE 60
//Becomes
#define MISSLELAUNCHER_DAMAGE 700
Then Under OnPlayerWeaponShot:
pawn Код:
if(weaponid == 35)
{
        SetVehicleHealth(hitid, hp-MISSLELAUNCHER_DAMAGE);
}

ScreenShots:
Vehicle Before Shooting:

Vehicle While Shooting:

Vehicle After Shooting:


Credits:
R0 - Scripting.

Download:
http://pastebin.com/BH22jQVp

ENJOY
Reply
#2

where have you been told that 'they' are not working ?...i can name at least 2 that do work.
anyways good job. i would prefer an include instead of a FS though.

EDIT: btw did you test it ? like..do the vehicles spawn back normaly after exploding ?.
its a commen sa-mp bug that on low setvehicle health the vehicle keeps spawning and burning to death.
Reply
#3

Nice stuff really, can help a lot of people.
Reply
#4

Quote:
Originally Posted by AIped
Посмотреть сообщение
where have you been told that 'they' are not working ?...i can name at least 2 that do work.
anyways good job. i would prefer an include instead of a FS though.

EDIT: btw did you test it ? like..do the vehicles spawn back normaly after exploding ?.
its a commen sa-mp bug that on low setvehicle health the vehicle keeps spawning and burning to death.
As i have said i made this to show newbies and...i am experienced at scripting so i do try to help newbies and i will make this as an include,i didnt say that they surely do not work,i said most of the scripters say that they dont work in their script,i will make it as an include soon
Reply
#5

nice one
Reply
#6

It might sound nice but it isn't, this feature that vehicles wont be damaged with someone in it was added for a reason, anyways good job.
Reply
#7

In the first pic the vehicle have 100 HP according to you but then at the last pic it have 700
COOL STORY BRO !
[Joking]


P.S : Good job buddy. You helped me to understand how it all works .
Reply
#8

for(new e = 0; e < MAX_PLAYERS; e++)
{
if(IsPlayerInAnyVehicle(e) && GetPlayerState(e) == PLAYER_STATE_DRIVER)
{
if(GetPlayerVehicleID(e) == vehicleid) return 0;
else return 1;
}
}
return 0;



should be:




for(new e = 0; e < MAX_PLAYERS; e++)
{
if(IsPlayerInAnyVehicle(e) && GetPlayerState(e) == PLAYER_STATE_DRIVER)
{
if(GetPlayerVehicleID(e) == vehicleid) return 1;
else return 0;
}
}
return 0;

little mistake that will screw up alot
Reply
#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
#10

Good FS but could be better with Vehicle Visual Damage
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)