Models replacement

Сообщения
458
Реакции
263
Помог
9 раз(а)
Алексеич, ошибка не исчезла, прописывал в конфиге без /cstrike/models/, ведь как я понял - это добавляется плагином, ошибка не исчезает но меняет букву, почему то, первоначально:
FATAL ERROR (shutting down): SV_ModelIndex: SV_ModelIndex: model z not precached
Сейчас:
FATAL ERROR (shutting down): SV_ModelIndex: SV_ModelIndex: model q not precached
 

fox

Сообщения
176
Реакции
49
Помог
7 раз(а)
malniata,
Код:
#define VERSION "0.0.1"

#define MAX_MODEL_LENGTH     64
#define MAX_PATH_LENGTH     128
#define MAX_PLAYERS            32
#define MAX_PARAMETERS        4

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define AllocString(%1)         engfunc(EngFunc_AllocString,%1)
#define SetModel(%1,%2)         engfunc(EngFunc_SetModel,%1,%2)
#define IsPlayer(%1)            (1 <= %1 <= g_iMaxPlayers)

#define PEV_CUSTOM_MODEL pev_iuser3
#define PEV_ADD_COUNTER pev_iuser4

const m_rgpPlayerItems_CWeaponBox = 34;
const XO_CBASEPLAYERWEAPON = 4;

new Trie:g_tViewModels
new Trie:g_tWeaponModels
new Trie:g_tWorldModels
new g_iAccess, g_iMaxPlayers

public plugin_precache()
{
    new szConfigFile[MAX_PATH_LENGTH], szMsg[128]
    get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
    add(szConfigFile, charsmax(szConfigFile), "/weapons_skins.ini")

    if(!file_exists(szConfigFile))
    {
        formatex(szMsg, charsmax(szMsg), "[ERROR] Config file ^"%s^" not found!", szConfigFile)
        set_fail_state(szMsg)
        return
    }
    new iFilePointer = fopen(szConfigFile, "rt")
    if(!iFilePointer)
    {
        return
    }

    new Trie:tRegisterWeaponDeploy = TrieCreate()
    new szDatas[192], szSetting[12], szSymb[3], szFlags[32]
    new szWeaponClass[32]
    new szViewModel[MAX_MODEL_LENGTH], szWeaponModel[MAX_MODEL_LENGTH], szWorldModel[MAX_MODEL_LENGTH]
    new szOldWorldModel[MAX_MODEL_LENGTH]

    while(!feof(iFilePointer))
    {
        fgets(iFilePointer, szDatas, charsmax(szDatas))
        trim(szDatas)
        if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#')
        {
            continue
        }
        if(equal(szDatas, "AccessFlag", 10))
        {
            parse(szDatas, szSetting, charsmax(szSetting), szSymb, charsmax(szSymb), szFlags, charsmax(szFlags))
            g_iAccess = read_flags(szFlags)
            continue
        }
        if(parse(szDatas, szWeaponClass, charsmax(szWeaponClass),
        szViewModel, charsmax(szViewModel), szWeaponModel, charsmax(szWeaponModel),
        szWorldModel, charsmax(szWorldModel)) == MAX_PARAMETERS)
        {
            if(!TrieKeyExists(tRegisterWeaponDeploy, szWeaponClass))
            {
                TrieSetCell
                (
                    tRegisterWeaponDeploy,
                    szWeaponClass,
                    RegisterHam(Ham_Item_Deploy, szWeaponClass, "ItemDeploy_Post", true)
                )
                RegisterHam(Ham_AddPlayerItem, "player", "AddPlayerItem_Pre", 0)
            }
            format(szViewModel, charsmax(szViewModel), "models/%s.mdl", szViewModel)
            if(file_exists(szViewModel))
            {
                if(!g_tViewModels)
                {
                    g_tViewModels = TrieCreate()
                }
                TrieSetCell(g_tViewModels, szWeaponClass, AllocString(szViewModel))
                precache_model(szViewModel)
            }
            format(szWeaponModel, charsmax(szWeaponModel), "models/%s.mdl", szWeaponModel)
            if(file_exists(szWeaponModel))
            {
                if(!g_tWeaponModels)
                {
                    g_tWeaponModels = TrieCreate()
                }
                TrieSetCell(g_tWeaponModels, szWeaponClass, AllocString(szWeaponModel))
                precache_model(szWeaponModel)
            }
            format(szWorldModel, charsmax(szWorldModel), "models/%s.mdl", szWorldModel)
            if(file_exists(szWorldModel))
            {
                if(!g_tWorldModels)
                {
                    g_tWorldModels = TrieCreate()
                }
                if(szWeaponClass[10] == 'n') // weapon_mp5navy
                {
                    // replace(szWeaponClass, charsmax(szWeaponClass), "navy", "")
                    szWeaponClass[10] = EOS
                }
                formatex(szOldWorldModel, charsmax(szOldWorldModel), "models/w_%s.mdl", szWeaponClass[7])
                if(!TrieKeyExists(g_tWorldModels, szOldWorldModel))
                {
                    TrieSetString(g_tWorldModels, szOldWorldModel, szWorldModel)
                    precache_model(szWorldModel)
                }
            }
        }
    }
    fclose(iFilePointer)
    TrieDestroy(tRegisterWeaponDeploy)
}

