[Include] s_actors - Dynamic Actor's (complete functions) (streamer - library requires: YSI)
#1

s_actors

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>
Once we have thus defined includes, and will have available s_actors functions.

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)
Eye, if you want to change any settings have to do as follows:

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>
Changes in definitions must go before the definition include.

Loops:

Code:
Loop_Only_Dynamic_Actors(variable) // Loop to list the actors created so far.
Example usage:

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;
}
Functions:

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);
Callbacks:

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);
Notes (IMPORTANT):

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.
Reply
#2

Version without YSI added to the post.
Reply
#3

Good idea but trying to use global pools like this is not a good idea to the extent that if someone actually needed to use this include they would likely have an active server with lots of players. This is why this was not done earlier it is basically like trying to use the CreateObject() pool to stream per player objects. I would say you wasted your time doing all this work for something that doesn't even scratch the surface of viability.
Reply
#4

Quote:
Originally Posted by Pottus
View Post
Good idea but trying to use global pools like this is not a good idea to the extent that if someone actually needed to use this include they would likely have an active server with lots of players. This is why this was not done earlier it is basically like trying to use the CreateObject() pool to stream per player objects. I would say you wasted your time doing all this work for something that doesn't even scratch the surface of viability.
If an intermediate or advanced scripter functions include sees, you know that with a good distribution of actors by area could be used unlimitedly so obviously sa-mp does not allow for the same limit https://sampwiki.blast.hk/wiki/CreateActor, just as this include some approaches to what would be unlimited, it will have to wait for more Kalcor increase the limit or have someone do some plugin that function. I will add this comment later in the notes section.

Thanks for comment.
Reply
#5

Quote:
Originally Posted by LatinZ
View Post
If an intermediate or advanced scripter functions include sees, you know that with a good distribution of actors by area could be used unlimitedly so obviously sa-mp does not allow for the same limit https://sampwiki.blast.hk/wiki/CreateActor, just as this include some approaches to what would be unlimited, it will have to wait for more Kalcor increase the limit or have someone do some plugin that function. I will add this comment later in the notes section.

Thanks for comment.
If that was the case then you wouldn't need this include. All this include does is tries to solve a problem with an obtuse solution when the real solution is per player actors. I think you would be a lot better off focusing your skills on another project. I know a good project when I see one the code looks good but the problem you tried to tackle and the way you did it was such a poor choice.

What is really so funny about it is that you actually believed this was a great idea and think you actually made something really good but in essence this is just a really well written joke script. But don't think I am trying to put you down at all I am just expressing my thoughts.
Reply
#6

Quote:
Originally Posted by Pottus
View Post
If that was the case then you wouldn't need this include. All this include does is tries to solve a problem with an obtuse solution when the real solution is per player actors. I think you would be a lot better off focusing your skills on another project. I know a good project when I see one the code looks good but the problem you tried to tackle and the way you did it was such a poor choice.

What is really so funny about it is that you actually believed this was a great idea and think you actually made something really good but in essence this is just a really well written joke script. But don't think I am trying to put you down at all I am just expressing my thoughts.
If I understand what you say.

A scripter know that the includes can not overlook the limitations of sa-mp, and this include is a way to try to avoid the limit of players by sa-mp, as I said, will have to wait a plugin with such Kalcor function or increase the limit.

The include is created to save others scripters do the same functions, plus it has some extra features ...

Greetings.
Reply
#7

****** want to make it , it must be on how to npc
p/s:tks
Reply
#8

I'm getting lot of errors from the include when I try to compile my gamemode.
Reply
#9

If you use the YSI version and do not have the corresponding library clearly the console will mark errors when compiling, if you use the normal version would not have why. In either case, both versions require the include / plugin streamer. If you see that you have everything correct, possibly have several includes outdated, check the versions that are either YSI, streamer and those that the server folder is by default.

https://sampforum.blast.hk/showthread.php?tid=102865
http://sa-mp.com/download.php

Greetings.
Reply
#10

