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(i = 0; i < sizeof fist_models; i++)
precache_model(fist_models[i])
for(i = 0; i < sizeof fist_sounds; i++)
precache_sound(fist_sounds[i])
for(i = 0; i < sizeof crowbar_models; i++)
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(id, channel, sample[])
{
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(id, CHAN_WEAPON, "weapons/bullet_hit2.wav", random_float(0.5, 1.0), ATTN_NORM, 0, PITCH_NORM)
return FMRES_SUPERCEDE
}
else if(equal(sample,"weapons/knife_stab.wav"))
{
emit_sound(id, CHAN_WEAPON, "weapons/cbar_hitbod2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return FMRES_SUPERCEDE
}
else if(equal(sample,"weapons/knife_hitwall1.wav"))
{
emit_sound(id, CHAN_WEAPON, "weapons/cbar_hitbod1.wav", 1.0, ATTN_NORM, 0, PITCH_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(id, pev_viewmodel2, fist_models[1])
set_pev(id, pev_weaponmodel2, fist_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(id, pev_viewmodel2, crowbar_models[1])
set_pev(id, pev_weaponmodel2, crowbar_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")
}
}