Raised This Month: $ Target: $400
 0% 

Ham_item_deploy


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 05-21-2014 , 12:37   Ham_item_deploy
Reply With Quote #1

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
egbertjan is offline
 



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 09:42.


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