01.12.2013, 06:31
(
Последний раз редактировалось Emmet_; 16.01.2014 в 23:37.
)
I have officially ended supported for this. 0.3z introduces a more accurate implementation of this in SA-MP, so you should use it instead.
OnPlayerShootPos
Introduction
I can't believe that nobody came up with this idea! Basically, this include detects the position that the player potentially shot at with a weapon. This is useful in a lot of circumstances. For example, if a player shoots an object, that object would get destroyed!
How it works
Firstly, the player's position is recorded and stored. An iteration is performed to get the position that the player potentially shot at. When the nearest Z position is matched with the aimed Z position, this callback is called:
Note that this include needs SAfull.hmap from MapAndreas (you do NOT need the plugin). Place it inside the scriptfiles folder.
Notes
- This doesn't work in interiors due to MapAndreas limitations.
- The array of weapon distances might be a bit off.
- Won't work when a player aims too high.
Credits
- Credits to RyDeR` for the MapAndreas function.
- Credits to Kalcor for the SAfull.hmap file.
- Credits to Rockstar Games for the weapon distances (weapon.dat).
Downloads
a_sp.inc
SAfull.hmap
Screenshots
Tested with this code:


OnPlayerShootPos
Introduction
I can't believe that nobody came up with this idea! Basically, this include detects the position that the player potentially shot at with a weapon. This is useful in a lot of circumstances. For example, if a player shoots an object, that object would get destroyed!
How it works
Firstly, the player's position is recorded and stored. An iteration is performed to get the position that the player potentially shot at. When the nearest Z position is matched with the aimed Z position, this callback is called:
pawn Код:
public OnPlayerShootPos(playerid, Float:x, Float:y, Float:z, Float:distance)
{
return 1;
}
Notes
- This doesn't work in interiors due to MapAndreas limitations.
- The array of weapon distances might be a bit off.
- Won't work when a player aims too high.
Credits
- Credits to RyDeR` for the MapAndreas function.
- Credits to Kalcor for the SAfull.hmap file.
- Credits to Rockstar Games for the weapon distances (weapon.dat).
Downloads
a_sp.inc
SAfull.hmap
Screenshots
Tested with this code:
pawn Код:
#include <a_samp>
#include <a_sp>
public OnPlayerShootPos(playerid, Float:x, Float:y, Float:z, Float:distance)
{
CreateExplosion(x, y, z, 6, 30.0);
return 1;
}


