
/* AMX Mod script. 
* 
* (c) Copyright 2002, [CCC]Taz-Deveil 
* This file is provided as is (no warranties). 
* 
*/ 

#include <amxmod> 

new lastwpn[33] 
new lastammo[33] 

public playsoundtoall(VarWave[]){  
   new players[32], inum    
   get_players(players,inum,"a")    
   for(new i = 0 ;i < inum ;++i) {    
      emit_sound(players[i],CHAN_ITEM, VarWave, 1.0, ATTN_NORM, 0, PITCH_NORM)    
   }  
} 

public amx_awpenable(id) { 
    if (!(get_user_flags(id)&ADMIN_LEVEL_B)) { 
        client_print(id,print_console,"[AMX] Access Denied") 
        return PLUGIN_HANDLED 
    } 
    if (read_argc() != 2) 
    { 
        client_print(id,print_console,"[AMX] Usage: amx_awp <1 | 0>") 
        return PLUGIN_HANDLED 
    } 
    new argstr[12] 
    read_argv(1,argstr,12) 
    new arg = str_to_num(argstr) 
    if ((arg != 1) && (arg != 0)) 
    { 
        client_print(id,print_console,"[AMX] Usage: amx_awp <1 | 0>") 
        return PLUGIN_HANDLED 
    } 
    client_print(id,print_console,"[AMX] Awp mode TH enabled to %i",arg) 
    set_hudmessage(100, 100,0, 0.05,0.60, 0, 6.0, 6.0, 0.5, 0.15, 2)
    if (arg == 1)   
         show_hudmessage(0,"Awp TH activate !!" )    
    if (arg == 0)   
         show_hudmessage(0,"Awp TH deactivate !!" )    
    set_cvar_num("AwpEnabled",arg )
    playsoundtoall("items/nvg_on.wav")  
    return PLUGIN_HANDLED 
} 

public Awpfire(id) 
{ 
new Awpactive = get_cvar_num("AwpEnabled")
if (Awpactive== 1) {
	new wpn = read_data(2) 
	new ammo = read_data(3) 
	new power = get_cvar_num("amx_awppv") 
	new user_health = get_user_health(id) 
	if ( (lastwpn[id]==wpn) && (lastammo[id]>ammo)) { 
		if (user_health > power) {
      			set_user_health(id,(user_health-power)) 
			client_print(id,print_chat,"When you R fire you loose %i HP",power) 
   		 }  			
    	} 
    	lastwpn[id] = wpn 
    	lastammo[id] = ammo 
}
return PLUGIN_HANDLED
} 

public plugin_precache() 
{ 
    precache_sound("items/nvg_on.wav") 
    return PLUGIN_CONTINUE 
} 

public plugin_init() 
{ 
    register_plugin("Awppunish","0.7.3","[CCC]Taz-Devil") 
    register_event("CurWeapon","Awpfire","be","1=1","2=18","3>0")  
    register_clcmd("amx_awp","amx_awpenable",ADMIN_LEVEL_B,"amx_awp <1 | 0>")   
    register_cvar("AwpEnabled","1")
    register_cvar("amx_awppv","10")
    return PLUGIN_CONTINUE 
} 


