AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing models (https://forums.alliedmods.net/showthread.php?t=196023)

GhostMan 09-14-2012 13:16

Changing models
 
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")    
    }



ConnorMcLeod 09-14-2012 14:43

Re: Changing models
 
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")
        }
    }



GhostMan 09-14-2012 17:23

Re: Changing models
 
Im not sure what is that
http://i.minus.com/ibd8QBrXdTsf6v.png

ConnorMcLeod 09-15-2012 05:48

Re: Changing models
 
Fixed, i hadn't chaned all pev_viemodel2 and pev_weaponmodel2 with pev_viewmodel and pev_weaponmodel.

GhostMan 09-15-2012 08:34

Re: Changing models
 
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.

ConnorMcLeod 09-15-2012 16:58

Re: Changing models
 
Those files are in valve directory and can be used in any mod.


All times are GMT -4. The time now is 08:16.

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