@Dutheil:
AttachDynamicObjectToPlayer requires YSF to work, because by default there's no
AttachPlayerObjectToPlayer (internally, streamer's dynamic objects are player objects) and YSF added that function. For it to work without YSF,
global objects would need to be used. This should be specified in the main post. Anyway, nice idea about this include.
Also:
Код:
#tryinclude <streamer>
#if !defined Streamer_IncludeFileVersion
#error This include needs streamer plugin
#endif
wouldn't it be better to just use
#include <streamer> and let the compiler warn by default if there's no
streamer.inc file ? You just replaced its job.
Also, you may want to change this:
Код:
CallLocalFunction("OnPlayerClickPlayer", "ddd", playerid, targetid, CLICK_SOURCE_SKIN);
into this:
Код:
#if defined OnPlayerClickPlayer
OnPlayerClickPlayer(playerid, targetid, CLICK_SOURCE_SKIN);
#endif
(this is a precompiler trick, if there's a
OnPlayerClickPlayer defined anywhere in the current script (even after the include) then it will be called directly, as
CallLocalFunction is slower) but shouldn't it be called in every script ? So you should probably use
CallRemoteFunction. But the problem here is that
CLICK_SOURCE_SKIN would be unknown in other scripts which aren't using this include.
Additionally, for every script that is using this include it looks like other dynamic objects will be created and attached to the player, which isn't fine. It's a mess to provide support for multiple scripts using an include like this, but they should work just fine without optimisation problems.
@Gammix: There's no limit with YSF+Streamer Plugin's
AttachDynamicObjectToPlayer (well, the maximum VISIBLE [not the total amount of objects] objects for a player is still
MAX_OBJECTS, but you can create an infinite amount of objects like that, or until your RAM is fully used). If using the regular
CreateObject, then the limit would be
MAX_OBJECTS. The limit of 10 you were talking about are the
player attachable objects which are a special kind of objects, they aren't using the regular object pool.