Raised This Month: $32 Target: $400
 8% 

Solved [TF2] How can I change cosmetic styles with scripting?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 11-03-2022 , 05:36   [TF2] How can I change cosmetic styles with scripting?
Reply With Quote #1

I'd like to change the style of a cosmetic style of the Team Fortress 2 'Caped Crusader' cosmetic from 'Vigilante' to 'Team Playa'. In other words, change the color of Batman's cape from black to team color. However, I have no idea how to do it since it requires a change in the style. Can you help?

I thought this piece of code might do it but I was wrong:
PHP Code:
SetEntData(hatFindSendPropInfo(entclass"m_nSkin"), style); 
I also found and tried this from SMLIB. No luck.
PHP Code:
/**
 * Sets the entity's model index (must be precached)
 *
 * @param entity            Entity index.
 * @param index                Model Index.
 * @noreturn
 */
stock Entity_SetModelIndex(entityindex)
{
    
SetEntProp(entityProp_Data"m_nModelIndex"index2);

Any ideas?

Update: I received this piece of code from Lugui on the AlliedModders Discord:
PHP Code:
int model PrecacheModel("models/workshop/player/items/soldier/bak_caped_crusader/bak_caped_crusader.mdl"false);
for(
int i 04i++) {
  
SetEntProp(itemEntProp_Send"m_nModelIndexOverrides"model4i);

Bad News: The code snippet provided by Lugui does not work with the Caped Crusader cosmetic. Most likely because this method only works when there is a different model used for the different style.

Good News: I tested the code snippet provided by Lugui and it does work when there is a different model used by the style, such as the Pest's Pads cosmetic for the Scout.

I'll leave this post as unsolved since I would still like to know how to change the style on the Caped Crusader with code.

Last edited by PC Gamer; 11-18-2022 at 19:21.
PC Gamer is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 11-18-2022 , 15:41   Re: [TF2] How can I change cosmetic styles with scripting?
Reply With Quote #2

Have you tried using the attribute "item style override"?
__________________
luki1412 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 11-18-2022 , 18:28   Re: [TF2] How can I change cosmetic styles with scripting?
Reply With Quote #3

Quote:
Originally Posted by luki1412 View Post
Have you tried using the attribute "item style override"?
Wow! That worked! Thanks for providing an answer!
PC Gamer is offline
Reply



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 01:21.


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