Is(Dynamic)ObjectInRangeOfPoint
#4

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;
}
Reply


Messages In This Thread
Is(Dynamic)ObjectInRangeOfPoint - by S4t3K - 03.05.2014, 20:20
Re: Is(Dynamic)ObjectInRangeOfPoint - by XK - 03.05.2014, 20:25
Re : Is(Dynamic)ObjectInRangeOfPoint - by S4t3K - 03.05.2014, 21:09
Re: Is(Dynamic)ObjectInRangeOfPoint - by Patrick - 03.05.2014, 21:26
Re : Is(Dynamic)ObjectInRangeOfPoint - by S4t3K - 03.05.2014, 21:29
Re: Is(Dynamic)ObjectInRangeOfPoint - by Vince - 03.05.2014, 22:48
Re : Is(Dynamic)ObjectInRangeOfPoint - by S4t3K - 04.05.2014, 09:54
Re: Is(Dynamic)ObjectInRangeOfPoint - by Konstantinos - 04.05.2014, 10:50

Forum Jump:


Users browsing this thread: 1 Guest(s)