AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [TFC] Check if model has skins (https://forums.alliedmods.net/showthread.php?t=294557)

DarthMan 03-01-2017 18:45

[TFC] Check if model has skins
 
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 !

SpannerSpammer 03-02-2017 03:41

Re: [TFC] Check if model has skins
 
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

DarthMan 03-02-2017 05:35

Re: [TFC] Check if model has skins
 
Quote:

Originally Posted by SpannerSpammer (Post 2499965)
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.


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

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