public plugin_init()
{
    register_plugin("Weapons Skins Manager", VERSION, "Vaqtincha")

    if(g_tWorldModels)
    {
        register_forward(FM_SetModel, "SetModel_Pre", 0)
    }
    g_iMaxPlayers = get_maxplayers()
}

public ItemDeploy_Post(wEnt)
{
    if(wEnt <= 0)
        return

    const m_pPlayer = 41

    new id = get_pdata_cbase(wEnt, m_pPlayer, .linuxdiff = 4)
    if(IsPlayer(id) && pev(wEnt, PEV_CUSTOM_MODEL))
    {
        new iszNewModel, szWeaponClass[32]
        pev(wEnt, pev_classname, szWeaponClass, charsmax(szWeaponClass))
        if(g_tViewModels)
        {
            if(TrieGetCell(g_tViewModels, szWeaponClass, iszNewModel))
            {
                set_pev(id, pev_viewmodel, iszNewModel)
            }
        }
        if(g_tWeaponModels)
        {
            if(TrieGetCell(g_tWeaponModels, szWeaponClass, iszNewModel))
            {
                set_pev(id, pev_weaponmodel, iszNewModel)
            }
        }
    }
}

public AddPlayerItem_Pre(player, weapon)
{
    if ((get_user_flags(player) & g_iAccess) && !pev(weapon, PEV_ADD_COUNTER)) {
        set_pev(weapon, PEV_CUSTOM_MODEL, 1)
    }

    set_pev(weapon, PEV_ADD_COUNTER, 1)
}

public SetModel_Pre(iEnt, const szModel[])
{
    // if(!pev_valid(iEnt))
        // return FMRES_IGNORED

    new id = pev(iEnt, pev_owner)
    if(!IsPlayer(id))
        return FMRES_IGNORED

    #define MAX_ITEM_TYPES    6
    for(new i, weapon; i < MAX_ITEM_TYPES; i++) {
        weapon = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox + i, XO_CBASEPLAYERWEAPON);

        if (pev_valid(weapon) == 2 && pev(weapon, PEV_CUSTOM_MODEL)) {
            new szNewModel[MAX_MODEL_LENGTH]
            if(TrieGetString(g_tWorldModels, szModel, szNewModel, charsmax(szNewModel)))
            {
                SetModel(iEnt, szNewModel)
                return FMRES_SUPERCEDE
            }
        }
    }

    return FMRES_IGNORED
}

public plugin_end()
{
    if(g_tViewModels)
        TrieDestroy(g_tViewModels)
    if(g_tWeaponModels)
        TrieDestroy(g_tWeaponModels)
    if(g_tWorldModels)
        TrieDestroy(g_tWorldModels)
}


