SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 08/05/2015, 11:35 AM   #1
Emmet_
Guest
 
Posts: n/a
Default Extended Actor Functions

Actor functions

Here are some useful functions related to actors. The purpose of this library is to extend the functionality of actors.

Function list
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
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:

Code:
public OnActorDeath(actorid, killerid, reason)
{
    SetActorRespawnTime(actorid, 5000);
}

Attach a 3D text label to a certain actor:

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.

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
  Reply With Quote
Old 08/05/2015, 11:38 AM   #2
Sellize
Gangsta
 
Sellize's Avatar
 
Join Date: Jan 2013
Location: (ง ͠ ͟ل͜ ͡)ง fight me irl
Posts: 897
Reputation: 286
Default Re: Extended Actor Functions

Another useful include by Emmet. Thanks <3
__________________
some things about me
  • my pc is fucked
  • i only play on a single rp server
  • i graduated in memes
  • /b/
  • best song ever
Sellize is offline   Reply With Quote
Old 08/05/2015, 11:48 AM   #3
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 2,029
Reputation: 274
Default Re: Extended Actor Functions

Great work Emmet. Have a cookie.
Suggestion:
Code:
SetActorColor(actorid,color);
__________________

Admigo is online now   Reply With Quote
Old 08/05/2015, 11:58 AM   #4
Emmet_
Guest
 
Posts: n/a
Default Re: Extended Actor Functions

Quote:
Originally Posted by Sellize View Post
Another useful include by Emmet. Thanks <3
Thanks sir.

Quote:
Originally Posted by Admigo View Post
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).
  Reply With Quote
Old 08/05/2015, 12:01 PM   #5
JaydenJason
Gangsta
 
JaydenJason's Avatar
 
Join Date: Oct 2014
Location: Netherlands
Posts: 723
Reputation: 51
Default Re: Extended Actor Functions

Great one Emmet, loving all of your releases!
JaydenJason is offline   Reply With Quote
Old 08/05/2015, 12:03 PM   #6
Smileys
Huge Clucker
 
Smileys's Avatar
 
Join Date: Dec 2013
Location: Home.
Posts: 399
Reputation: 31
Default Re: Extended Actor Functions

Another great release, keep it up!
Smileys is offline   Reply With Quote
Old 08/05/2015, 12:37 PM   #7
SeV_
High-roller
 
SeV_'s Avatar
 
Join Date: Jul 2012
Location: __________________.
Posts: 1,459
Reputation: 154
Default Re: Extended Actor Functions

Nice!
SeV_ is offline   Reply With Quote
Old 08/05/2015, 12:51 PM   #8
LMaxCo
Big Clucker
 
Join Date: Dec 2014
Location: SA-MP Forums - Powered by VBulletin.
Posts: 158
Reputation: 11
Default Re: Extended Actor Functions

Another usefull include by Emmet_
Thanks !!!!
LMaxCo is offline   Reply With Quote
Old 08/05/2015, 01:44 PM   #9
Infra
Big Clucker
 
Infra's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 77
Reputation: 9
Default AW: Extended Actor Functions

Good job

Code:
native SetActorSkin(actorid, skinid);

:3

I hate destroying the old actor, creating it again and setting its animation again >.>
Infra is online now   Reply With Quote
Old 08/05/2015, 04:06 PM   #10
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,135
Reputation: 450
Default Re: Extended Actor Functions

Now thats more like it.. we really don't need dynamic actors.

Nice work!
Kar is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Extended vehicle functions Emmet_ Includes 63 21/11/2016 09:00 PM
[Include] Extended functions on Vehicles / Seats d3ll Includes 3 04/08/2014 06:25 AM
[Include] FCNPC Extended Functions Pottus Includes 3 27/05/2014 04:37 AM
[Include] exobjects - Extended object functions kvann Includes 2 11/12/2013 07:01 PM
[Include] FileEx (Extended file functions controlling and debugging script) BigETI Includes 4 28/08/2013 12:47 PM


All times are GMT. The time now is 07:30 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.