Extended Actor Functions - Emmet_ - 08.05.2015
Actor functions
Here are some useful functions related to actors. The purpose of this library is to extend the functionality of actors.
Function list
pawn Code:
// Resynchronize an actor.
forward ResyncActor(actorid);
// Respawns an actor.
forward RespawnActor(actorid);
// Checks if the actor is dead.
forward IsActorDead(actorid);
// Sets an actor's respawn time (after death).
forward SetActorRespawnTime(actorid, time);
// Checks if a player is in range of an actor.
forward IsPlayerInRangeOfActor(playerid, actorid, Float:radius = 5.0);
// Attaches a 3D text label to an actor.
forward Text3D:Attach3DTextLabelToActor(actorid, text[], color, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:distance = 10.0, worldid = 0, testlos = 0);
Callback list
pawn Code:
// Called when an actor dies.
forward OnActorDeath(actorid, killerid, reason);
// Called when an actor spawns.
forward OnActorSpawn(actorid);
// Called when a player aims at an actor.
forward OnPlayerTargetActor(playerid, newtarget, oldtarget);
Other benefits:
- Animations are automatically preloaded for an actor, so you don't need to preload them yourself!
- Actor damage is automatically deducted so you don't need to worry about doing that also.
- This also fixes a bug where animations aren't cleared when an actor dies.
Usage
Here's some useful code to respawn a dead actor after 5 seconds:
pawn Code:
public OnActorDeath(actorid, killerid, reason)
{
SetActorRespawnTime(actorid, 5000);
}
Attach a 3D text label to a certain actor:
pawn Code:
gActor = CreateActor(255, 0.0, 0.0, 10.0, 90.0);
gAttachedLabel = Attach3DTextLabelToActor(gActor, "I am an actor!\nPress {FFFF00}'Y'{FFFFFF} to interact with me!", 0xFFFFFFFF, 0.0, 0.0, 0.3, 10.0, 0);
Make the targeted actor put their hands up.
pawn Code:
public OnPlayerTargetActor(playerid, newtarget, oldtarget)
{
if (newtarget != INVALID_ACTOR_ID)
{
ApplyActorAnimation(newtarget, "PED", "handsup", 4.1, 0, 0, 0, 0, 0);
}
if (oldtarget != INVALID_ACTOR_ID)
{
ClearActorAnimations(oldtarget);
}
}
Download
http://pastebin.com/kkb9fgS3
Re: Extended Actor Functions -
Sellize - 08.05.2015
Another useful include by Emmet. Thanks <3
Re: Extended Actor Functions -
Admigo - 08.05.2015
Great work Emmet. Have a cookie.
Suggestion:
Code:
SetActorColor(actorid,color);
Re: Extended Actor Functions - Emmet_ - 08.05.2015
Quote:
Originally Posted by Sellize
Another useful include by Emmet. Thanks <3
|
Thanks sir.
Quote:
Originally Posted by Admigo
Great work Emmet. Have a cookie.
Suggestion:
Code:
SetActorColor(actorid,color);
|
Thanks, and good idea too! I need to think of the best way to add it, since map icons are limited to 100 and they are the only way to create blip markers on the radar (unless I check if the streamer plugin is included and then use CreateDynamicMapIcon).
Re: Extended Actor Functions -
JaydenJason - 08.05.2015
Great one Emmet, loving all of your releases!
Re: Extended Actor Functions -
Smileys - 08.05.2015
Another great release, keep it up!
Re: Extended Actor Functions -
SeV_ - 08.05.2015
Nice!
Re: Extended Actor Functions -
LMaxCo - 08.05.2015
Another usefull include by Emmet_
Thanks !!!!
AW: Extended Actor Functions -
Infra - 08.05.2015
Good job
pawn Code:
native SetActorSkin(actorid, skinid);
:3
I hate destroying the old actor, creating it again and setting its animation again >.>
Re: Extended Actor Functions -
Kar - 08.05.2015
Now thats more like it.. we really don't need dynamic actors.
Nice work!