Код:
; 'Weapons Skins Manager' config file.

;=============================================================================

; ● Defualt access flags:
AccessFlag = "t"

;=============================== MODELS =================================

; ● If you get this error: [HAMSANDWICH] Failed to retrieve classtype for "weapon_xxx"
; You have to check for mistakes in weapon names.

; ● Valid weapon names:
; weapon_elite, weapon_fiveseven, weapon_usp, weapon_glock18, weapon_p228, weapon_deagle
; weapon_scout, weapon_xm1014, weapon_mac10, weapon_aug, weapon_ump45, weapon_sg550,
; weapon_galil, weapon_famas, weapon_awp, weapon_mp5navy, weapon_m249, weapon_m3,
; weapon_m4a1, weapon_tmp, weapon_g3sg1, weapon_sg552, weapon_ak47, weapon_p90
; weapon_knife, weapon_c4 weapon_flashbang, weapon_hegrenade, weapon_smokegrenade

; ● Format:
; "weaponname" "v_model" "p_model" "w_model" (without 'models/' & '.mdl')

; ● Examples:
; Set awp model
; "weapon_awp" "custom/v_awp" "custom/p_awp" "custom/w_awp"

; Set knife model without 'w_' model
; "weapon_knife" "custom/v_knife" "custom/p_knife" ""

; ● Notes:
; Do not forget about the precache limit 512!
"weapon_deagle" "custom/v_deagle" "custom/p_deagle" "custom/w_deagle"
"weapon_famas" "custom/v_famas" "custom/p_famas" "custom/w_famas"
"weapon_ak47" "custom/v_ak47" "custom/p_ak47" "custom/w_ak47"
"weapon_m4a1" "custom/v_m4a1" "custom/p_m4a1" "custom/w_m4a1"
"weapon_awp" "custom/v_awp" "custom/p_awp" "custom/w_awp"
 
Сообщения
458
Реакции
263
Помог
9 раз(а)
Если нужно заменить стандартные модели на какие-то другие, можно воспользоваться также модулем Ultimate Unprecacher.
и тут я понял, что ничего не понял

models/w_ak47.mdl c custom/ak47/w_ak47_c.mdl
FATAL ERROR (shutting down): Mod_LoadModel: custom/ak47/w_ak47_c.mdl not found
Безымянный.png
 
Сообщения
458
Реакции
263
Помог
9 раз(а)
malniata,
Код:
#define VERSION "0.0.1"

#define MAX_MODEL_LENGTH     64
#define MAX_PATH_LENGTH     128
#define MAX_PLAYERS            32
#define MAX_PARAMETERS        4

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define AllocString(%1)         engfunc(EngFunc_AllocString,%1)
#define SetModel(%1,%2)         engfunc(EngFunc_SetModel,%1,%2)
#define IsPlayer(%1)            (1 <= %1 <= g_iMaxPlayers)

#define PEV_CUSTOM_MODEL pev_iuser3
#define PEV_ADD_COUNTER pev_iuser4

const m_rgpPlayerItems_CWeaponBox = 34;
const XO_CBASEPLAYERWEAPON = 4;

new Trie:g_tViewModels
new Trie:g_tWeaponModels
new Trie:g_tWorldModels
new g_iAccess, g_iMaxPlayers