Thanks for your answer, I'm using the NON YSI version, and I'm sure that all my includes are updated streamer and a_samp and all the files but when I add #include <s_actor> and try to compile I get these errors.

Code:
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(96) : error 001: expected token: "}", but found "-identifier-"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(99) : error 010: invalid function or declaration
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(397) : error 017: undefined symbol "IsValidDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(406) : error 017: undefined symbol "DestroyDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(481) : error 017: undefined symbol "Streamer_SetFloatData"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(482) : error 017: undefined symbol "Streamer_SetFloatData"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(483) : error 017: undefined symbol "Streamer_SetFloatData"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(480) : warning 203: symbol is never used: "z"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(480) : warning 203: symbol is never used: "y"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(480) : warning 203: symbol is never used: "x"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(480) : warning 203: symbol is never used: "id"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(581) : error 017: undefined symbol "IsValidDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(582) : error 017: undefined symbol "DestroyDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(589) : error 017: undefined symbol "IsValidDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(589) : error 017: undefined symbol "e_iLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(590) : error 017: undefined symbol "IsValidDynamic3DTextLabel"
C:\Users\Krauser\Desktop\Roleplay2\pawno\include\s_actor.inc(590) : error 017: undefined symbol "e_iLabelName"
Reply
#11

This is because you are defining the include before streamer or you are not directly defining streamer in your gamemode.

Example wrong:

Код:
// ** This send errors

#include <a_samp>
#include <s_actors>

// ** Other code
Example correct:

Код:
#include <a_samp>
#include <streamer>
#include <s_actors>

// ** Other code
The include compiles correctly ...

Reply
#12

I'm an Idiot I totally forgot that I'm not including streamer.inc. However, thanks for your help and for this awesome Job ! keep it up
Reply
#13

Thanks, possibly update the include to correct these "setbacks".
Reply
#14

Well there's a problem that when there is more than one player the actor become to.. lag or something it's like disappearing and reappearing to fast
Reply
#15

Quote:
Originally Posted by Krauser123
Посмотреть сообщение
Well there's a problem that when there is more than one player the actor become to.. lag or something it's like disappearing and reappearing to fast
You can reduce the timers and try to try to reduce the lag a bit, I'll work on a new version of the include to launch it later, good day!
Reply
#16

Well, it looks like this technically dead has died. Because the user Incognito has updated its streamer plugin, which comes dynamic actors.

Streamer: https://sampforum.blast.hk/showthread.php?tid=102865
Reply
#17

Quote:
Originally Posted by Doesk
Посмотреть сообщение
Well, it looks like this technically dead has died. Because the user Incognito has updated its streamer plugin, which comes dynamic actors.

Streamer: https://sampforum.blast.hk/showthread.php?tid=102865
That's like saying ZCMD is "technically dead" because a new command processor was made...
Reply
#18

Quote:
Originally Posted by Crayder
Посмотреть сообщение
That's like saying ZCMD is "technically dead" because a new command processor was made...
I-ZCMD forever, i never get another command processor.
Reply
#19

Quote:
Originally Posted by Crayder
Посмотреть сообщение
That's like saying ZCMD is "technically dead" because a new command processor was made...
You can not compare an include to what is a plugin, technically the plugin gives you the ability to create actors unlimited, but in the class of this include is governed by the limitations of sa:mp, so from my point of view I see It is unnecessary to continue improving this when there is already a much better and efficient alternative.
Reply
#20

Quote:
Originally Posted by Doesk
Посмотреть сообщение
You can not compare an include to what is a plugin, technically the plugin gives you the ability to create actors unlimited, but in the class of this include is governed by the limitations of sa:mp, so from my point of view I see It is unnecessary to continue improving this when there is already a much better and efficient alternative.
It's your include afterall, but I completely disagree with your logic. Perhaps Yahoo should just give up on their search engine because ******'s is better. Or maybe K-12 shouldn't exist because colleges are more advanced. Or (a bit more relative to this situation, lol) maybe ZCMD is dead because a command processing plugin was made.



(@Abyss: The developer of I-ZCMD also made SmartCMD, which is much more advanced and super useful. Check it out.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)