here is me code i am using:
Code:


entity player_weapon
{
type = <knife_arm.mdl>;
layer = 0;
view = camera;
albedo = 50;
ambient = -100;
x = 32;
y = -20;
z = -19;
pan = 10;
tilt = 10;
roll = -10;
}

function player_fight()
{
var animdist;
var mouse_left_pressed = 0;
var rdm;
while(1)
{
if(mouse_left && mouse_mode == 0)
{

temp.pan = 10;
temp.tilt = 10;
temp.z = 128;

indicator = _click;
scan_entity(camera.x,temp);


//snd_play(click_wav,100,0);

if(item_player_weapon && mouse_left && animdist == 0)
{

vec_set(temp.x,nullvector);
temp.x = 48;
vec_rotate(temp.x,camera.pan);
vec_add(temp.x,player.x);

trace_mode = ignore_me + ignore_models;
result = trace(my.x,temp.x);

if(result != 0)
{
snd_play(hit_wav,10,0);
}else{
snd_play(swing_wav,50,0);
}

temp.pan = 90;
temp.tilt = 90;
temp.z = 96;

damage = player_dmg;
scan_entity(camera.x,temp);

rdm += 1;//int(random(2));
if(rdm%2 == 0)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_a",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}

ent_animate(player_weapon,"attack_a",100,anm_cycle);
animdist = 0;
}
if(rdm%2 == 1)
{
while(animdist < 100)
{
ent_animate(player_weapon,"attack_b",animdist,anm_cycle);
animdist += 10 * time;
wait(1);
}

ent_animate(player_weapon,"attack_b",100,anm_cycle);
animdist = 0;
}

}
while(mouse_left){wait(1);}
}
wait(1);
}
}


its alittlebit long but works fine^^ (it use two different attack-animations)