public plugin_precache()
{
    new szConfigFile[MAX_PATH_LENGTH], szMsg[128]
    get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
    add(szConfigFile, charsmax(szConfigFile), "/weapons_skins.ini")

    if(!file_exists(szConfigFile))
    {
        formatex(szMsg, charsmax(szMsg), "[ERROR] Config file ^"%s^" not found!", szConfigFile)
        set_fail_state(szMsg)
        return
    }
    new iFilePointer = fopen(szConfigFile, "rt")
    if(!iFilePointer)
    {
        return
    }

    new Trie:tRegisterWeaponDeploy = TrieCreate()
    new szDatas[192], szSetting[12], szSymb[3], szFlags[32]
    new szWeaponClass[32]
    new szViewModel[MAX_MODEL_LENGTH], szWeaponModel[MAX_MODEL_LENGTH], szWorldModel[MAX_MODEL_LENGTH]
    new szOldWorldModel[MAX_MODEL_LENGTH]

    while(!feof(iFilePointer))
    {
        fgets(iFilePointer, szDatas, charsmax(szDatas))
        trim(szDatas)
        if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#')
        {
            continue
        }
        if(equal(szDatas, "AccessFlag", 10))
        {
            parse(szDatas, szSetting, charsmax(szSetting), szSymb, charsmax(szSymb), szFlags, charsmax(szFlags))
            g_iAccess = read_flags(szFlags)
            continue
        }
        if(parse(szDatas, szWeaponClass, charsmax(szWeaponClass),
        szViewModel, charsmax(szViewModel), szWeaponModel, charsmax(szWeaponModel),
        szWorldModel, charsmax(szWorldModel)) == MAX_PARAMETERS)
        {
            if(!TrieKeyExists(tRegisterWeaponDeploy, szWeaponClass))
            {
                TrieSetCell
                (
                    tRegisterWeaponDeploy,
                    szWeaponClass,
                    RegisterHam(Ham_Item_Deploy, szWeaponClass, "ItemDeploy_Post", true)
                )
                RegisterHam(Ham_AddPlayerItem, "player", "AddPlayerItem_Pre", 0)
            }
            format(szViewModel, charsmax(szViewModel), "models/%s.mdl", szViewModel)
            if(file_exists(szViewModel))
            {
                if(!g_tViewModels)
                {
                    g_tViewModels = TrieCreate()
                }
                TrieSetCell(g_tViewModels, szWeaponClass, AllocString(szViewModel))
                precache_model(szViewModel)
            }
            format(szWeaponModel, charsmax(szWeaponModel), "models/%s.mdl", szWeaponModel)
            if(file_exists(szWeaponModel))
            {
                if(!g_tWeaponModels)
                {
                    g_tWeaponModels = TrieCreate()
                }
                TrieSetCell(g_tWeaponModels, szWeaponClass, AllocString(szWeaponModel))
                precache_model(szWeaponModel)
            }
            format(szWorldModel, charsmax(szWorldModel), "models/%s.mdl", szWorldModel)
            if(file_exists(szWorldModel))
            {
                if(!g_tWorldModels)
                {
                    g_tWorldModels = TrieCreate()
                }
                if(szWeaponClass[10] == 'n') // weapon_mp5navy
                {
                    // replace(szWeaponClass, charsmax(szWeaponClass), "navy", "")
                    szWeaponClass[10] = EOS
                }
                formatex(szOldWorldModel, charsmax(szOldWorldModel), "models/w_%s.mdl", szWeaponClass[7])
                if(!TrieKeyExists(g_tWorldModels, szOldWorldModel))
                {
                    TrieSetString(g_tWorldModels, szOldWorldModel, szWorldModel)
                    precache_model(szWorldModel)
                }
            }
        }
    }
    fclose(iFilePointer)
    TrieDestroy(tRegisterWeaponDeploy)
}

public plugin_init()
{
    register_plugin("Weapons Skins Manager", VERSION, "Vaqtincha")

    if(g_tWorldModels)
    {
        register_forward(FM_SetModel, "SetModel_Pre", 0)
    }
    g_iMaxPlayers = get_maxplayers()
}

