SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/04/2016, 07:50 AM   #1
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Extended Actor Functions

Since Emmet_ has left SA-MP i will maintain this include by releasing new updates and fixing bugs.
I don't want to take any credit for his work.

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);
// Sets an actor's name(3D text label)
forward SetActorName(actorid, name[]);
// Gets an actor's name
forward GetActorName(actorid);
// Toggle an actor's name(Show/Hide 3D text label. Only works when the actor's name is already set(SetActorName)
forward ToggleActorName(actorid,bool:toggle);
// Sets an actor's color(Colors 3D text label only)
forward SetActorColor(actorid, color);
// Sets an actor's chat bubble
forward SetActorChatBubble(actorid, text[], color, Float:drawdistance, expiretime);

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

Updates
Update 08.04.2016
pawn Code:
- Added native SetActorName(actorid,name[])
- Added native GetActorName(actorid)
- Added native ToggleActorName(actorid,bool:toggle)
- Added native SetActorColor(actorid, color)
- Added native SetActorChatBubble(actorid, text[], color, Float:drawdistance, expiretime)

Downloads
Updated
http://pastebin.com/A9U2suFK

Old
http://pastebin.com/TGKx2EyD

Suggestions
If you have any suggestions to improve this include you can pm me or leave a comment here.

Admigo
__________________
Follow me on Instagram @brandonvanommen

Last edited by Admigo; 08/04/2016 at 10:21 PM.
Admigo is offline   Reply With Quote
Old 06/04/2016, 01:24 AM   #2
aoEXE
Gangsta
 
Join Date: Dec 2013
Location: Japón
Posts: 789
Reputation: 39
Default Respuesta: Extended Actor Functions

Code:
SetActorName(actorid, name[]);
GetActorName(actorid, const name[], len);
ToggleActorName(actorid, toggle);
SetActorChatBubble(actorid, text[], color, Float:drawdistance, expiretime);
It must be easy for you.
aoEXE is offline   Reply With Quote
Old 08/04/2016, 09:49 PM   #3
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Respuesta: Extended Actor Functions

Quote:
Originally Posted by aoEXE View Post
Code:
SetActorName(actorid, name[]);
GetActorName(actorid, const name[], len);
ToggleActorName(actorid, toggle);
SetActorChatBubble(actorid, text[], color, Float:drawdistance, expiretime);
It must be easy for you.
Thanks for your suggestions. I just added them in an update.
Update 08.04.2016
pawn Code:
- Added native SetActorName(actorid,name[])
- Added native GetActorName(actorid)
- Added native ToggleActorName(actorid,bool:toggle)
- Added native SetActorColor(actorid, color)
- Added native SetActorChatBubble(actorid, text[], color, Float:drawdistance, expiretime)

Download
http://pastebin.com/A9U2suFK
__________________
Follow me on Instagram @brandonvanommen

Last edited by Admigo; 08/04/2016 at 10:21 PM.
Admigo is offline   Reply With Quote
Old 09/04/2016, 06:45 AM   #4
-CaRRoT
High-roller
 
-CaRRoT's Avatar
 
Join Date: Jul 2011
Location: CA, Los Angeles.
Posts: 1,279
Reputation: 344
Default Re: Extended Actor Functions

Am glad someone with more experience has taken the task to keep this include maintained/updated, keep it up!
-CaRRoT is offline   Reply With Quote
Old 09/04/2016, 10:08 AM   #5
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Extended Actor Functions

Quote:
Originally Posted by -CaRRoT View Post
Am glad someone with more experience has taken the task to keep this include maintained/updated, keep it up!
I won't say i have more experience then Emmet. Just want to keep this include updated. If you have any suggestions to improve this include tell me.
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 09/04/2016, 03:22 PM   #6
bruxo00
High-roller
 
bruxo00's Avatar
 
Join Date: Oct 2012
Location: Portugal
Posts: 1,118
Reputation: 152
Default Re: Extended Actor Functions

I don't know why but none of those functions are working with me...
__________________
RELEASES

[INC] SAMPMailJS
[FS] doxIT!
[GM] Paradise City Roleplay
[TOOL] bAnticheat
[TOOL] Logs Checker
[TUTORIAL] Email confirmation system

www.mp3it.cc · www.diogomartino.com
bruxo00 is offline   Reply With Quote
Old 09/04/2016, 04:12 PM   #7
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Extended Actor Functions

Quote:
Originally Posted by bruxo00 View Post
I don't know why but none of those functions are working with me...
Any errors? Can you show me the code you are using?
__________________
Follow me on Instagram @brandonvanommen
Admigo is offline   Reply With Quote
Old 09/04/2016, 05:04 PM   #8
bruxo00
High-roller
 
bruxo00's Avatar
 
Join Date: Oct 2012
Location: Portugal
Posts: 1,118
Reputation: 152
Default Re: Extended Actor Functions

I was just testing this... But the functions are simply not working. No errors tho.

Like:
Attach3DTextLabelToActor does not create the label.
SetActorName the same.
RespawnActor destroys the actor but the actor don't respawn.

I just tested these 3 functions.
__________________
RELEASES

[INC] SAMPMailJS
[FS] doxIT!
[GM] Paradise City Roleplay
[TOOL] bAnticheat
[TOOL] Logs Checker
[TUTORIAL] Email confirmation system

www.mp3it.cc · www.diogomartino.com
bruxo00 is offline   Reply With Quote
Old 06/06/2016, 01:01 AM   #9
Ermanhaut
Gangsta
 
Ermanhaut's Avatar
 
Join Date: Apr 2016
Location: Curitiba
Posts: 643
Reputation: 47
Default Re: Extended Actor Functions

I have a request for you.
Can you create a callback "OnPlayerShootActor"? Is it possible?
__________________
try, try and try again
Ermanhaut is offline   Reply With Quote
Old 06/06/2016, 04:56 PM   #10
Admigo
High-roller
 
Admigo's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,840
Reputation: 297
Default Re: Extended Actor Functions

You can use the callback OnPlayerGiveDamageActor for that.
__________________
Follow me on Instagram @brandonvanommen
Admigo 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 Actor Functions Emmet_ Includes 47 09/07/2016 08:23 AM
Emmet_ actor.inc / extended functions bogushas Scripting Help 3 26/03/2016 06:46 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


All times are GMT. The time now is 11:33 PM.


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