03.05.2014, 21:26
I have time to do some experiment and I was bored so I said I'll give it a go and help this guy, I hope this would work I am not really sure what you're really looking for but I wrote 2 functions for ya' I hope both of them will work.
pawn Код:
#define STATIC_OBJECT (0)
#define DYNAMIC_OBJECT (1)
stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1, Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
stock IsPlayerInRangeOfObject(playerid, objectid, Float:radius, TYPE = STATIC_OBJECT)
{
new Float:ObjectOffsets[ 3 ];
if(TYPE == STATIC_OBJECT)
{
GetObjectPos(objectid, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]);
if(IsPlayerInRangeOfPoint(playerid, radius, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]))
return true;
}
else if(TYPE == DYNAMIC_OBJECT)
{
GetDynamicObjectPos(objectid, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]);
if(IsPlayerInRangeOfPoint(playerid, radius, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]))
return true;
}
return false;
}
stock IsObjectInRangePoint(objectid, Float:X, Float:Y, Float:Z, Float:radius = 5.0, TYPE = STATIC_OBJECT)
{
new Float:ObjectOffsets[ 3 ];
if(TYPE == STATIC_OBJECT)
{
GetObjectPos(objectid, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]);
if(GetDistanceBetweenPoints(ObjectOffsets[0], ObjectOffsets[1], ObjectOffsets[2], X, Y, Z) <= radius) return true;
}
else if(TYPE == DYNAMIC_OBJECT)
{
GetDynamicObjectPos(objectid, ObjectOffsets[ 0 ], ObjectOffsets[ 1 ], ObjectOffsets[ 2 ]);
if(GetDistanceBetweenPoints(ObjectOffsets[0], ObjectOffsets[1], ObjectOffsets[2], X, Y, Z) <= radius) return true;
}
return false;
}