public ItemDeploy_Post(wEnt)
{
    if(wEnt <= 0)
        return

    const m_pPlayer = 41

    new id = get_pdata_cbase(wEnt, m_pPlayer, .linuxdiff = 4)
    if(IsPlayer(id) && pev(wEnt, PEV_CUSTOM_MODEL))
    {
        new iszNewModel, szWeaponClass[32]
        pev(wEnt, pev_classname, szWeaponClass, charsmax(szWeaponClass))
        if(g_tViewModels)
        {
            if(TrieGetCell(g_tViewModels, szWeaponClass, iszNewModel))
            {
                set_pev(id, pev_viewmodel, iszNewModel)
            }
        }
        if(g_tWeaponModels)
        {
            if(TrieGetCell(g_tWeaponModels, szWeaponClass, iszNewModel))
            {
                set_pev(id, pev_weaponmodel, iszNewModel)
            }
        }
    }
}

public AddPlayerItem_Pre(player, weapon)
{
    if ((get_user_flags(player) & g_iAccess) && !pev(weapon, PEV_ADD_COUNTER)) {
        set_pev(weapon, PEV_CUSTOM_MODEL, 1)
    }

    set_pev(weapon, PEV_ADD_COUNTER, 1)
}

public SetModel_Pre(iEnt, const szModel[])
{
    // if(!pev_valid(iEnt))
        // return FMRES_IGNORED

    new id = pev(iEnt, pev_owner)
    if(!IsPlayer(id))
        return FMRES_IGNORED

    #define MAX_ITEM_TYPES    6
    for(new i, weapon; i < MAX_ITEM_TYPES; i++) {
        weapon = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox + i, XO_CBASEPLAYERWEAPON);

        if (pev_valid(weapon) == 2 && pev(weapon, PEV_CUSTOM_MODEL)) {
            new szNewModel[MAX_MODEL_LENGTH]
            if(TrieGetString(g_tWorldModels, szModel, szNewModel, charsmax(szNewModel)))
            {
                SetModel(iEnt, szNewModel)
                return FMRES_SUPERCEDE
            }
        }
    }

    return FMRES_IGNORED
}

public plugin_end()
{
    if(g_tViewModels)
        TrieDestroy(g_tViewModels)
    if(g_tWeaponModels)
        TrieDestroy(g_tWeaponModels)
    if(g_tWorldModels)
        TrieDestroy(g_tWorldModels)
}


Код:
; 'Weapons Skins Manager' config file.

;=============================================================================

; ● Defualt access flags:
AccessFlag = "t"

;=============================== MODELS =================================

; ● If you get this error: [HAMSANDWICH] Failed to retrieve classtype for "weapon_xxx"
; You have to check for mistakes in weapon names.

; ● Valid weapon names:
; weapon_elite, weapon_fiveseven, weapon_usp, weapon_glock18, weapon_p228, weapon_deagle
; weapon_scout, weapon_xm1014, weapon_mac10, weapon_aug, weapon_ump45, weapon_sg550,
; weapon_galil, weapon_famas, weapon_awp, weapon_mp5navy, weapon_m249, weapon_m3,
; weapon_m4a1, weapon_tmp, weapon_g3sg1, weapon_sg552, weapon_ak47, weapon_p90
; weapon_knife, weapon_c4 weapon_flashbang, weapon_hegrenade, weapon_smokegrenade

; ● Format:
; "weaponname" "v_model" "p_model" "w_model" (without 'models/' & '.mdl')

; ● Examples:
; Set awp model
; "weapon_awp" "custom/v_awp" "custom/p_awp" "custom/w_awp"

; Set knife model without 'w_' model
; "weapon_knife" "custom/v_knife" "custom/p_knife" ""

; ● Notes:
; Do not forget about the precache limit 512!
"weapon_deagle" "custom/v_deagle" "custom/p_deagle" "custom/w_deagle"
"weapon_famas" "custom/v_famas" "custom/p_famas" "custom/w_famas"
"weapon_ak47" "custom/v_ak47" "custom/p_ak47" "custom/w_ak47"
"weapon_m4a1" "custom/v_m4a1" "custom/p_m4a1" "custom/w_m4a1"
"weapon_awp" "custom/v_awp" "custom/p_awp" "custom/w_awp"
Спасибо, работает. НО, сервер падает не выдавая ошибку при переходе с команды CT со скином в руках за команду TT, обратно же все нормально
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу