15.03.2015, 23:32
You actually can by using the provided X, Y, Z offsets and comparing them to the object.
Example:
However unless you hook(or use an extensive function) to store the object's offsets using Attached Player Objects you have to use global objects.
Example:
pawn Код:
// in command...
ShieldObject[playerid] = CreateObject(18637, 0, 0, 0, 0, 0, 0);
AttachObjectToPlayer(objectid, .....
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float: fX, Float: fY, Float: fZ)
{
if(hittype == BULLET_HIT_TYPE_PLAYER && Shield[hitid] == true)
{
new Float: pos[4];
GetObjectOffset(ShieldObject[playerid], playerid, EXTRA_TYPE_PLAYER, pos[0], pos[1], pos[2], pos[3]);
if(GetDistance(x, y, z, pos[0], pos[1], pos[2], pos[3] < 5.0)
{
return 0;
}
}
return 1;
}
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );
}