/*  SA-MP Actor Functions
 *
 *  (c) Copyright 2015, SA-MP Team
 *
 */

#if defined _actor_included
	#endinput
#endif
#define _actor_included
#pragma library actors

native CreateActor(modelid, Float:X, Float:Y, Float:Z, Float:Rotation);
native DestroyActor(actorid);

native IsActorStreamedIn(actorid, forplayerid);

native SetActorVirtualWorld(actorid, vworld);
native GetActorVirtualWorld(actorid);

native ApplyActorAnimation(actorid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time);
native ClearActorAnimations(actorid);

native SetActorPos(actorid, Float:X, Float:Y, Float:Z);
native GetActorPos(actorid, &Float:X, &Float:Y, &Float:Z);
native SetActorFacingAngle(actorid, Float:ang);
native GetActorFacingAngle(actorid, &Float:ang);

native SetActorHealth(actorid, Float:health);
native GetActorHealth(actorid, &Float:health);
native SetActorInvulnerable(actorid, invulnerable = true);
native IsActorInvulnerable(actorid);

native IsValidActor(actorid);

//=========================================================================================================
stock IsActorToPoint(Float:radius, playerid, actorid)
{
	if(!IsPlayerConnected(playerid)) return true;
	new Float:posx, Float:posy, Float:posz,Float:oldposx, Float:oldposy, Float:oldposz,Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    GetActorPos(actorid, posx, posy, posz);
    tempposx = (oldposx -posx); tempposy = (oldposy -posy); tempposz = (oldposz -posz);
    if (((tempposx < radius) && (tempposx > -radius)) && ((tempposy < radius) && (tempposy > -radius)) && ((tempposz < radius) && (tempposz > -radius))) return true;
    return false;
}  
stock CreateActor_Ex(modelid, Float:x, Float:y, Float:z, Float:cx, virtualworld)
{
	new CreateiActor;
	CreateiActor = CreateActor(modelid, x, y, z, cx);
	SetActorVirtualWorld(CreateiActor, virtualworld);
	return CreateiActor;
}