[FilterScript] Vehicle Damage Enabler [Alpha v1.0]
#1

* Can administrators change name of the thread to "[Unoccupied] Vehicle Damage Enabler"? Thank you.
__________________________________________________ ____________________________________________
Introduction
- This represents my first script and I hope it will be just one of many in close future. My goal was to learn more of coding through creating, and if happens to be a good and useful for others, that's even better, I'd just be more motivated to keep updating this one and work on new scripts.

About
- This script will enable you to damage vehicles that doesn't have drivers in them. There are few more scripts on this same topic, but non was able to work as I want, or was outdated, so I decided to make one myself.
- The idea is to bring more reality into RP servers, to disable someone from going further by damaging his/hers car or popping tires. It can be useful for mafia, gangs or if just someone makes you angry . Also, I didn't like the possibility to jump out of the car at any time to avoid them getting damaged.

*It's in Alpha state as I couldn't test it on big server, only made it on local alone with two computers. Also it doesn't have all features I was planing to have, but that is changing with new updates. So far no one mentioned problems for bigger servers.

Features
- You can use all weapons that fire bullets to damage vehicles with no driver:
  • Pistols (9mm, Silenced and Desert Eagle);
  • Shotguns (Shotgun, Sawed Off, Combat Shotgun);
  • SMGs (Uzi, MP5, Tec-9);
  • Rifles (Country Rifle, Sniper, M4, AK-47);
  • Minigun.
- Weapons deal different amount of damage to ground vehicles, and to airplanes, same as if someone would drive them.
Weapon
Vehicles
Airplanes
9mm
25
10
Silenced
40
16
Desert Eagle
140
56
Shotgun
150
60
Sawnoff
150
60
Combat Shotgun
120
48
Uzi
20
8
MP5
25
10
AK-47
30
12
M4
30
12
Tec-9
20
8
Country Rifle
75
30
Sniper
125
50
Minigun
140
56
- You can pop tires on vehicles. - Added in Alpha v2.0
Video preview - https://www.youtube.com/watch?v=4V-7SKCzUG8
- In plan is to add melee, heavy weapons (RPG, HS rocket and flamethrower) and also the bombs to deal exact damage like with driver. But, at the moment I can't enable explosions and fire to damage empty cars, as there is no such callback, or I'm just not aware of it.

Known bugs and issues
- Shotguns will deal maximum damage (150 and 60) with every shot. (Damage should depend on how many bullets actually hit the target).
- Popping tires will also damage vehicle. (Working on a fix.)
- Vehicle health can go to minus. *Fixed in Alpha v2.0 (You can't damage vehicle if it's on fire, have less then 250 health).

Feedback
- I would appreciate a feedback on how script is reacting when several players shoot at the same car or different players shot different cars. If you spot problems in other situations, please post here and I'll try to fix them.
- If you have some ideas how to make this better I'd like to hear it, I'm open to suggestions.

Copyrights and credits
- You can use or edit script as long as you give me credits as first creator and initiator.
- Thanks and credits goes to AmigaBlizzard for showing me IsAirModel(modelid) function.
- Thanks to Gammix's vehicleplus.inc, helped me to figure out wheels position.
- Thanks Abagail for improved IsDriverAvalable call and player loop.

Download and installation
- Download .amx file file and put it into your "filterscripts" folder.
- After that open server.cfg and add name of the file under "filterscripts", without the .amx extension.

Alpha v1.0 (4th March 2016.)
- Download - AMX file
- Download - PWN file
- Preview script code

Alpha v2.0 (5th March 2016.)
* with new feature tire popping
- Download - AMX file
- Download - PWN file
- Preview script code

Alpha v2.1 (6th March 2016.)
* same features with improved code
- Download - AMX file
- Download - PWN file
- Preview script code
Reply
#2

not bad!
Keep it up
Reply
#3

Quote:
Originally Posted by AzaMx
Посмотреть сообщение
not bad!
Keep it up
Thank you, I will
Reply
#4

Good, I was wanting it.
Reply
#5

Check out the damage operations in Slice's weapon config library. The things done in there are way better than your static values.

As for tire popping, you can easily use the damage status bits to enable it.

As for airplanes with tails, I suggest checking out my Over Heated script (link in signature). It includes a tail-rotor death script that destroys the plane if someone shoots the rotor, as it would in real life.

There is a lot more you could add to make this better...
Reply
#6

