16.01.2014, 17:34
When you hit an object/vehicle/player, the coordinates are actually offsets, so for the hitid position you have to add the offsets.
pawn Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(fX != 0 && fY != 0 && fZ != 0)
{
new Float:a;
GetPlayerFacingAngle(playerid, a);
fX -= floatsin(-a, degrees)/2;
fY -= floatcos(-a, degrees)/2;
new Float:X, Float:Y, Float:Z;
switch( hittype )
{
case BULLET_HIT_TYPE_PLAYER: GetPlayerPos( hitid, X, Y, Z );
case BULLET_HIT_TYPE_VEHICLE: GetVehiclePos( hitid, X, Y, Z );
case BULLET_HIT_TYPE_OBJECT: GetObjectPos( hitid, X, Y, Z );
}
SetPlayerPos(playerid, X + fX, Y + fY, Z + fZ+0.3);
}
printf("BULLET HIT type: %d with weapon %d. HITID: %d POS (%f, %f, %f)", hittype, weaponid, hitid, fX, fY, fZ);
return 1;
}