Raised This Month: $ Target: $400
 0% 

Changing models


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 09-14-2012 , 13:16   Changing models
Reply With Quote #1

I'm wondering if i'm changing player's hands and "player" models correctly. Maby there is any way to optimise it?

PHP Code:
new const fist_models[][] = { "models/p_bknuckles.mdl""models/v_bknuckles.mdl" }
new const 
crowbar_models[][] = { "models/p_crowbar.mdl""models/v_crowbar.mdl" }
new const 
fist_sounds[][] = { "weapons/cbar_hitbod2.wav""weapons/cbar_hitbod1.wav""weapons/bullet_hit1.wav""weapons/bullet_hit2.wav" }

public 
plugin_init() 
{
    
register_event("CurWeapon""CurWeapon""be""1=1""2=29")

    
register_forward(FM_EmitSound"EmitSound")
    
    
RegisterHam(Ham_Spawn"player""client_spawn"1)
}

public 
plugin_precache()
{
    static 
i
    
    
for(0sizeof fist_modelsi++)
        
precache_model(fist_models[i])
    
    for(
0sizeof fist_soundsi++)
        
precache_sound(fist_sounds[i])
    
    for(
0sizeof crowbar_modelsi++)
        
precache_model(crowbar_models[i])
        
    
precache_model("models/player/amx_t_nike/amx_t_nike.mdl")
    
precache_model("models/player/amx_ct_puma/amx_ct_puma.mdl")
}

public 
EmitSound(idchannelsample[])
{
    if(
get_pcvar_num(cvar_fists))
    {
        if(
is_user_alive(id))
        {
            if(
equal(sample"weapons/knife_"14))
            {
                if(
equal(sample"weapons/knife_hit"17))
                {
                    
emit_sound(idCHAN_WEAPON"weapons/bullet_hit2.wav"random_float(0.51.0), ATTN_NORM0PITCH_NORM)
                    return 
FMRES_SUPERCEDE
                
}
                else if(
equal(sample,"weapons/knife_stab.wav"))
                {
                    
emit_sound(idCHAN_WEAPON"weapons/cbar_hitbod2.wav"1.0ATTN_NORM0PITCH_NORM)    
                    return 
FMRES_SUPERCEDE
                
}
                else if(
equal(sample,"weapons/knife_hitwall1.wav"))
                {
                    
emit_sound(idCHAN_WEAPON"weapons/cbar_hitbod1.wav"1.0ATTN_NORM0PITCH_LOW)
                    return 
FMRES_SUPERCEDE            
                
}        
            }
        }        
    }
    return 
FMRES_IGNORED
}

public 
CurWeapon(id)
{
    if(
is_user_alive(id)) 
    {        
        if(
get_pcvar_num(cvar_fists) && id != crowbaruser
        {
            
set_pev(idpev_viewmodel2fist_models[1])
            
set_pev(idpev_weaponmodel2fist_models[0])    
        }    
        else if(
get_pcvar_num(cvar_crowbar) && id == crowbaruser// Don't look here, it checks for specified player. The player is randomly chosen on round start.
        
{
            
set_pev(idpev_viewmodel2crowbar_models[1])
            
set_pev(idpev_weaponmodel2crowbar_models[0])            
        }
    }
}

public 
client_spawn(id)
{    
    if(!
is_user_connected(id) || !is_user_alive(id))
        return
    
    new 
CsTeams:team
    team 
cs_get_user_team(id)
        
    if(
team == CS_TEAM_T
    {
        
cs_set_player_model(id"amx_t_nike")
    }
    else if (
team == CS_TEAM_CT
    {
        
cs_set_player_model(id"amx_ct_puma")    
    }

GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-14-2012 , 14:43   Re: Changing models
Reply With Quote #2

PHP Code:
new Trie:g_tFistSounds
new g_iszFistPModelg_iszFistVModelg_iszCrowbarPModelg_iszCrowbarVModel

public plugin_init() 
{
    
register_event("CurWeapon""CurWeapon""be""1=1""2=29")

    
register_forward(FM_EmitSound"EmitSound")

    
RegisterHam(Ham_Spawn"player""client_spawn"1)
}

public 
plugin_precache()
{
    
g_tFistSounds TrieCreate()

    new 
bullet_hit2[] = "weapons/bullet_hit2.wav"
    
new cbar_hitbod1[] = "weapons/cbar_hitbod1.wav"
    
new cbar_hitbod2[] = "weapons/cbar_hitbod2.wav"

    
TrieSetString(g_tFistSounds"weapons/knife_hit1.wav"bullet_hit2)
    
TrieSetString(g_tFistSounds"weapons/knife_hit2.wav"bullet_hit2)
    
TrieSetString(g_tFistSounds"weapons/knife_hit3.wav"bullet_hit2)
    
TrieSetString(g_tFistSounds"weapons/knife_hit4.wav"bullet_hit2)
    
TrieSetString(g_tFistSounds"weapons/knife_hitwall1.wav"cbar_hitbod1)
    
TrieSetString(g_tFistSounds"weapons/knife_stab.wav"cbar_hitbod2)

    new 
p_bknuckles[] = "models/p_bknuckles.mdl"
    
new v_bknuckles[] = "models/v_bknuckles.mdl"
    
new p_crowbar[] = "models/p_crowbar.mdl"
    
new v_crowbar[] = "models/v_crowbar.mdl"
    
g_iszFistPModel engfunc(EngFunc_AllocStringp_bknuckles)
    
g_iszFistVModel engfunc(EngFunc_AllocStringv_bknuckles)
    
g_iszCrowbarPModel engfunc(EngFunc_AllocStringp_crowbar)
    
g_iszCrowbarVModel engfunc(EngFunc_AllocStringv_crowbar)

    
precache_soundbullet_hit2 )
    
precache_soundcbar_hitbod1 )
    
precache_soundcbar_hitbod2 )

    
precache_modelp_bknuckles )
    
precache_modelv_bknuckles )
    
precache_modelp_crowbar )
    
