Quote:
Originally Posted by lexzor
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(PLUGIN, VERSION, AUTHOR)
RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "OnPlayerChangeWeapon_Pre", false)
}
public plugin_precache()
{
for(new i; i < sizeof(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 i; i < sizeof(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 id, szViewModel[], szWeaponModel[])
{
if(!g_bCanHaveSkin[id])
{
return HC_CONTINUE
}
static iWeaponID;
iWeaponID = rg_get_weapon_id(id)
SetHookChainArg(2, ATYPE_STRING, V_MODELS[iWeaponID])
SetHookChainArg(3, ATYPE_STRING, P_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)