SA-MP Forums Archive
[FilterScript] Unoccupied Vehicle Damage[NEW] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Unoccupied Vehicle Damage[NEW] (/showthread.php?tid=521010)



Unoccupied Vehicle Damage[NEW] - R0 - 21.06.2014

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


Re: Unoccupied Vehicle Damage[NEW] - AIped - 21.06.2014

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.


Re: Unoccupied Vehicle Damage[NEW] - Jawz - 21.06.2014

Nice stuff really, can help a lot of people.


Re: Unoccupied Vehicle Damage[NEW] - R0 - 21.06.2014

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


Re: Unoccupied Vehicle Damage[NEW] - iBots - 23.06.2014

nice one


Re: Unoccupied Vehicle Damage[NEW] - Beckett - 23.06.2014

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.


Re: Unoccupied Vehicle Damage[NEW] - iAnonymous - 23.06.2014

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 .


Re: Unoccupied Vehicle Damage[NEW] - jop9888 - 29.10.2014

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


Re: Unoccupied Vehicle Damage[NEW] - Riddick94 - 30.10.2014

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


Re: Unoccupied Vehicle Damage[NEW] - n0minal - 31.10.2014

Good FS but could be better with Vehicle Visual Damage