In this script that I found Ham_item_deploy is used to change weapon models instead of using the curweapon. I want to change multiple weapons, and this code seems rather good, however I'm wondering if I need a loop like this to use multiple weapons? Or can I use something like:
Code:
RegisterHam( Ham_Item_Deploy, "fwReplaceModels", 1);
Code:
public fwReplaceModel( entity )
{
if( pev_valid( entity ) != 2 ) return HAM_IGNORED;
new id = get_pdata_cbase( entity, 41, 4 );
static entclass[32];
pev(entity, pev_classname, entclass, 31);
for( i = 0; i < g_size; i++ )
{
if( equal( entclass, szWeaponInfo[ i ][ 0 ] ) )
set_pev( id, pev_viewmodel2, szWeaponInfo[ i ][ 1 ] );
}
return HAM_IGNORED;
}
And then do something like this:
Code:
public fwReplaceModel( entity ) {
if( pev_valid( entity ) != 2 ) return HAM_IGNORED;
new id = get_pdata_cbase( entity, 41, 4 );
new clip,ammo
new weapon=get_user_weapon(id,clip,ammo)
static entclass[32];
pev(entity, pev_classname, entclass, 31);
switch(weapon) {
case CSW_KNIFE:
{
if(player_class[id] != Ninja) {
entity_set_string(id, EV_SZ_viewmodel, KNIFE_VIEW)
entity_set_string(id, EV_SZ_weaponmodel, KNIFE_PLAYER)
}
}
case CSW_C4:
{
entity_set_string(id, EV_SZ_viewmodel, C4_VIEW)
entity_set_string(id, EV_SZ_weaponmodel, C4_PLAYER)
}
case CSW_HEGRENADE:
{
entity_set_string(id, EV_SZ_viewmodel, HE_VIEW)
entity_set_string(id, EV_SZ_weaponmodel, HE_PLAYER)
}
case CSW_FLASHBANG:
{
entity_set_string(id, EV_SZ_viewmodel, FL_VIEW)
entity_set_string(id, EV_SZ_weaponmodel, FL_PLAYER)
}
case CSW_SMOKEGRENADE:
{
entity_set_string(id, EV_SZ_viewmodel, SE_VIEW)
entity_set_string(id, EV_SZ_weaponmodel, SE_PLAYER)
}
}
return HAM_IGNORED;
}
Source:
https://forums.alliedmods.net/showpo...42&postcount=5