07.07.2016, 04:33
(
Last edited by Unrea1; 12/02/2017 at 10:55 PM.
)
s_actors
Dynamic Actor's (complete functions) (streamer - YSI)
Dynamic Actor's (complete functions) (streamer - YSI)
Introduction:
Sorry, use ****** translator, well ... basically is the re-structuring of an include, which he had many bug's and notices of code (I'll leave in the include link which I edited).
This include have multiple functions, including the main one is the creation of actors without worrying about the limit of SA-MP (which is as you have assigned the "MAX_PLAYERS" the server), therefore I will explain in detail the usage code the include.
Installation:
To use it you need to include the plugin / include streamer, the link will be in the download section.
Once you have the "requirements" for this include in the definition of their includes should be similar to the following code:
Code:
#include <a_samp> #include <YSI\YSI_Data\y_foreach> // s_actors version YSI: Optional, but recommended for faster execution. #include <YSI\YSI\y_timers> // s_actors version YSI. #include <streamer> #include <s_actors>
Explanation of use:
Well, I'll start from definitions to functions and callbacks.
#DEFINES:
Code:
#define MAX_DYNAMIC_ACTORS (2000) // Maximum number of creating actors, this is unlimited! #define MAX_ACTOR_STREAM_DISTANCE (50.0) // Distance which actors are removed when a user is not near any. #define ACTOR_STREAM_TICK_RATE (250) // "Timer" or "Task" which distant actors of the players, which erase function applies are checked. If there is any user around the actor is created. #define MAX_ACTORS_AREA (50) // Maximum players per area, this restriction was created for comfort scripter if you want a maximum of actors for particular area, this is unlimited! #define HEIGHT_LABEL_NAME (1.1) // Height label the name of the actor, I recommend 1.1 because it is the normal value for names. #define VIEWING_DISTANCE_LABEL_NAME (15.0) // Viewing distance to the label name, change to your liking. #define HEIGHT_LABEL_SAY (1.2) // Height label "say" the actor, I recommend 1.2. #define VIEWING_DISTANCE_LABEL_SAY (20.0) // Viewing distance to the label "say", change to your liking. #define TIME_HIDE_LABEL_SAY (5000) // Time which disappears label "say" (once used the DynamicActorSay function ...) #define TIME_DEFAULT_SPAWN (4000) // Default time for the "Dynamic Actor Spawn" function, I recommend 4000 (4 seconds)
Code:
#include <a_samp> #include <YSI\YSI_Data\y_foreach> // s_actors version YSI. #include <YSI\YSI\y_timers> // s_actors version YSI. #include <streamer> #define MAX_DYNAMIC_ACTORS (5000) #include <s_actors>
Loops:
Code:
Loop_Only_Dynamic_Actors(variable) // Loop to list the actors created so far.
Code:
public OnGameModeInit() { Loop_Only_Dynamic_Actors(i) { if(IsValidDynamicActor(i)) printf("Dynamic actor id: %i.", i); } SetGameModeText("Test"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; }
Code:
CreateDynamicActor(name[MAX_PLAYER_NAME], modelid, Float:x, Float:y, Float:z, Float:angle, worldid = 0, bool:invulnerable = true, Float:health = 100.0); DestroyDynamicActor(actorid); IsValidDynamicActor(actorid); IsDynamicActorStreamedIn(actorid, forplayerid); IsDynamicActorInStreamRange(actorid, forplayerid); SetDynamicActorVirtualWorld(actorid, worldid); GetDynamicActorVirtualWorld(actorid); ApplyDynamicActorAnimation(actorid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time); ClearDynamicActorAnimations(actorid); SetDynamicActorPos(actorid, Float:x, Float:y, Float:z); GetDynamicActorPos(actorid, &Float:x, &Float:y, &Float:z); SetDynamicActorFacingAngle(actorid, Float:angle); GetDynamicActorFacingAngle(actorid, &Float:angle); SetDynamicActorSkin(actorid, skinid); GetDynamicActorSkin(actorid); SetDynamicActorHealth(actorid, Float:health); GetDynamicActorHealth(actorid, &Float:health); IsDynamicActorDead(actorid); SetDynamicActorInvulnerable(actorid, bool:invulnerable = true); IsDynamicActorInvulnerable(actorid); AttachDynamicActor3DTextLabel(actorid, text[], color, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:distance = VIEWING_DISTANCE_LABEL_NAME); UpdateDynamicActor3DTextLabel(actorid, color, text[]); DeleteDynamicActor3DTextLabel(actorid); SetDynamicActorName(actorid, name[MAX_PLAYER_NAME]); SetDynamicActorColor(actorid, color); GetDynamicActorInternalID(actorid); GetDynamicActorName(actorid); GetDynamicActorID(name[MAX_PLAYER_NAME]); IsPlayerInRangeOfDynamicActor(playerid, actorid, Float:range = 7.0); DynamicActorSay(actorid, text[], color, Float:distance = VIEWING_DISTANCE_LABEL_SAY); SpawnDynamicActor(actorid, skinid, Float:x, Float:y, Float:z, Float:angle, worldid = 0, bool:invulnerable = true, Float:health = 100.0);
Code:
forward OnDynamicActorStreamIn(actorid, forplayerid); forward OnDynamicActorStreamOut(actorid, forplayerid); forward OnPlayerGiveDamageDynamicActor(playerid, actorid, Float:amount, weaponid, bodypart); forward OnDynamicActorDeath(actorid, killerid, weaponid); forward OnDynamicActorSpawn(actorid);
Well, I'll leave a couple of notes that will be useful when using the include.
+ The "DynamicActorSay", "SetDynamicActorInvulnerable", "SetDynamicActorSkin", "SetDynamicActorFacingAngle", "SetDynamicActorPos", "ApplyDynamicActorAnimation", "SetDynamicActorVirtualWorld" functions return to false if the actor is dead.
+ To use the "GetDynamicActorName" function in your command or verification system "IsValidDynamicActor", otherwise the function will return incorrect data must exist.
+ By default the "CreateDynamicActor" function detect if you entered a name which is already used, this is to avoid errors in the "GetDynamicActorID" function
+ When you change the skin to him, the angle opposed to an actor, automatically all actors (deleted and created auto) is synchronized
+ In defining "MAX_ACTORS_AREA" do not exceed 50, otherwise arise a bug which will not create actors for some reason, I have tried modifying several codes but I can not resolve this bug, if anyone knows comment.
+ Depending on the number of users you have on your server (if you have +50 players) have to adjust definitions include about your server, the definitions are: "MAX_ACTORS_AREA" and "MAX_ACTOR_STREAM_DISTANCE" This is due to the limit of actors from the client SA: MP (https://sampwiki.blast.hk/wiki/CreateActor)
If you make good use of functions include, in a nutshell, you can use the actors unlimitedly.
Bugs:
Look at the notes section "MAX_ACTORS_AREA".
Otherwise it works perfectly.
Why YSI library and the plugin / include streamer used?:
YSI mainly for timers, and foreach to "call" connected players quickly.
Similarly there are two versions of the include, without YSI and YSI.
Streamer for labels (samp has limitation with these ...)
Downloads/Tutorials:
If using the YSI include this library, I'll let some tutorials to get a little more this comprehensive library.
YSI: https://github.com/Misiur/YSI-Includes
Tutorial y_timers: https://sampforum.blast.hk/showthread.php?tid=571044
Tutorial foreach (and others...): https://sampforum.blast.hk/showthread.php?tid=570937
streamer: https://sampforum.blast.hk/showthread.php?tid=102865
ActorStreamer original include: https://github.com/ziggi/actor-streamer
s_actors.inc version YSI (more fast): http://pastebin.com/5jtdTiHm
s_actors.inc: http://pastebin.com/Y6qaem2E
Example use of s_actors: http://pastebin.com/v3p0cChQ
Post spanish: https://sampforum.blast.hk/showthread.php?pid=3729804#pid3729804
Credits:
a_samp: samp team.
YSI: ******
streamer: Incognito.
s_actors: Thanks for the base include (Although I was... wrong): Emmet_, Abagail, Kar, kvanningsen, ziggi.
LatinZ: Restructuring of the entire code and new features added.
Thank you for using.
Last update: 06/07/2016 9:40 PM.
Last update: 06/07/2016 9:40 PM.