precache_modelv_crowbar )

    
precache_model("models/player/amx_t_nike/amx_t_nike.mdl")
    
precache_model("models/player/amx_ct_puma/amx_ct_puma.mdl")
}

public 
EmitSound(idchannelsample[], Float:volFloat:attnflagspitch)
{
    if (
get_pcvar_num(cvar_fists) && is_user_alive(id) )
    {
        new 
szSound[32]
        if( 
TrieGetString(g_tFistSoundssampleszSoundcharsmax(szSound)) )
        {
            
emit_sound(idchannelszSoundvolattnflagspitch)
            return 
FMRES_SUPERCEDE
        
}    
    }
    return 
FMRES_IGNORED
}

public 
CurWeapon(id)
{
    if( 
is_user_alive(id) ) 
    {
        if( 
id == crowbaruser )
        {
            
set_pev(idpev_viewmodelg_iszCrowbarVModel)
            
set_pev(idpev_weaponmodelg_iszCrowbarPModel
        }
        else if( 
get_pcvar_num(cvar_fists) )
        {
            
set_pev(idpev_viewmodelg_iszFistVModel)
            
set_pev(idpev_weaponmodelg_iszFistPModel)  
        }
    }
}

public 
client_spawn(id)
{    
    if( 
is_user_aliveid ) )
    {
        switch( 
cs_get_user_team(id) )
        {
            case 
CS_TEAM_T:cs_set_player_model(id"amx_t_nike")
            case 
CS_TEAM_CT:cs_set_player_model(id"amx_ct_puma")
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-15-2012 at 05:47.
ConnorMcLeod is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 09-14-2012 , 17:23   Re: Changing models
Reply With Quote #3

Im not sure what is that
http://i.minus.com/ibd8QBrXdTsf6v.png
GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-15-2012 , 05:48   Re: Changing models
Reply With Quote #4

Fixed, i hadn't chaned all pev_viemodel2 and pev_weaponmodel2 with pev_viewmodel and pev_weaponmodel.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 09-15-2012 , 08:34   Re: Changing models
Reply With Quote #5

PHP Code:
    new bullet_hit2[] = "weapons/bullet_hit2.wav"
    
new cbar_hitbod1[] = "weapons/cbar_hitbod1.wav"
    
new cbar_hitbod2[] = "weapons/cbar_hitbod2.wav"

    
new p_bknuckles[] = "models/p_bknuckles.mdl"
    
new v_bknuckles[] = "models/v_bknuckles.mdl"
    
new p_crowbar[] = "models/p_crowbar.mdl"
    
new v_crowbar[] = "models/v_crowbar.mdl" 
Some of these files arent in cstrike/models but they are in valve/models and it still works. Why is that?

I'm using this plugin on cs server.
GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-15-2012 , 16:58   Re: Changing models
Reply With Quote #6

Those files are in valve directory and can be used in any mod.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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 08:16.


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