View Single Post
Author Message
souvik2701
Junior Member
Join Date: Jul 2016
Location: IND
Old 08-23-2016 , 10:41   Plugin Not Working
Reply With Quote #1

Please anyone check this
This plugin is not working and is making my server to crash
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <dhudmessage>
#include <hamsandwich>

#define PLUGIN "Knife It Up"
#define VERSION "2.0"
#define AUTHOR "KaLaDhan"

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_dictionary("knifeitup.txt")
	
	register_cvar("knifeitup_HP", "25")
	register_cvar("knifeitup_adminHP", "100")
	

	register_cvar("knifeitup_p_sBoost", "50")
	register_cvar("knifeitup_a_sBoost", "50")
	register_cvar("knifeitup_sBoost_Time", "2.0")

	register_cvar("knifeitup_frags", "3")
	register_cvar( "knifeitup_TAG", "['O|s|G']" )
		
	RegisterHam(Ham_Killed, "player", "Death_Knife")
	
	//ExecuteConfigs()
}
new knifesounds[4][] =
{
	"sound/oldskoolcs/osg_knifekill.wav",
	"sound/oldskoolcs/osg_knifekill2.wav",
	"sound/oldskoolcs/osg_knifekill3.wav",
	"sound/oldskoolcs/osg_knifekill4.wav"
}
public plugin_precache()
{
	if(file_exists("sound/oldskoolcs/osg_knifekill.wav"))
		precache_sound("sound/oldskoolcs/osg_knifekill.wav")
	if(file_exists("sound/oldskoolcs/osg_knifekill2.wav"))
		precache_sound("sound/oldskoolcs/osg_knifekill2.wav")
	if(file_exists("sound/oldskoolcs/osg_knifekill3.wav"))
		precache_sound("sound/oldskoolcs/osg_knifekill3.wav")
	if(file_exists("sound/oldskoolcs/osg_knifekill4.wav"))
		precache_sound("sound/oldskoolcs/osg_knifekill4.wav")
		
}

public Death_Knife ( victim, attacker, wpnindex, hitplace  )
{
	if ( !is_user_alive( attacker ) ||victim == attacker )
		return HAM_IGNORED
	
	new attacker_weapon[13]
	get_weaponname( wpnindex, attacker_weapon, charsmax(attacker_weapon) )
	
	if ( equal( attacker_weapon, "weapon_knife" ) )
	{
		new TAG[10]
		get_cvar_string( "knifeitup_TAG", TAG, charsmax(TAG) )
		
		new pHP =	get_cvar_num( "knifeitup_HP" )
		new aHP =	get_cvar_num( "knifeitup_adminHP" )
		new frags =	get_cvar_num( "knifeitup_frags" )
		new p_sBoost =	get_cvar_num( "knifeitup_p_sBoost" )
		new a_sBoost =	get_cvar_num( "knifeitup_a_sBoost" )
		new Float:sBoost_Time = get_cvar_float("knifeitup_sBoost_Time")
		
		new attacker_name[32]
		new victim_name[32]
		get_user_name( attacker, attacker_name ,charsmax( attacker_name )  )
		get_user_name( victim, victim_name ,charsmax( victim_name )  )
		
		set_dhudmessage(0, 160, 0, 0.40, 0.60, 2, 6.0, 12.0)
		show_dhudmessage( 0, "%s just knived %s", attacker_name, victim_name)
		client_cmd( 0, "spk %s", knifesounds )
		
		if( get_user_flags(attacker) & ADMIN_KICK )
		{
			set_user_health( attacker, get_user_health(attacker) + aHP )
			set_user_maxspeed( attacker, get_user_maxspeed( attacker ) + a_sBoost/100 )
			
			frags = get_user_frags( attacker ) + frags
			set_user_frags( attacker, frags )
			set_user_frags( attacker, frags )
			client_printc( 0, "!g%s !nkilled %s with !gknife", attacker_name, victim_name )
			client_print( 0, print_chat, "%s %L", TAG, LANG_PLAYER, "PLAYER_MSG", attacker_name, victim_name, aHP, frags, sBoost_Time )

		}
		else
		{
			set_user_health( attacker, get_user_health(attacker) + pHP )
			set_user_maxspeed( attacker, get_user_maxspeed( attacker ) + p_sBoost/100 )
			frags = get_user_frags( attacker ) + frags
			set_user_frags( attacker, frags )
			set_user_frags( attacker, frags )
			client_printc( 0, "!nAdmin !g%s !nkilled %s with !gknife", attacker_name, victim_name )
			client_print( 0, print_chat, "%s %L", TAG, LANG_PLAYER, "ADMIN_MSG", attacker_name, victim_name, pHP, frags, sBoost_Time )
		}
	}
}

public ExecuteConfigs()
{
	new config_dir[200]    						//Create the variable
	get_configsdir( config_dir, charsmax( config_dir ) )     	//get the configs directory (addons/amxmodx/configs/)	
	add( config_dir, charsmax( config_dir ), "/knifeitup.cfg" )	//create the file being used
	
	if( file_exists( config_dir ) )     				//if its already there just execute it
	{
		server_cmd( "exec %s", config_dir )
		server_exec()
	}
	else
	{
		make_config( config_dir );     				//if its not then create it with the information we made here
	}	
}  

make_config(const config_dir[])
{
		
	new f = fopen(config_dir, "wt")					//open the file with the flags Write and Text
	
	fputs(f, "// Your Configs Go Here^n^n^n")			//Add a comment line with 3 spaces (Note ^n means "New line")
	
	//Write the cvars for your plugin in the form used to change the cvars"
	fprintf(f, "	//HP Gain for Normal Players^n\
			knifeitup_HP %i^n", get_cvar_num( "knifeitup_HP" ))
	fprintf(f, "	//HP Gain for Admins^n\
			knifeitup_adminHP %i^n", get_cvar_num( "knifeitup_adminHP" ) )
	
	fprintf(f, "	//Extra Frags Amount ^n\
			knifeitup_frags %i^n", get_cvar_num( "knifeitup_frags" ) )
	
	fprintf(f, "	//Speed Boost for Normal Players in Percentage. Ex : 50^n\
			knifeitup_frags %i^n", get_cvar_num( "knifeitup_p_sBoost" ) )
	fprintf(f, "	//Speed Boost for Normal Players in Percentage. Ex : 50^n\
			knifeitup_frags %i^n", get_cvar_num( "knifeitup_a_sBoost" ) )
	
	fprintf(f, "	//TAG to be put before text messages printed in chat area. Ex : [KNIFE]^n\
			knifeitup_frags %i^n", get_cvar_num( "knifeitup_TAG" ) )
	
	fclose(f)							//close the file
} 

// Colour Chat
client_printc(index, const text[], any:...)
{
    new szMsg[128];
    vformat(szMsg, sizeof(szMsg) - 1, text, 3);
    
    replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
    replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
    replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
    
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
    write_byte(index);
    write_string(szMsg);
    message_end();
}
souvik2701 is offline