[Include] OnPlayerClickPlayer (Extended)
#1

Hi, a basic include which allows to click on the "skin" of any player.
I don't know why nobody thought about it, the include uses an invisible object attached to the player and the function SelectObject.

This include uses the streamer plugin.

Useful :
https://sampwiki.blast.hk/wiki/OnPlayerClickPlayer
SelectPlayer(playerid);
CLICK_SOURCE_SKIN

Link :
https://pastebin.com/mE0XUxQs
Reply
#2

Awesome idea, i didn't test it yet whether it works or not.
But i guess, you missed something, you forgot to destroy the object whenever a player leaves?
Otherwise, good job.
Reply
#3

Quote:
Originally Posted by X337
Посмотреть сообщение
Awesome idea, i didn't test it yet whether it works or not.
But i guess, you missed something, you forgot to destroy the object whenever a player leaves?
Otherwise, good job.
Ah yes, I fix this omg I was tired when I made it
Edit: Fixed
Reply
#4

PHP код:
AttachDynamicObjectToPlayer 
So we can attach how many objects to player with this? I know samp's one have a limit of 10.
Reply
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
PHP код:
AttachDynamicObjectToPlayer 
So we can attach how many objects to player with this? I know samp's one have a limit of 10.
Yes, but you can't attach object to the bone
Reply
#6

Quote:
Originally Posted by Ben666
Посмотреть сообщение
Yes, but you can't attach object to the bone
What is the limit if there is one?
Reply
#7

@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.
Reply
#8

That clears out, so you cannot attach the dynamic objects to a body part i guess, like bone, left arm, etc; they just attached to the center of body of the player?
Reply
#9

Amazing! Such a simple way to do something that I originally thought would be so complex (I attempted this a few years back, trying to get the screen X-Y click, then convert it to GTA coordinates.. needless to say, it didn't get far) xD
Reply
#10

Interesting concept. Really interesting.
Reply
#11

Quote:
Originally Posted by Gammix
Посмотреть сообщение
That clears out, so you cannot attach the dynamic objects to a body part i guess, like bone, left arm, etc; they just attached to the center of body of the player?
Yes, it's like AttachDynamicObjectToVehicle for Skins (it was the old method of attaching Objects before SetPlayerAttachedObject was added (which does not use real objects, so they wouldn't be selectable)).


Well done. You could extend this method to also be possible with Vehicles, just a small suggestion.

Also, I see you use Extra IDs to link Objects to Skins, that is really nice. Only few people seem to know about this (at least that's my impression, since most scripts I see use an Array or a huge Loop for things like this).
Reply
#12

Nice, nice, nice, nice, nice.
Reply
#13

Is there an object conflict with shooting shots?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)