Raised This Month: $ Target: $400
 0% 

[STOCK]Set a prop's skin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iloveportalz0r
Member
Join Date: May 2010
Location: Up yours
Old 06-04-2010 , 20:38   [STOCK]Set a prop's skin
Reply With Quote #1

I was messing with SetEntityRenderFx and SetEntityRenderColor for my build server on HL2DM and noticed that there was no SetEntitySkin function in SourceMod, so here's one for people who don't know how to make one themselves. Just copy and paste this into addons/sourcemod/scripting/include/entity_prop_stocks.inc

/**
* Sets an entity's skin.
*
* @param entity Entity index.
* @param skin Skin value.
* @noreturn
* @error Invalid entity index, or lack of mod compliance.
*/
stock SetEntitySkin(entity, Skin:skin)
{
static bool:gotconfig = false;
static String:prop[32];

if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nSkin", prop, sizeof(prop));
CloseHandle(gc);

if (!exists)
{
strcopy(prop, sizeof(prop), "m_nSkin");
}

gotconfig = true;
}

SetEntProp(entity, Prop_Send, prop, skin, 1);
}
__________________
I sure was dumb in 2010
iloveportalz0r is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 06-04-2010 , 21:59   Re: [STOCK]Set a prop's skin
Reply With Quote #2

You didn't find SetEntitySkin because sdktools' SetEntityModel(entity, const String:model[]) does the job 0.o'
Sammy-ROCK! is offline
iloveportalz0r
Member
Join Date: May 2010
Location: Up yours
Old 06-04-2010 , 22:49   Re: [STOCK]Set a prop's skin
Reply With Quote #3

Quote:
Originally Posted by Sammy-ROCK! View Post
You didn't find SetEntitySkin because sdktools' SetEntityModel(entity, const String:model[]) does the job 0.o'
It's simpler with a SetEntitySkin function, instead of having to find that SetEntityModel thing and figure out how to use it. It looks like all it does is set a prop's model, as the name suggests.
__________________
I sure was dumb in 2010

Last edited by iloveportalz0r; 06-04-2010 at 22:51.
iloveportalz0r is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-05-2010 , 08:55   Re: [STOCK]Set a prop's skin
Reply With Quote #4

You don't really need a stock for this. Other than the single line to set the prop, your only other logic is to look for the name of the prop in core.games gamedata, which it will never actually fine unless someone adds it there manually.

PHP Code:
SetEntProp(entProp_Send"m_nSkin"value); 
This is all that is needed. It's the same as setting any other netprop.

@Sammy-ROCK!
SetEntityModel sets the model as the function name suggests. A model can have multiple skins (textures) in it.
psychonic is offline
iloveportalz0r
Member
Join Date: May 2010
Location: Up yours
Old 07-17-2010 , 22:05   Re: [STOCK]Set a prop's skin
Reply With Quote #5

Cool. I didn't know about SetEntProp when I posted this though, sorry.
__________________
I sure was dumb in 2010
iloveportalz0r 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 21:53.


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