22.01.2014, 21:30
Okay, so if you want Rhino's to explode when shot at just follow this tutorial. It's tailored for beginners-intermediate pawno scripters.
Okay, so we'll be using the new 0.3z RC3 PAWN package. We'll need to download this if not already, by clicking here. After downloaded follow the tutorial.
Okay, so we'll be needing the #a_samp include of-course.
Then, we'll be needing to define the following things:
#define BULLET_HIT_TYPE_NONE 0
#define BULLET_HIT_TYPE_PLAYER 1
#define BULLET_HIT_TYPE_VEHICLE 2
#define BULLET_HIT_TYPE_OBJECT 3
#define BULLET_HIT_TYPE_PLAYER_OBJECT 4
Then, after we've defined that we can start with the actual code. We'll be using OnPlayerWeaponShot for this.
Then, we'll of-course need to check if they've shot a vehicle. BULLET_HIT_TYPE_VEHICLE is defined as hittype 2, so we'll check just that.(Don't forget to put your brackets!)
This will also check if the VEHICLEID(hitid) is a valid vehicle. If not it will just return 0 basically. Now, we need to check if the vehicle they shot is a Rhino or not. Rhino's are VehID 432.
We'll use GetVehicleModel for this.
We'll be using a custom stock to actually create the explosions. We will use CreateExplosion for this tutorial, although it is possible to use custom functions for fire/explosions.
Now we will use the Float's to get the vehicle's position with GetVehiclePos.
GetVehiclePos(vehicleid, x, y, z);
Then, we can actually create the explosions. This is where you need to be creative. You can do different explosion types, different ranges, etc. The one's I've used are shown below:
You can find the ExplosionID's by clicking here, and the CreateExplosion wiki page by clicking here.
Code:
If you have any questions feel free to reply or PM me.
Thanks,
Abagail
Okay, so we'll be using the new 0.3z RC3 PAWN package. We'll need to download this if not already, by clicking here. After downloaded follow the tutorial.
Okay, so we'll be needing the #a_samp include of-course.
Then, we'll be needing to define the following things:
#define BULLET_HIT_TYPE_NONE 0
#define BULLET_HIT_TYPE_PLAYER 1
#define BULLET_HIT_TYPE_VEHICLE 2
#define BULLET_HIT_TYPE_OBJECT 3
#define BULLET_HIT_TYPE_PLAYER_OBJECT 4
Then, after we've defined that we can start with the actual code. We'll be using OnPlayerWeaponShot for this.
pawn Code:
forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
pawn Code:
if(hittype == 2 && hitid != INVALID_VEHICLE_ID)
We'll use GetVehicleModel for this.
pawn Code:
if(GetVehicleModel(hitid) == 432) ExplodeRhino(hitid);
pawn Code:
stock ExplodeRhino(vehicleid)
We'll need to make sure to define the x y and z floats, so we'll do:
new Float: x, Float: y, Float: z;
GetVehiclePos(vehicleid, x, y, z);
Then, we can actually create the explosions. This is where you need to be creative. You can do different explosion types, different ranges, etc. The one's I've used are shown below:
pawn Code:
CreateExplosion(x, y, z, 7, 10.0);
CreateExplosion(x, y, z, 1, 7.0);
CreateExplosion(x, y, z, 9, 8.5);
Code:
pawn Code:
// Rhino Explosions
#include <a_samp>
#define BULLET_HIT_TYPE_NONE 0
#define BULLET_HIT_TYPE_PLAYER 1
#define BULLET_HIT_TYPE_VEHICLE 2
#define BULLET_HIT_TYPE_OBJECT 3
#define BULLET_HIT_TYPE_PLAYER_OBJECT 4
forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == 2 && hitid != INVALID_VEHICLE_ID)
{
if(GetVehicleModel(hitid) == 432) ExplodeRhino(hitid); // They Shot a Rhino, - Let there be an explosion from the Rhino. We'll use a custom stock for this. //
}
}
stock ExplodeRhino(vehicleid)
{
new Float: x, Float: y, Float: z;
GetVehiclePos(vehicleid, x, y, z);
CreateExplosion(x, y, z, 7, 10.0);
CreateExplosion(x, y, z, 1, 7.0);
CreateExplosion(x, y, z, 9, 8.5);
}
Thanks,
Abagail