Raised This Month: $103 Target: $400
 25% 

Custom Player Skins (Core)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mitchell
~lick~
Join Date: Mar 2010
Location: noitacoL:
Plugin ID:
4211
Plugin Version:
1.4
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    3 
    Plugin Description:
    Allows plugins to assign a 'skin' to players.
    Old 05-20-2014 , 14:49   Custom Player Skins (Core)
    Reply With Quote #1

    Custom Player Skins
    Allows other plugins to easily bonemerge a player skin to a player, with out worrying about deleting the skin on player_death, etc.
    Mere warning for those who ask if this will work in tf2, the answer is no, nor am i going to make a version that works for tf2.

    If you find this useful and want to use it in your plugin you should pull the code for the skins themselves and use that other then using these natives. Only one plugin can use a skin at any given time.

    Natives
    Inside CustomPlayerSkins.inc:
    Code:
    //Custom Player Skins include file
    
    #if defined _CustomPlayerSkins_included
     #endinput
    #endif
    #define _CustomPlayerSkins_included
    
    #define CPS_NOFLAGS         0
    #define CPS_RENDER          (1 << 0) //Does not make the model invisible. (useful for glows) (used on RemoveSkin it will not force the player's render back to Normal.)
    #define CPS_NOATTACHMENT    (1 << 1) //Does not 'SetParentAttachment' variant. (Useful for non-bone merging)
    #define CPS_IGNOREDEATH     (1 << 2) //This will prevent the removal of the skin on death.
    #define CPS_TRANSMIT        (1 << 3) //This will ignore the hook for Transmit
    
    /**
     * Sets the client's skin from the given path.
     *
     * @param client Client index
     * @param model User input for model path
     * @param flags flags are used to determine what this function does and does not do.
     * @return The skin entity index
     * @error Invalid client.
     */
    native int CPS_SetSkin(int client, char[] model, int flags = CPS_NOFLAGS);
    
    /**
     * Gets the client's skin entity reference.
     *
     * @param client Client index
     * @return Returns the entity reference of the player's skin, INVALID_ENT_REFERENCE if there is no skin.
     * @error Invalid client.
     */
    native int CPS_GetSkin(int client);
    
    /**
     * Simple check if the client already has a skin.
     *
     * @param client Client index
     * @return Returns if the client has a skin currently. (will not check if the player is alive, etc.)
     * @error Invalid client.
     */
    native bool CPS_HasSkin(int client);
    
    /**
     * Removes and resets the player and their skin.
     *
     * @param client Client index
     * @noreturn
     * @error Invalid client.
     */
    native void CPS_RemoveSkin(int client, int flags = CPS_NOFLAGS);
    
    
    /**
     * Sets the client's transmit variable (see below)
     * NOTE: Check if the player is between 0 and MAXPLAYERS.
     *
     * @param owner Client index of the skin's owner
     * @param client Client index of the player that will see the skin.
     * @param transmit	0 - Do not transmit at all.
    					1 - Transmit only if other cases pass.
    					2 - Override other checks.
     * @noreturn
     * @error Invalid client.
     */
    native void CPS_SetTransmit(int owner, int client, int transmit);
    
    
    /**
     * Simple native to return the skin's flags
     * NOTE: Check if the player is between 0 and MAXPLAYERS.
     *
     * @param client Client index
     * @return Returns the client index's skin flags.
     */
    native CPS_GetFlags(client);
    
    public SharedPlugin:__pl_CustomPlayerSkins =
    {
    	name = "CustomPlayerSkins",
    	file = "CustomPlayerSkins.smx",
    #if defined REQUIRE_PLUGIN
    	required = 1,
    #else
    	required = 0,
    #endif
    };
    
    #if !defined REQUIRE_PLUGIN
    public __pl_CustomPlayerSkins_SetNTVOptional()
    {
    	MarkNativeAsOptional("CPS_SetSkin");
    	MarkNativeAsOptional("CPS_GetSkin");
    	MarkNativeAsOptional("CPS_HasSkin");
    	MarkNativeAsOptional("CPS_RemoveSkin");
    	MarkNativeAsOptional("CPS_SetTransmit");
    	MarkNativeAsOptional("CPS_GetFlags");
    }
    #endif

    Planned Features
    • None Currently

    Plugins
    You can only use 1 plugin.
    Random Player Skins (FoF, CS:GO)
    ESP/WH for Admins (CS:GO)

    Downloads
    Plugin
    Source
    Include File

    GitHub Link
    __________________

    Last edited by Mitchell; 12-09-2016 at 13:50.
    Mitchell is offline
    shavit
    AlliedModders Donor
    Join Date: Dec 2011
    Location: Israel
    Old 05-20-2014 , 23:02   Re: Custom Player Skins (Core)
    Reply With Quote #2

    I like that coding commenting style, looks neat
    __________________
    My Plugins
    Not taking private requests, too busy.
    shavit is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Location: noitacoL:
    Old 05-20-2014 , 23:27   Re: Custom Player Skins (Core)
    Reply With Quote #3

    Quote:
    Originally Posted by shavit View Post
    I like that coding commenting style, looks neat
    Glad you read through the code!
    Hopefully more people will catch on, helps other's learn coding with small projects like these with descriptive comments.
    I like comments that explain what the goal of each function, and why it's unique!
    __________________
    Mitchell is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 06-28-2014 , 17:04   Re: Custom Player Skins (Core)
    Reply With Quote #4

    Interesting stuff. That's really a cool thing, because I can enable glow on specific players in CS:GO. Gotta mess with it.
    EDIT: I havent tested plugin yet, but got some notes.
    Reading through the code, dont use MAXMODELLENGTH, use PLATFORM_MAX_PATH instead.
    On a death event, why you initialize client instead of doing RemoveSkin(GetClientOfUserId(GetEventInt(even t, "userid"))) ?
    I would switch to player_hurt event and check if (GetClientHealth(client) < 1) if necessary. Because sometimes props wont be removed on player_death event (its late), or it may looks weird in some cases.
    Also, does ShouldTransmit hook is really doing something?
    Thanks for plugin.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot

    Last edited by Root_; 06-28-2014 at 19:28.
    Root_ is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Location: noitacoL:
    Old 07-02-2014 , 16:48   Re: Custom Player Skins (Core)
    Reply With Quote #5

    Quote:
    Originally Posted by Root_ View Post
    Reading through the code, dont use MAXMODELLENGTH, use PLATFORM_MAX_PATH instead.
    Will do.

    Quote:
    Originally Posted by Root_ View Post
    On a death event, why you initialize client instead of doing RemoveSkin(GetClientOfUserId(GetEventInt(even t, "userid"))) ?
    Good point.

    Quote:
    Originally Posted by Root_ View Post
    I would switch to player_hurt event and check if (GetClientHealth(client) < 1) if necessary. Because sometimes props wont be removed on player_death event (its late), or it may looks weird in some cases.
    hmm, ill look into that, shouldnt matter if the player_death event is late or not though..

    Quote:
    Originally Posted by Root_ View Post
    Also, does ShouldTransmit hook is really doing something?
    Thanks for plugin.
    Nice catch! seems like I forgot to remove that commented out code there from testing!
    Should be stopping the model from being transmitted to the client.
    __________________

    Last edited by Mitchell; 07-02-2014 at 17:12.
    Mitchell is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 07-06-2014 , 21:37   Re: Custom Player Skins (Core)
    Reply With Quote #6

    Hey I am using this in my Admin ESP plugin.
    Please update it on github to latest changes described here, otherwise players will able to see themselves from first person.
    It works perfectly though.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot

    Last edited by Root_; 07-06-2014 at 21:38.
    Root_ is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Location: noitacoL:
    Old 07-07-2014 , 10:43   Re: Custom Player Skins (Core)
    Reply With Quote #7

    Commit updated
    __________________
    Mitchell is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 07-07-2014 , 11:29   Re: Custom Player Skins (Core)
    Reply With Quote #8

    Quote:
    Originally Posted by Mitchell View Post
    Commit updated
    Thanks! Developers can really mess with this plugin, which is nice. You dont mind adding precache for custom player model automatically? So plugin makers will not be confused what crashes the server. Also add something like this to transmit hook to prevent players from seeing custom player skin of observed target.
    Code:
    new target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); if (IsValidEdict(target) && entity == EntRefToEntIndex(CPS_GetSkin(target))) {     return Plugin_Handled; }
    I also got a question about SetVariantString("forward"). I used it for hats plugin, cant see reason of using it here. AFAIK DoD:S have an attachment 'head' instead of generic 'forward' or 'eyes', so I would check engine version just to be clear.
    And SetEntityRenderMode(client, RENDER_NONE) added for preventing double model on a player or 'misanimations', right?
    Thanks in advance.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot

    Last edited by Root_; 07-07-2014 at 16:49.
    Root_ is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Location: noitacoL:
    Old 07-07-2014 , 16:52   Re: Custom Player Skins (Core)
    Reply With Quote #9

    Quote:
    Originally Posted by Root_ View Post
    Thanks! This plugin really can be very useful. You dont mind adding precache for custom player model automatically? So plugin developers will not be confused why it crashes. Also add something like this to OnShouldProp hook to prevent players from seeing custom player skin from firstperon of observed target.
    Code:
    new target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); if (IsValidClient(target) && entity == EntRefToEntIndex(CPS_GetSkin(target))) {     return Plugin_Handled; }
    I also got a question about SetVariantString("forward"). I used it for hats plugin, cant see reason of using it here. AFAIK DoD:S have an attachment 'head' instead of generic 'forward' or 'eyes', so I would check engine version just to be clear. And SetEntityRenderMode(client, RENDER_NONE) is for preventing double model on a player or 'misanimations', right?
    Thanks in advance.
    As for the precache, i will not be adding this, since all this plugin does is set the skin based on the path, and you should precache your models on MapStart() (or OnPluginStart, which ever one...)
    I can add the observer target.
    The "forward" attachment is so the prop will bonemerge to the model, I don't think i had tested it without though.
    The RenderMode is so the prop and the player is not rendered, as i didnt plan for it to be used for glows. I'll add in an argument that you can pass to ignore that feature.
    __________________
    Mitchell is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 07-07-2014 , 17:51   Re: Custom Player Skins (Core)
    Reply With Quote #10

    Quote:
    Originally Posted by Mitchell View Post
    As for the precache, i will not be adding this, since all this plugin does is set the skin based on the path, and you should precache your models on MapStart() (or OnPluginStart, which ever one...)
    Oh yeah, that makes sense. Didnt though bout that lol.
    Quote:
    Originally Posted by Mitchell View Post
    I can add the observer target.
    I'll add in an argument that you can pass to ignore that feature.
    I made a pull request, review it and accept changes please.
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot

    Last edited by Root_; 07-07-2014 at 20:34.
    Root_ is offline
    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

    Forum Jump


    All times are GMT -4. The time now is 20:58.


    Powered by vBulletin®
    Copyright ©2000 - 2018, vBulletin Solutions, Inc.
    Theme made by Freecode