Raised This Month: $ Target: $400
 0% 

[TFC] Check if model has skins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-01-2017 , 18:45   [TFC] Check if model has skins
Reply With Quote #1

Hello. Is there any way to check if a custom model (Team Fortress Classic) has skins and how many?
I've been looking all over the internet without any luck. Thanks a lot for reading the message !
DarthMan is offline
SpannerSpammer
Member
Join Date: Mar 2006
Old 03-02-2017 , 03:41   Re: [TFC] Check if model has skins
Reply With Quote #2

Quote:
Originally Posted by DarthMan
I've been looking all over the internet without any luck.
There's a reason for that: I don't think anyone has ever needed
to or done anything like that before. It's easy to do in C++:
Code:
int GetNumSkins( edict_t *pEntity )
{
	void *pmodel = GET_MODEL_PTR( pEntity );
	studiohdr_t *pstudiohdr;
	pstudiohdr = (studiohdr_t *)pmodel;
	if (!pstudiohdr) return 0;
	int iRet = pstudiohdr->numskinfamilies;
	if( iRet < 0 ) iRet = 0;

	return iRet;
}
It's not so easy to do in PAWN. You would have to open the MDL file in binary mode
then fseek to the part of the file that contains the model data (i.e. an offset
value from the beginning of the file since the model data is stored after bone,
animation and sequence data). Then you could either fseek directly to skin data if
you know the offset value OR you could read the entire model studiohdr_t data
structure into an enumerated "struct" and extract the skin info from there.


EDIT: numskinfamilies is the correct skin count data variable.


See this thread for reference:
https://forums.alliedmods.net/showthread.php?t=178658
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf

Last edited by SpannerSpammer; 03-04-2017 at 03:21. Reason: Fixed incorrect skin variable
SpannerSpammer is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 05:35   Re: [TFC] Check if model has skins
Reply With Quote #3

Quote:
Originally Posted by SpannerSpammer View Post
There's a reason for that: I don't think anyone has ever needed
to or done anything like that before. It's easy to do in C++:
Code:
int GetNumSkins( edict_t *pEntity )
{
	void *pmodel = GET_MODEL_PTR( pEntity );
	studiohdr_t *pstudiohdr;
	pstudiohdr = (studiohdr_t *)pmodel;
	if (!pstudiohdr) return 0;
	int iRet = pstudiohdr->numskinref;
	if( iRet < 0 ) iRet = 0;

	return iRet;
}
It's not so easy to do in PAWN. You would have to open the MDL file in binary mode
then fseek to the part of the file that contains the model data (i.e. an offset
value from the beginning of the file since the model data is stored after bone,
animation and sequence data). Then you could either fseek directly to skin data if
you know the offset value OR you could read the entire model studiohdr_t data
structure into an enumerated "struct" and extract the skin info from there.

See this thread for reference:
https://forums.alliedmods.net/showthread.php?t=178658
Well, this si required for my tfc server. FM has a menu plugin that for models that if a model has more skins, it shows the skins tab.
DarthMan 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 20:58.


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