AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] How can I change cosmetic styles with scripting? (https://forums.alliedmods.net/showthread.php?t=340214)

PC Gamer 11-03-2022 05:36

[TF2] How can I change cosmetic styles with scripting?
 
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.

luki1412 11-18-2022 15:41

Re: [TF2] How can I change cosmetic styles with scripting?
 
Have you tried using the attribute "item style override"?

PC Gamer 11-18-2022 18:28

Re: [TF2] How can I change cosmetic styles with scripting?
 
Quote:

Originally Posted by luki1412 (Post 2793163)
Have you tried using the attribute "item style override"?

Wow! That worked! Thanks for providing an answer!
:bacon!:


All times are GMT -4. The time now is 21:04.

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