Raised This Month: $ Target: $400
 0% 

player model problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 10-26-2009 , 01:13   Re: player model problems
Reply With Quote #1

Quote:
Originally Posted by Arkshine View Post
Try to use this method instead.
I used his plugin, it works but there is a problem. When someone switches from CT to T, they still have the CT models. I need it so if they get switched by the server to the opposite team, the newly found T will have the specified T model instead of the CT model.

Here is the .sma and here is my .ini file...

Code:
/*    Formatright © 2009, ConnorMcLeod

    Players Models is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Players Models; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#pragma semicolon 1

#define VERSION "1.2.1"

#define SetUserModeled(%1)        g_bModeled |= 1<<(%1 & 31)
#define SetUserNotModeled(%1)        g_bModeled &= ~( 1<<(%1 & 31) )
#define IsUserModeled(%1)        ( g_bModeled &  1<<(%1 & 31) )

#define SetUserConnected(%1)        g_bConnected |= 1<<(%1 & 31)
#define SetUserNotConnected(%1)        g_bConnected &= ~( 1<<(%1 & 31) )
#define IsUserConnected(%1)        ( g_bConnected &  1<<(%1 & 31) )

#define MAX_MODEL_LENGTH    16
#define MAX_AUTHID_LENGTH 25

#define MAX_PLAYERS    32

#define ClCorpse_ModelName 1
#define ClCorpse_PlayerID 12

#define g_ulModelIndexPlayer 491

new const g_szDefaultModels[][] = {"", "urban", "terror", "leet", "arctic", "gsg9", 
                    "gign", "sas", "guerilla", "vip", "militia", "spetsnaz" };

new const MODEL[] = "model";
new g_bModeled;
new g_szCurrentModel[MAX_PLAYERS+1][MAX_MODEL_LENGTH];

new Trie:g_tTeamModels[2];
new Trie:g_tModelIndexes;

new g_szNewModels[12][MAX_MODEL_LENGTH];

new g_szAuthid[MAX_PLAYERS+1][MAX_AUTHID_LENGTH];
new g_bPersonalModel[MAX_PLAYERS+1];

new g_bConnected;

public plugin_init()
{
    register_plugin("Players Models", VERSION, "ConnorMcLeod");

    register_forward(FM_SetClientKeyValue, "SetClientKeyValue");
    register_message(get_user_msgid("ClCorpse"), "Message_ClCorpse");
}

public plugin_precache()
{
    new szConfigFile[128];
    get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile));
    format(szConfigFile, charsmax(szConfigFile), "%s/players_models.ini", szConfigFile);

    new iFile = fopen(szConfigFile, "rt");
    if( iFile )
    {
        new Trie:tDefaultModels = TrieCreate();
        for(new i=1; i<sizeof(g_szDefaultModels); i++)
        {
            TrieSetCell(tDefaultModels, g_szDefaultModels[i], i);
        }

        g_tModelIndexes = TrieCreate();

        g_tTeamModels[0] = TrieCreate();
        g_tTeamModels[1] = TrieCreate();

        new szDatas[70], szRest[40], szKey[MAX_AUTHID_LENGTH], szModel1[MAX_MODEL_LENGTH], szModel2[MAX_MODEL_LENGTH], iVal;
        while( !feof(iFile) )
        {
            fgets(iFile, szDatas, charsmax(szDatas));
            trim(szDatas);
            if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#' || (szDatas[0] == '/' && szDatas[1] == '/'))
            {
                continue;
            }

            strbreak(szDatas, szKey, charsmax(szKey), szRest, charsmax(szRest));

            if( TrieGetCell(tDefaultModels, szKey, iVal) )
            {
                parse(szRest, szModel1, charsmax(szModel1));
                if( szModel1[0] && PrecachePlayerModel(szModel1) )
                {
                    formatex(g_szNewModels[iVal], MAX_MODEL_LENGTH-1, szModel1);
                }
            }
            else if( equal(szKey, "STEAM_", 6) || equal(szKey, "BOT") )
            {
                parse(szRest, szModel1, charsmax(szModel1), szModel2, charsmax(szModel2));
                if( szModel1[0] && PrecachePlayerModel(szModel1) )
                {
                    TrieSetString(g_tTeamModels[1], szKey, szModel1);
                }
                if( szModel2[0] && PrecachePlayerModel(szModel2) )
                {
                    TrieSetString(g_tTeamModels[0], szKey, szModel2);
                }
            }
        }
        TrieDestroy(tDefaultModels);
        fclose( iFile );
    }
}

PrecachePlayerModel( const szModel[] )
{
    if( TrieKeyExists(g_tModelIndexes, szModel) )
    {
        return 1;
    }

    new szFileToPrecache[64];
    formatex(szFileToPrecache, charsmax(szFileToPrecache), "models/player/%s/%s.mdl", szModel, szModel);
    if( !file_exists( szFileToPrecache ) )
    {
        return 0;
    }

    TrieSetCell(g_tModelIndexes, szModel, precache_model(szFileToPrecache));

    formatex(szFileToPrecache, charsmax(szFileToPrecache), "models/player/%s/%st.mdl", szModel, szModel);
    if( file_exists( szFileToPrecache ) )
    {
        precache_model(szFileToPrecache);
        return 1;
    }
    formatex(szFileToPrecache, charsmax(szFileToPrecache), "models/player/%s/%sT.mdl", szModel, szModel);
    if( file_exists( szFileToPrecache ) )
    {
        precache_model(szFileToPrecache);
        return 1;
    }

    return 1;
}

public plugin_end()
{
    TrieDestroy(g_tTeamModels[0]);
    TrieDestroy(g_tTeamModels[1]);
    TrieDestroy(g_tModelIndexes);
}

public client_authorized( id )
{
    get_user_authid(id, g_szAuthid[id], MAX_AUTHID_LENGTH-1);

    for(new i=1; i<=2; i++)
    {
        if( TrieKeyExists(g_tTeamModels[2-i], g_szAuthid[id]) )
        {
            g_bPersonalModel[id] |= i;
        }
        else
        {
            g_bPersonalModel[id] &= ~i;
        }
    }
}

public client_putinserver(id)
{
    if( !is_user_hltv(id) )
    {
        SetUserConnected(id);
    }
}

public client_disconnect(id)
{
    g_bPersonalModel[id] = 0;
    SetUserNotModeled(id);
    SetUserNotConnected(id);
}

public SetClientKeyValue(id, const szInfoBuffer[], const szKey[], const szValue[])
{
    if( equal(szKey, MODEL) && IsUserConnected(id) )
    {
        new iInternalModel;
        new iTeam = _:cs_get_user_team(id, iInternalModel);
        if( 1 <= iTeam <= 2 )
        {
            new szSupposedModel[MAX_MODEL_LENGTH];

            if( g_bPersonalModel[id] & iTeam )
            {
                TrieGetString(g_tTeamModels[2-iTeam], g_szAuthid[id], szSupposedModel, charsmax(szSupposedModel));
            }
            else
            {
                formatex(szSupposedModel, charsmax(szSupposedModel), g_szNewModels[iInternalModel]);
            }

            if( szSupposedModel[0] )
            {
                if(    !IsUserModeled(id)
                ||    !equal(g_szCurrentModel[id], szSupposedModel)
                ||    !equal(szValue, szSupposedModel)    )
                {
                    formatex(g_szCurrentModel[id], MAX_MODEL_LENGTH-1, szSupposedModel);
                    SetUserModeled(id);
                    set_user_info(id, MODEL, szSupposedModel);
                    new iModelIndex;
                    TrieGetCell(g_tModelIndexes, szSupposedModel, iModelIndex);
                    set_pev(id, pev_modelindex, iModelIndex);
                    set_pdata_int(id, g_ulModelIndexPlayer, iModelIndex);
                    return FMRES_SUPERCEDE;
                }
            }

            if( IsUserModeled(id) )
            {
                SetUserNotModeled(id);
                g_szCurrentModel[id][0] = 0;
            }
        }
    }
    return FMRES_IGNORED;
}

public Message_ClCorpse()
{
    new id = get_msg_arg_int(ClCorpse_PlayerID);
    if( IsUserModeled(id) )
    {
        set_msg_arg_string(ClCorpse_ModelName, g_szCurrentModel[id]);
    }
}
.ini file:

Code:
; replace default skins
;"defaultname" "newname"

; set skin according to steamid
;"STEAM_0:1:23456789" "terrorist_model" "ct_model"
;"BOT" "bot_te_model" "bot_ct_model"

"terror" "Prisoner"
"guerilla" "Prisoner"
"arctic" "Prisoner"
"militia" "Prisoner"
"urban" "Guard"
"gign" "Guard"
"gsg9" "Guard"
"sas" "Guard"

"STEAM_0:0:xxx484xx" "Prisoner" "Admin"

"STEAM_0:1:x46xxx" "Prisoner" "Admin"

"STEAM_0:1:x460xx" "Prisoner" "Admin"

"STEAM_0:1:x93xxxxx" "Prisoner" "Admin"

"STEAM_0:0:xx992xxx" "Prisoner" "Admin"

"STEAM_0:1:xx951xx" "Prisoner" "Admin"

"STEAM_0:0:xx2xxxx" "Prisoner" "Admin"

"STEAM_0:1:xx12xxx" "Prisoner" "Admin"
Any suggestions?
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 10-26-2009 at 01:16.
drumzplaya13 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-26-2009 , 02:15   Re: player model problems
Reply With Quote #2

Quote:
Originally Posted by drumzplaya13 View Post
Any suggestions?
Read the whole thread about the plugin would have driven you to that post : http://forums.alliedmods.net/showthr...434#post966434

Also, if you want support about that plugin, don't post anywhere but on the plugin thread.


Should be fixed in v1.3.0
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-03-2009 at 04:43.
ConnorMcLeod is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 10-26-2009 , 02:39   Re: player model problems
Reply With Quote #3

Yes I know it leads me to that thread, Ive been using your plugin for 2 days now on my new server, and I was quoting him. Sorry, I will reply in your original plugin thread Conner. Usually when I do that for most plugins, no one seems to answer anymore but since I know your alive I will.
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 10-26-2009 at 02:53.
drumzplaya13 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 17:47.


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