[FilterScript] [0.3z] Unoccupied vehicle damage
#1

Version 3, which takes care of sync issues and adds API support, is now released! (take a look at the Downloads section)

What is this?

So, you know how you can't damage a vehicle unless there's a driver inside it? Say goodbye to that, as this simple filterscript takes advantage of the functions introduced in 0.3z to enable unoccupied vehicle damage!


Limitations

You currently cannot damage vehicles by using weapons that do not fire bullets (melee weapons, explosive weapons etc.)


Setup

Version 1 & 2:

The script is plug-and-play. Minigun damage is disabled by default. If you do not want to be able to deal damage to unoccupied vehicles using the minigun, just skip to the downloads section below and add the script to your filterscripts list.

If you DO want to enable minigun damage, you need to manually compile the source code:

1. Download the source code from the GitHub link below.
2. Open the file in your favourite editor
3. Locate the line
pawn Код:
#define MINIGUN_DAMAGE_ENABLED false
and change it to
pawn Код:
#define MINIGUN_DAMAGE_ENABLED true
4. Save and compile the script using the PAWN compiler


Version 3:


As version 3 adds an API, you need to create the special type of vehicles yourself. Here's how:
  1. Download the v3 filterscript (see the Downloads section below)
  2. Place it in your filterscripts folder, and add it to your server.cfg filterscripts line
  3. Download the v3 API include (.inc file)
  4. Place it inside your /pawno/include/ folder
  5. Include it in your other scripts using
    pawn Код:
    #include <uvdmg>
  6. Now, just add whatever vehicles you'd like (see the documentation below for a function list) and compile your script.

Documentation

Definitions:

pawn Код:
VEHICLE_STATE_INACTIVE
VEHICLE_STATE_SPAWNED
VEHICLE_STATE_DYING

SV_MINIGUN_ENABLED
SV_RESPAWN_VEHICLES
Functions:

pawn Код:
CreateSyncVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, Float:health = 1000.0)
Creates a vehicle that can be destroyed unoccupied.

Returns: The ID of the vehicle created


pawn Код:
DestroySyncVehicle(vehicleid)
Destroys a vehicle created using CreateSyncVehicle.

Returns: 0 if the vehicle doesn't exist/is a normal vehicle, 1 if the vehicle has successfully been destroyed


pawn Код:
SetSyncVehiclesOption(setting, value)
Sets script options, where the setting parameter is one of the SV_ definitions (see above).

Returns: 0 if the option doesn't exist, 1 if the option has been set


pawn Код:
GetSyncVehicleState(vehicleid)
Gets a sync vehicle's current state, the VEHICLE_STATE_ definitions (see above)

Returns: A sync vehicle's current state, the VEHICLE_STATE_ definitions (see above)

pawn Код:
IsVehicleSyncVehicle(vehicleid)
Checks if a vehicle was created using CreateSyncVehicle

Returns: 0 if the vehicle isn't a sync vehicle, 1 if it is


Callbacks:

pawn Код:
public OnUnoccupiedSyncVehicleDying(vehicleid)
Called when an unoccupied synced vehicle's engine is lit on fire (5 seconds before it explodes)


pawn Код:
public OnUnoccupiedSyncVehicleDeath(vehicleid)
Called when an unoccupied synced vehicle explodes


pawn Код:
public OnUnoccupiedSyncVehicleRespawn(vehicleid)
Called when an unoccupied synced vehicle respawns


pawn Код:
public OnUnoccupiedSyncVehicleDamage(playerid, vehicleid, weaponid, Float:amount)
Called when a player damages an unoccupied synced vehicle


Downloads

Source code:
v2
v3

API include:
v3

Compiled binaries: Attached to post


Big thanks to Djole1337 who helped gather damage data, and to FUNExtreme for helping me fix the sync issues!
Oh, and absolutely NO thanks whatsoever to [jS]Thomas!
Reply
#2

Good work King.
Reply
#3

I actually made the same thing a few hours ago. Very neat code.
Reply
#4

Too Fast :P

Nice Work Man
Reply
#5

EDIT:

Nice work.

Took me a while to even find 0.3z... Kalcor posted it in the Scripting Help forum for some reason and it hasn't been added to the downloads page.
Reply
#6

good job ))
Reply
#7

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
That awkward moment when there is no 0.3z version.

At least, none that have officially been released and named that...?
https://sampforum.blast.hk/showthread.php?tid=487997
Reply
#8

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
That awkward moment when there is no 0.3z version.

At least, none that have officially been released and named that...?
https://sampforum.blast.hk/showthread.php?tid=487997
Reply
#9

Good job..
Reply
#10

C:\Users\odst2154\Downloads\test2\filterscripts\vd amage.pwn(2 : error 017: undefined symbol "BULLET_HIT_TYPE_VEHICLE"
1 error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)