Pretty Simple.

Try to make something special. And put more effort into it.
Reply
#7

Quote:
Originally Posted by SeanGarnier
Посмотреть сообщение
Good, I was wanting it.
I'm glad that you find it useful

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Check out the damage operations in Slice's weapon config library. The things done in there are way better than your static values.

As for tire popping, you can easily use the damage status bits to enable it.

As for airplanes with tails, I suggest checking out my Over Heated script (link in signature). It includes a tail-rotor death script that destroys the plane if someone shoots the rotor, as it would in real life.

There is a lot more you could add to make this better...
I don't get what you mean by Slice's weapon config library? Searched for that nothing was showing up. Your tail-rotor death script is a good idea, I like it, but I wanted damaging to be the same as when there is a driver. People could add that if they find it good, but I don't want to make it part of my script, if you meant that. Can you tell me more about that tire popping and how to do it? Of course it could be better, as I said in first post, it's unfinished version, it doesn't have full features as I wanted at first, but I'm limited with knowledge and possibilities at the moment, in close future it should be much better.

Quote:
Originally Posted by illuminati2
Посмотреть сообщение
Pretty Simple.

Try to make something special. And put more effort into it.
Believe me I putted effort in this, much more then you think, and I'm happy how it turned out for first and unfinished script. I started learning Pawn a week a go, so for now I only have "special" ideas, and lack of skill to turn them into reality. But I respect your comment, and I know what you mean, it's not a special script, it's simple, but I didn't saw anyone else done it, all scripts I found were outdated, that's why I made this one myself.
Reply
#8

Good Job then. +REP
Reply
#9

Nice man really nice. Simple and clean!
Reply
#10

Quote:
Originally Posted by illuminati2
Посмотреть сообщение
Good Job then. +REP
Thanks, you got one too

Quote:
Originally Posted by kasis223
Посмотреть сообщение
Nice man really nice. Simple and clean!
Thank you, I gave my best. If you can, keep it simple
Reply
#11

Updated to Alpha v2.0.
- Tire popping enabled.
Reply
#12

Mega ^.^ thanks
Reply
#13

Looping through all players each time someone shoots an unoccupied vehicle is redudant and inefficent. Instead of looping through, you can use a variable and update it each time the driver enters/exits the vehicle(OnPlayerStateChange is great for this).

Example:
Code:
new
     vehicleDriver[MAX_VEHICLES] = INVALID_PLAYER_ID,
     playerCurVeh[MAX_PLAYERS] = INVALID_VEHICLE_ID;

public OnPlayerStateChange(playerid, newstate, oldstate)
{
        if(newstate == PLAYER_STATE_DRIVER) {
                 if(GetPlayerVehicleID(playerid) != INVALID_VEHICLE_ID) {
                          vehicleDriver[GetPlayerVehicleID(playerid)] = playerid;
                          playerCurVeh[playerid] = GetPlayerVehicleID(playerid);
                 }
        } else if(oldstate == PLAYER_STATE_DRIVER) {
                 if(playerCurVeh[playerid] != INVALID_VEHICLE_ID) {
                           if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;
                 playerCurVeh[playerid] = INVALID_VEHICLE_ID;
        }

        return 1;
}

public OnPlayerDisconnect(playerid, reason) {
      if(playerCurVeh[playerid] != INVALID_PLAYER_ID)
              if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;

      return 1;
}

DriverAvailable(vehicleid)
      return (vehicleDriver[vehicleid] == INVALID_PLAYER_ID) ? (false) : (true);
Also instead of subtracting a predefined value again and again you can just use an array. Example:
Code:
new AirDamage[] =
{
	{0.0},  // 0
	{0.0},  // 1
	{0.0},  // 2
	{0.0},  // 3
	{0.0},  // 4
	{0.0},  // 5
	{0.0},  // 6
	{0.0},  // 7
	{0.0},  // 8
	{0.0},  // 9
	{0.0},  // 10
	{0.0},  // 11
	{0.0},  // 12
	{0.0},  // 13
	{0.0},  // 14
	{0.0},  // 15
	{0.0},  // 16
	{0.0},  // 17
	{0.0},  // 18
	{0.0},  // 19
	{0.0},  // 20
	{0.0},  // 21
	{10.0}, // 22
	{16.0}, // 23
	{56.0}, // 24
	{60.0}, // 25
	{60.0}, // 26
	{48.0}, // 27
	{8.0},  // 28
	{10.0}, // 29
	{12.0}, // 30
	{12.0}, // 31
	{8.0}   // 32
	{30.0}, // 33
	{50.0}, // 34
	{0.0},  // 35
	{0.0},  // 36
	{0.0},  // 37
	{56.0}, // 38
};

...
SetVehicleHealth(hitid, vHealth-AirDamage[weaponid]);
Reply
#14

Quote:
Originally Posted by wampiros6
View Post
Mega ^.^ thanks
You're welcome, I'm glad that you like it

Quote:
Originally Posted by Abagail
View Post
Looping through all players each time someone shoots an unoccupied vehicle is redudant and inefficent. Instead of looping through, you can use a variable and update it each time the driver enters/exits the vehicle(OnPlayerStateChange is great for this).
Thank you for showing me this I wasn't aware of that at all. I'm new at scripting, but still I wouldn't like my scripts to be bad coded. I'll try to make it with that code you wrote.

Quote:
Originally Posted by Abagail
View Post
Also instead of subtracting a predefined value again and again you can just use an array.
I know this could be done in a better way, just wasn't sure how and didn't have time actually to figure it out, as soon as I enabled tire popping a wanted to upload it. I planed to get back to edit code before next release.

Again thank you for your comments, as I'm new I need to hear what can be done better and especially how. Giving you +REP.

P.S. I removed codes, so that post don't take too much space.
Reply
#15

Use this plugin to avoid you call OnVehicleDeath and respawn dead vehicle. You need to set hitid vehicle occuppied when you shoot at, else OnVehicleDeath wount call! http://forum.sa-mp.com/showthread.ph...light=kurta999
Also for better visual effects use this include https://sampforum.blast.hk/showthread.php?tid=577156
Reply
#16

Quote:
Originally Posted by OmegaKiller72
View Post
Use this plugin to avoid you call OnVehicleDeath and respawn dead vehicle. You need to set hitid vehicle occuppied when you shoot at, else OnVehicleDeath wount call! http://forum.sa-mp.com/showthread.ph...light=kurta999
Also for better visual effects use this include https://sampforum.blast.hk/showthread.php?tid=577156
Here is a better plugin, haven't seen it released though: https://github.com/povargek/AntiVehicleSpawn
Reply
#17

Quote:
Originally Posted by OmegaKiller72
View Post
Use this plugin to avoid you call OnVehicleDeath and respawn dead vehicle. You need to set hitid vehicle occuppied when you shoot at, else OnVehicleDeath wount call! http://forum.sa-mp.com/showthread.ph...light=kurta999
Also for better visual effects use this include https://sampforum.blast.hk/showthread.php?tid=577156
Quote:
Originally Posted by Crayder
View Post
Here is a better plugin, haven't seen it released though: https://github.com/povargek/AntiVehicleSpawn
Not sure if this is referred to me or users of script, but that should be used aside from this filterscript. It's optional for server owners and scripters, depending on that if they want vehicle to respawn or not. My opinion is that they should respawn on starting position after being destroyed, with small delay, but that can be edited to anyone taste.

Or I didn't understand well those posts.
Reply
#18

Quote:
Originally Posted by Salvator
View Post
Not sure if this is referred to me or users of script, but that should be used aside from this filterscript. It's optional for server owners and scripters, depending on that if they want vehicle to respawn or not. My opinion is that they should respawn on starting position after being destroyed, with small delay, but that can be edited to anyone taste.

Or I didn't understand well those posts.
He was basically suggesting you to handle the vehicle deaths. I'd agree with that if this was an include, but it's a filterscript. He suggested you use YSF but that is a bit overboard for something this simple. That's why I mentioned the other plugin which alone does enough for handling the vehicle deaths.
Reply
#19

Quote:
Originally Posted by Crayder
View Post
He was basically suggesting you to handle the vehicle deaths. I'd agree with that if this was an include, but it's a filterscript. He suggested you use YSF but that is a bit overboard for something this simple. That's why I mentioned the other plugin which alone does enough for handling the vehicle deaths.
OK, I almost got it right So as I said in my previous post other plugin is optional aside of the filterscript.
Reply
#20

Updated to Alpha v2.1
- Same features with improved code.
(Changed IF to SWITCH, and faster IsDriverAvailable function)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)