View Single Post
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 07-27-2023 , 21:08   Re: Reapi Weapon Models
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
try this one,

position from array V/P_MODELS of the models must be the same as weaponid

PHP Code:
#include <amxmodx>
#include <reapi>

#define PLUGIN  "[Reapi] Replace Weapon Models"
#define VERSION "1.0"
#define AUTHOR  "[N]drs"

#define rg_get_weapon_id(%0) get_member(get_member(get_member(%0, m_pPlayer), m_pActiveItem), m_iId)

static const SKIN_FLAGS[] = "cd"

static const V_MODELS[] =
{
    
"path/to/v_model/",
    
"path/to/v_model/",
    
"path/to/v_model/",
    
"path/to/v_model/",
    
"path/to/v_model/",
}

static const 
P_MODELS[] =
{
    
"path/to/p_model/",
    
"path/to/p_model/",
    
"path/to/p_model/",
    
"path/to/p_model/",
    
"path/to/p_model/"
}

new 
bool:g_bCanHaveSkin[MAX_PLAYERS 1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy"OnPlayerChangeWeapon_Pre"false)
}

public 
plugin_precache()
{
    for(new 
isizeof(V_MODELS); i++)
    {
        if(
file_exists(V_MODELS[i]))
        {
            
precache_model(V_MODELS[i])
        }
        else 
        {
            
server_print("Model %s does not exists"V_MODELS[i])
        }
    }

    for(new 
isizeof(P_MODELS); i++)
    {
        if(
file_exists(P_MODELS[i]))
        {
            
precache_model(P_MODELS[i])
        }
        else 
        {
            
server_print("Model %s does not exists"P_MODELS[i])
        }
    }
}

public 
client_putinserver(id)
{
    
g_bCanHaveSkin[id] = bool:(get_user_flags(id) & read_flags(SKIN_FLAGS))
}

public 
OnPlayerChangeWeapon_Pre(const idszViewModel[], szWeaponModel[])
{
    if(!
g_bCanHaveSkin[id])
    {
        return 
HC_CONTINUE
    
}

    static 
iWeaponID;
    
iWeaponID rg_get_weapon_id(id)
    
SetHookChainArg(2ATYPE_STRINGV_MODELS[iWeaponID])
    
SetHookChainArg(3ATYPE_STRINGP_MODELS[iWeaponID])

    return 
HC_CONTINUE


All models show:
Model odels/guns2024/p_scout.mdl does not exists
Model dels/guns2024/p_scout.mdl does not exists
Model els/guns2024/p_scout.mdl does not exists
Model ls/guns2024/p_scout.mdl does not exists
Model s/guns2024/p_scout.mdl does not exists
Model /guns2024/p_scout.mdl does not exists
Model guns2024/p_scout.mdl does not exists
Model uns2024/p_scout.mdl does not exists
Model ns2024/p_scout.mdl does not exists
Model s2024/p_scout.mdl does not exists
Model 2024/p_scout.mdl does not exists
Model 024/p_scout.mdl does not exists
Model 24/p_scout.mdl does not exists
Model 4/p_scout.mdl does not exists
Model /p_scout.mdl does not exists
Model p_scout.mdl does not exists
Model _scout.mdl does not exists
Model scout.mdl does not exists
Model cout.mdl does not exists
Model out.mdl does not exists
Model ut.mdl does not exists
Model t.mdl does not exists
Model .mdl does not exists
Model mdl does not exists
Model dl does not exists
Model l does not exists
Model does not exists

Also:
L 07/27/2023 - 21:05:42: [AMXX] Displaying debug trace (plugin "guns2024.amxx", version "1.0")
L 07/27/2023 - 21:05:42: [AMXX] Run time error 4: index out of bounds
L 07/27/2023 - 21:05:42: [AMXX] [0] guns2024.sma::OnPlayerChangeWeapon_Pre (line 87)
JuanitoAlimana is offline