Заявка за плъгини [ТУК]

Всичко свързано с AMX mod (X), плъгини, проблеми с плъгини, заявки и тн.
Потребителски аватар
TheRedShoko
Member
Мнения: 50
Регистриран: пет мар 25, 2016 2:54 pm
Баланс: Locked

ср авг 10, 2016 2:32 am

Има квар за максимално количество кръв...

Потребителски аватар
MuHaBaM
Member
Мнения: 56
Регистриран: ср май 25, 2016 12:50 pm
Баланс: Locked

ср авг 10, 2016 9:20 am

[quote="TheRedShoko"]Има квар за максимално количество кръв...[/quote]

Без no fall damage plugin съм. И знам, че има за максимално кръв. Искам да кажа, че не се регенерира кръвта. Аз съм на 3000hp, скачам взима ми 25 и ми остава 2975 после нали трябва да бъде 2985, а ми остава пак 2975... Дано да си ме разбрал. :)

Потребителски аватар
TheRedShoko
Member
Мнения: 50
Регистриран: пет мар 25, 2016 2:54 pm
Баланс: Locked

ср авг 10, 2016 2:40 pm

Не виждам логика да бъгва.... Пробвай така:

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include <amxmodx>
#include <fakemeta>
#include <basebuilder>

new szClassInfo[][] =
{
    "Regeneration Zombie",
    "Health Regen",
    "bb_regen_zombie",
    "models/v_regen_claws.mdl",
    "3000",
    "270",
    "1.0",
    "0.0"
}

new iRegenClass, p_iMaxRegen, p_iRegenAmount, p_iRegenTime;

public plugin_init()
{
    register_plugin("[BB] Zombie Class: Regeneration", "1.0", "TheRedShoko");
    
    p_iMaxRegen = register_cvar("bb_regen_max", "3000");
    p_iRegenAmount = register_cvar("bb_regen_amount", "10");
    p_iRegenTime = register_cvar("bb_regen_time", "3.0");
}

public plugin_precache()
{
    iRegenClass = bb_register_zombie_class(szClassInfo[0], szClassInfo[1], szClassInfo[2], szClassInfo[3], 
    str_to_num(szClassInfo[4]), str_to_num(szClassInfo[5]), str_to_float(szClassInfo[6]), str_to_float(szClassInfo[7]));
}

public client_disconnect(id)
{
    if (task_exists(id))
    {
        remove_task(id);
    }
}

public client_putinserver(id)
{
    if (task_exists(id))
    {
        remove_task(id);
    }
}

public bb_zombie_class_picked(id, iClass)
{
    if (iClass == iRegenClass && bb_is_user_zombie(id) && !task_exists(id))
    {
        set_task(get_pcvar_float(p_iRegenTime), "RegenPlayer", id, .flags = "b");
    }
}

public RegenPlayer(id)
{
    if (!is_user_connected(id) || bb_get_user_zombie_class(id) != iRegenClass || !bb_is_user_zombie(id) || !is_user_alive(id))
    {
        return;
    }
    
    if (pev(id, pev_health) < get_pcvar_float(p_iMaxRegen))
    {
        set_pev(id, pev_health, pev(id, pev_health) + get_pcvar_float(p_iRegenAmount));
    }
}  
Последна промяна от xvi на нед яну 22, 2017 7:17 pm, променено общо 1 път.

Потребителски аватар
Microxx
Newbie
Мнения: 5
Регистриран: съб авг 27, 2016 6:07 pm
Баланс: Locked

нед авг 28, 2016 11:06 am

[quote="Irie"]Искам плъгина на @TheRedShoko - Weapon Special Abilities, да го редактирате, за да бъде само за CT отбора![/quote]

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <xs>

#define VERSION "1.1"
#define TASK_REGEN 123
#define TASK_BURN 156
#define TASK_FREEZE 188

enum Cvars
{
	WEAPON_WHICH,
	MULT_DMG,
	GRAVITY,
	SPEED,
	VISIBILITY,
	REGEN,
	REGEN_TIME,
	REGEN_MAX,
	FIRE_DURATION,
	FIRE_HURT,
	FREEZE_TIME
}

new szWeaponCommands[][] =
{
	"say /weapon",
	"say /weapons",
	"say /abilities",
	"say_team /weapon",
	"say_team /weapons",
	"say_team /abilities"
}

new Array:WeaponNames, Array:WeaponAbbilities, Array:WeaponViewModels, Array:WeaponWorldModels
new iTotalWeapons, iCvars[Cvars], iCurrentWeapon[33], iUserFireAttacker[33], iUserFireDuration[33]
new iMsgStatusIcon, iSprFlame, iSprSmoke, iGlassGibs

new szIceModel[] = "models/wsa/ice_cube.mdl"
new szIceBlockClassname[] = "entity_ice_block"

public plugin_init()
{
	register_plugin("Weapon Special Abilities", VERSION, "TheRedShoko")
	register_cvar("weapon_abilities_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
	
	register_event("CurWeapon", "eventCurrentWeapon", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePre", 0)
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePost", 1)
	RegisterHam(Ham_TraceAttack, "player", "playerAttackPre", 0)
	
	for (new i = 0; i < sizeof(szWeaponCommands); i++)
	{
		register_clcmd(szWeaponCommands[i], "weapon_ability_menu")
	}
	
	iMsgStatusIcon = get_user_msgid("StatusIcon")
	
	iCvars[WEAPON_WHICH] = register_cvar("ability_weapon", "29") // The index of the weapon! Default: 29 - knife
	iCvars[MULT_DMG] = register_cvar("weapon_ability_damage", "2.0") // How many times the damage will be higher for weapons with flag "a"! Default: 2.0
	iCvars[GRAVITY] = register_cvar("weapon_ability_gravity", "500") // The amount of gravity for weapons with flag "b" using sv_gravity cvar! Default: 500
	iCvars[SPEED] = register_cvar("weapon_ability_speed", "340") // The amount of speed for weapons with flag "c"! Default: 340
	iCvars[VISIBILITY] = register_cvar("weapon_ability_invisibility", "60") //The amount in % of visibility for weapons with flag "d"! Default: 60
	iCvars[REGEN] = register_cvar("weapon_ability_regen", "5") // The amount of health that will be regenerated for weapons with flag "f"! Default: 5
	iCvars[REGEN_TIME] = register_cvar("weapon_ability_regen_time", "5.0") // The delay between every health delay in float! Default: 5.0
	iCvars[REGEN_MAX] = register_cvar("weapon_ability_regen_maxhp", "150") // The max amount of health that user can regen! Default: 150
	iCvars[FIRE_DURATION] = register_cvar("weapon_ability_fire_duration", "10") // The duration of the fire when user is burned. Default: 10
	iCvars[FIRE_HURT] = register_cvar("weapon_ability_fire_hurt", "10") // The amount of health that will be taken while burning. Default: 10
	iCvars[FREEZE_TIME] = register_cvar("weapon_ability_freeze_time", "10") //The frost duration. Defautl: 10
}

public plugin_precache()
{
	WeaponNames = ArrayCreate(32, 1)
	WeaponAbbilities = ArrayCreate(16, 1)
	WeaponViewModels = ArrayCreate(64, 1)
	WeaponWorldModels = ArrayCreate(64, 1)
	
	Load_File()
	
	new szModel[128]
	
	for (new i = 1; i < iTotalWeapons; i++)
	{
		ArrayGetString(WeaponViewModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
		
		ArrayGetString(WeaponWorldModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
	}
	
	PrecacheModel(szIceModel)
	
	iSprFlame = precache_model("sprites/flame.spr")
	iSprSmoke = precache_model("sprites/black_smoke1.spr")
	iGlassGibs = precache_model("models/glassgibs.mdl")
}

public client_connect(id)
{
	reset(id)
}

public client_disconnect(id)
{
	reset(id)
}

reset(id)
{
	if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	if (task_exists(TASK_FREEZE + id))
	{
		remove_task(TASK_FREEZE + id)
		user_unfreeze(TASK_FREEZE + id)
	}
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
	}
	
	iCurrentWeapon[id] = 0
}

public playerAttackPre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], tracehandle, damage_type)
{
	if (!is_user_connected(iAttacker) || iVictim == iAttacker)
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (task_exists(TASK_FREEZE + iVictim))
	{
		if (has_ability(szFlags, "g") && get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
		|| !has_ability(szFlags, "g"))
		{
			return HAM_SUPERCEDE
		}
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePre(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) 
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "a"))
	{
		SetHamParamFloat(4, flDamage * get_pcvar_float(iCvars[MULT_DMG]))
	}
	
	if (has_ability(szFlags, "h"))
	{
		set_task(0.1, "user_freeze", iVictim + TASK_FREEZE)
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePost(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) || !is_user_alive(iVictim)
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "g"))
	{
		iUserFireAttacker[iVictim] = iAttacker
		iUserFireDuration[iVictim] = get_pcvar_num(iCvars[FIRE_DURATION])
		
		set_task(0.1, "start_burn", TASK_BURN + iVictim)
	}
	
	return HAM_IGNORED
}

public eventCurrentWeapon(id)
{
	new iWeapon = read_data(2)
	
	if (iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	set_pev(id, pev_gravity, ((has_ability(szFlags, "b") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[GRAVITY]) : 800.0 ) / 800.0)
	
	set_pev(id, pev_maxspeed, (has_ability(szFlags, "c") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[SPEED]) : 270.0)
	
	set_user_footsteps(id, ((has_ability(szFlags, "e") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? 1 : 0))
	
	if (has_ability(szFlags, "f") && !task_exists(TASK_REGEN + id) && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_task(get_pcvar_float(iCvars[REGEN_TIME]), "user_regen", TASK_REGEN + id, .flags = "b")
	}
	else if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, (has_ability(szFlags, "d") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? (255 - (2.55 * get_pcvar_float(iCvars[VISIBILITY]))) : 255.0)
}

public user_regen(taskid)
{
	new id = taskid - TASK_REGEN
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	if (pev(id, pev_health) < get_pcvar_float(iCvars[REGEN_MAX]) && has_ability(szFlags, "f")
	&& get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_pev(id, pev_health, ((pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) < get_pcvar_num(iCvars[REGEN_MAX])) ? (pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) : 150.0)
	}
}

public start_burn(taskid)
{
	static id; id = taskid - TASK_BURN
	
	if (!is_user_connected(id) || !is_user_alive(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_heat")
	message_end()
	
	if (~pev(id, pev_flags) & FL_INWATER && !task_exists(TASK_FREEZE + id))
	{
		iUserFireDuration[id]--
	}
	else
	{
		iUserFireDuration[id] = 0
		
		if (task_exists(TASK_FREEZE + id))
		{
			user_unfreeze(TASK_FREEZE + id)
			remove_task(TASK_FREEZE + id)
		}
	}
	
	if (iUserFireDuration[id])
	{
		if (pev(id, pev_health) > get_pcvar_float(iCvars[FIRE_HURT]))
		{
			set_pev(id, pev_health, pev(id, pev_health) - get_pcvar_float(iCvars[FIRE_HURT]))
			
			message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
			write_byte(TE_SPRITE)
			write_coord(origin[0])
			write_coord(origin[1])
			write_coord(origin[2])
			write_short(iSprFlame)
			write_byte(10)
			write_byte(180)
			message_end()
			
			message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
			write_byte(3)
			write_string("dmg_heat")
			write_byte(255)
			write_byte(85)
			write_byte(0)
			message_end()
		}
		else
		{
			iUserFireDuration[id] = 0
			
			if (is_user_connected(iUserFireAttacker[id]))
			{
				ExecuteHamB(Ham_Killed, id, iUserFireAttacker[id], false)
			}
			else
			{
				ExecuteHamB(Ham_Killed, id, id, false)
			}
		}
	}
	
	if (iUserFireDuration[id])
	{
		set_task(1.0, "start_burn", taskid)
	}
	else
	{
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_SMOKE)
		write_coord(origin[0])
		write_coord(origin[1])
		write_coord(origin[2])
		write_short(iSprSmoke)
		write_byte(7)
		write_byte(30)
		message_end()
	}
}	

public user_freeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
		return
	}
	
	static Float:origin[3]
	pev(id, pev_origin, origin)
	origin[2] -= 35.0
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_KILLBEAM)
	write_short(id)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(3)
	write_string("dmg_cold")
	write_byte(0)
	write_byte(200)
	write_byte(255)
	message_end()
	
	fm_set_rendering(id, kRenderFxGlowShell, 0, 200, 255, kRenderNormal, 60.0)
	set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
	
	new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if (pev_valid(iEnt))
	{
		set_pev(iEnt, pev_classname, szIceBlockClassname)
		set_pev(iEnt, pev_movetype, MOVETYPE_NONE)
		set_pev(iEnt, pev_solid, SOLID_BBOX)
		set_pev(iEnt, pev_iuser1, id)
		set_pev(iEnt, pev_origin, origin)
		set_pev(iEnt, pev_size, Float:{ -4.67, -4.04, -4.62 }, Float:{ 4.68, 4.05, 13.01 })
		engfunc(EngFunc_SetModel, iEnt, szIceModel)
		fm_set_rendering(iEnt, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255.0)
	}
	
	set_task(get_pcvar_float(iCvars[FREEZE_TIME]), "user_unfreeze", TASK_FREEZE + id)
}

public user_unfreeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	new iEnt, iUser
	
	while ( (iEnt = engfunc(EngFunc_FindEntityByString, -1, "classname", szIceBlockClassname)) > 0)
	{
		iUser = pev(iEnt, pev_iuser1)
		
		if (iUser == id)
		{
			engfunc(EngFunc_RemoveEntity, iEnt)
			
			break
		}
	}
	
	if (!is_user_connected(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_cold")
	message_end()
	
	set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 16.0)
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_BREAKMODEL)
	write_coord(origin[0])
	write_coord(origin[1])
	write_coord(origin[2] + 24)
	write_coord(16)
	write_coord(16)
	write_coord(16)
	write_coord(random_num(-50,50))
	write_coord(random_num(-50,50))
	write_coord(25)
	write_byte(10)
	write_short(iGlassGibs)
	write_byte(14)
	write_byte(30)
	write_byte(0x01)
	message_end()
}

Load_File()
{
	new szFile[128]
	get_configsdir(szFile, charsmax(szFile))
	
	add(szFile, charsmax(szFile), "/weapon_list.ini")
	
	new iLine, szData[128], buffer

	new szName[32], szFlags[16], szVModel[64], szPModel[64]
	
	if (file_exists(szFile))
	{
		iTotalWeapons = 1
		
		ArrayPushString(WeaponNames, "Classic")
		ArrayPushString(WeaponAbbilities, "")
		ArrayPushString(WeaponViewModels, "")
		ArrayPushString(WeaponWorldModels, "")
		
		while ( (iLine = read_file(szFile, iLine, szData, charsmax(szData), buffer)) )
		{
			if (!szData[0] || szData[0] == '/' && szData[1] == '/' || szData[0] == ';') continue
			
			parse(szData, szName, charsmax(szName), szFlags, charsmax(szFlags), szVModel, charsmax(szVModel), szPModel, charsmax(szPModel))
			
			ArrayPushString(WeaponNames, szName)
			ArrayPushString(WeaponAbbilities, szFlags)
			ArrayPushString(WeaponViewModels, szVModel)
			ArrayPushString(WeaponWorldModels, szPModel)
			
			iTotalWeapons++
		}
	}
	else
	{
		new iFile = fopen(szFile, "wt")
		
		if (iFile)
		{
			new szLine[256]
			
			formatex(szLine, charsmax(szLine), "; Weapon Abilities by TheRedShoko^n; Flags:^n; a - Higher damage^n; b - Lower Gravity^n; c - Higher Speed^n; d - Less Visibility^n; e - No footsteps^n")
			
			fputs(iFile, szLine)
			
			formatex(szLine, charsmax(szLine), "; f - Health Regen^n; g - Burn Players^n; h - Freeze Players^n; ^"Weapon Name to be displayed^" ^"Flags^" ^"v_model path^" ^"p_model path^"^n")
			
			fputs(iFile, szLine)
			
			fclose(iFile)
		}
	}
}

public weapon_ability_menu(id)
{
	new team = get_user_team(id)
	if(team == 2)
	{
		new iMenu = menu_create("\rWeapon Abilities Menu^n\yChoose a weapon with ability:^n", "weapon_ability_handler")
		
		new szName[256], szFlags[16]
		
		for (new i = 0; i < iTotalWeapons; i++)
		{
			ArrayGetString(WeaponNames, i, szName, charsmax(szName))
			ArrayGetString(WeaponAbbilities, i, szFlags, charsmax(szFlags))
					
			menu_additem(iMenu, FormatItem(szName, szFlags), _, _, menu_makecallback("weapon_ability_callback"))
		}
		
		menu_display(id, iMenu)
		
		return PLUGIN_HANDLED
	}
	else
	{
		client_print(id, "You are T.You cannot use Weapon Special Abilities!")
		return PLUGIN_HANDLED
	}
}

public weapon_ability_callback(id, iMenu, Item)
{
	if (Item == iCurrentWeapon[id])
	{
		return ITEM_DISABLED
	}
	
	return ITEM_ENABLED
}

public weapon_ability_handler(id, iMenu, Item)
{
	if (Item == MENU_EXIT)
	{
		menu_destroy(iMenu)
		return PLUGIN_HANDLED
	}
	
	iCurrentWeapon[id] = Item
	
	if (is_user_alive(id) && get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
		eventCurrentWeapon(id)
	}
	
	menu_destroy(iMenu)
	
	return PLUGIN_HANDLED
}

SetWeapon(id)
{
	if (!iCurrentWeapon[id]) return
	
	new szVModel[64], szPModel[64]
	
	ArrayGetString(WeaponViewModels, iCurrentWeapon[id], szVModel, charsmax(szVModel))
	ArrayGetString(WeaponWorldModels, iCurrentWeapon[id], szPModel, charsmax(szPModel))
	
	set_pev(id, pev_viewmodel2, szVModel)
	set_pev(id, pev_weaponmodel2, szPModel)
}

FormatItem(szName[256], szFlags[16])
{
	if (has_ability(szFlags, "a"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Damage")
	}
	
	if (has_ability(szFlags, "b"))
	{
		add(szName, charsmax(szName), " \y| \rLower Gravity")
	}
	
	if (has_ability(szFlags, "c"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Speed")
	}
	
	if (has_ability(szFlags, "d"))
	{
		add(szName, charsmax(szName), " \y| \rLower visibility")
	}
	
	if (has_ability(szFlags, "e"))
	{
		add(szName, charsmax(szName), " \y| \rNo Footsteps")
	}
	
	if (has_ability(szFlags, "f"))
	{
		add(szName, charsmax(szName), " \y| \rHealth Regen")
	}
	
	if (has_ability(szFlags, "g"))
	{
		add(szName, charsmax(szName), " \y| \rBurn Players")
	}
	
	if (has_ability(szFlags, "h"))
	{
		add(szName, charsmax(szName), " \y| \rFreeze Players")
	}
	
	return szName
}

PrecacheModel(szModel[])
{
	if (file_exists(szModel))
	{
		precache_model(szModel)
	}
	else
	{
		log_amx("Failed to precache: ^"%s^"! It's missing or may have a wrong name!", szModel)
	}
}

stock has_ability(szFlags[], szFlag[])
{
	return (contain(szFlags, szFlag) != -1) ? true : false
}

//Set rendering from fakemeta_util
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, Float:amount)
{
	new Float:RenderColor[3]
	RenderColor[0] = float(r)
	RenderColor[1] = float(g)
	RenderColor[2] = float(b)

	set_pev(entity, pev_renderfx, fx)
	set_pev(entity, pev_rendercolor, RenderColor)
	set_pev(entity, pev_rendermode, render)
	set_pev(entity, pev_renderamt, amount)

	return 1;
}

Потребителски аватар
Irie
Newbie
Мнения: 16
Регистриран: съб юни 25, 2016 11:31 am
Баланс: Locked

пон авг 29, 2016 12:32 am

[quote="Microxx"][quote="Irie"]Искам плъгина на @TheRedShoko - Weapon Special Abilities, да го редактирате, за да бъде само за CT отбора![/quote]

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <xs>

#define VERSION "1.1"
#define TASK_REGEN 123
#define TASK_BURN 156
#define TASK_FREEZE 188

enum Cvars
{
	WEAPON_WHICH,
	MULT_DMG,
	GRAVITY,
	SPEED,
	VISIBILITY,
	REGEN,
	REGEN_TIME,
	REGEN_MAX,
	FIRE_DURATION,
	FIRE_HURT,
	FREEZE_TIME
}

new szWeaponCommands[][] =
{
	"say /weapon",
	"say /weapons",
	"say /abilities",
	"say_team /weapon",
	"say_team /weapons",
	"say_team /abilities"
}

new Array:WeaponNames, Array:WeaponAbbilities, Array:WeaponViewModels, Array:WeaponWorldModels
new iTotalWeapons, iCvars[Cvars], iCurrentWeapon[33], iUserFireAttacker[33], iUserFireDuration[33]
new iMsgStatusIcon, iSprFlame, iSprSmoke, iGlassGibs

new szIceModel[] = "models/wsa/ice_cube.mdl"
new szIceBlockClassname[] = "entity_ice_block"

public plugin_init()
{
	register_plugin("Weapon Special Abilities", VERSION, "TheRedShoko")
	register_cvar("weapon_abilities_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
	
	register_event("CurWeapon", "eventCurrentWeapon", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePre", 0)
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePost", 1)
	RegisterHam(Ham_TraceAttack, "player", "playerAttackPre", 0)
	
	for (new i = 0; i < sizeof(szWeaponCommands); i++)
	{
		register_clcmd(szWeaponCommands[i], "weapon_ability_menu")
	}
	
	iMsgStatusIcon = get_user_msgid("StatusIcon")
	
	iCvars[WEAPON_WHICH] = register_cvar("ability_weapon", "29") // The index of the weapon! Default: 29 - knife
	iCvars[MULT_DMG] = register_cvar("weapon_ability_damage", "2.0") // How many times the damage will be higher for weapons with flag "a"! Default: 2.0
	iCvars[GRAVITY] = register_cvar("weapon_ability_gravity", "500") // The amount of gravity for weapons with flag "b" using sv_gravity cvar! Default: 500
	iCvars[SPEED] = register_cvar("weapon_ability_speed", "340") // The amount of speed for weapons with flag "c"! Default: 340
	iCvars[VISIBILITY] = register_cvar("weapon_ability_invisibility", "60") //The amount in % of visibility for weapons with flag "d"! Default: 60
	iCvars[REGEN] = register_cvar("weapon_ability_regen", "5") // The amount of health that will be regenerated for weapons with flag "f"! Default: 5
	iCvars[REGEN_TIME] = register_cvar("weapon_ability_regen_time", "5.0") // The delay between every health delay in float! Default: 5.0
	iCvars[REGEN_MAX] = register_cvar("weapon_ability_regen_maxhp", "150") // The max amount of health that user can regen! Default: 150
	iCvars[FIRE_DURATION] = register_cvar("weapon_ability_fire_duration", "10") // The duration of the fire when user is burned. Default: 10
	iCvars[FIRE_HURT] = register_cvar("weapon_ability_fire_hurt", "10") // The amount of health that will be taken while burning. Default: 10
	iCvars[FREEZE_TIME] = register_cvar("weapon_ability_freeze_time", "10") //The frost duration. Defautl: 10
}

public plugin_precache()
{
	WeaponNames = ArrayCreate(32, 1)
	WeaponAbbilities = ArrayCreate(16, 1)
	WeaponViewModels = ArrayCreate(64, 1)
	WeaponWorldModels = ArrayCreate(64, 1)
	
	Load_File()
	
	new szModel[128]
	
	for (new i = 1; i < iTotalWeapons; i++)
	{
		ArrayGetString(WeaponViewModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
		
		ArrayGetString(WeaponWorldModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
	}
	
	PrecacheModel(szIceModel)
	
	iSprFlame = precache_model("sprites/flame.spr")
	iSprSmoke = precache_model("sprites/black_smoke1.spr")
	iGlassGibs = precache_model("models/glassgibs.mdl")
}

public client_connect(id)
{
	reset(id)
}

public client_disconnect(id)
{
	reset(id)
}

reset(id)
{
	if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	if (task_exists(TASK_FREEZE + id))
	{
		remove_task(TASK_FREEZE + id)
		user_unfreeze(TASK_FREEZE + id)
	}
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
	}
	
	iCurrentWeapon[id] = 0
}

public playerAttackPre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], tracehandle, damage_type)
{
	if (!is_user_connected(iAttacker) || iVictim == iAttacker)
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (task_exists(TASK_FREEZE + iVictim))
	{
		if (has_ability(szFlags, "g") && get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
		|| !has_ability(szFlags, "g"))
		{
			return HAM_SUPERCEDE
		}
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePre(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) 
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "a"))
	{
		SetHamParamFloat(4, flDamage * get_pcvar_float(iCvars[MULT_DMG]))
	}
	
	if (has_ability(szFlags, "h"))
	{
		set_task(0.1, "user_freeze", iVictim + TASK_FREEZE)
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePost(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) || !is_user_alive(iVictim)
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "g"))
	{
		iUserFireAttacker[iVictim] = iAttacker
		iUserFireDuration[iVictim] = get_pcvar_num(iCvars[FIRE_DURATION])
		
		set_task(0.1, "start_burn", TASK_BURN + iVictim)
	}
	
	return HAM_IGNORED
}

public eventCurrentWeapon(id)
{
	new iWeapon = read_data(2)
	
	if (iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	set_pev(id, pev_gravity, ((has_ability(szFlags, "b") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[GRAVITY]) : 800.0 ) / 800.0)
	
	set_pev(id, pev_maxspeed, (has_ability(szFlags, "c") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[SPEED]) : 270.0)
	
	set_user_footsteps(id, ((has_ability(szFlags, "e") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? 1 : 0))
	
	if (has_ability(szFlags, "f") && !task_exists(TASK_REGEN + id) && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_task(get_pcvar_float(iCvars[REGEN_TIME]), "user_regen", TASK_REGEN + id, .flags = "b")
	}
	else if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, (has_ability(szFlags, "d") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? (255 - (2.55 * get_pcvar_float(iCvars[VISIBILITY]))) : 255.0)
}

public user_regen(taskid)
{
	new id = taskid - TASK_REGEN
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	if (pev(id, pev_health) < get_pcvar_float(iCvars[REGEN_MAX]) && has_ability(szFlags, "f")
	&& get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_pev(id, pev_health, ((pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) < get_pcvar_num(iCvars[REGEN_MAX])) ? (pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) : 150.0)
	}
}

public start_burn(taskid)
{
	static id; id = taskid - TASK_BURN
	
	if (!is_user_connected(id) || !is_user_alive(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_heat")
	message_end()
	
	if (~pev(id, pev_flags) & FL_INWATER && !task_exists(TASK_FREEZE + id))
	{
		iUserFireDuration[id]--
	}
	else
	{
		iUserFireDuration[id] = 0
		
		if (task_exists(TASK_FREEZE + id))
		{
			user_unfreeze(TASK_FREEZE + id)
			remove_task(TASK_FREEZE + id)
		}
	}
	
	if (iUserFireDuration[id])
	{
		if (pev(id, pev_health) > get_pcvar_float(iCvars[FIRE_HURT]))
		{
			set_pev(id, pev_health, pev(id, pev_health) - get_pcvar_float(iCvars[FIRE_HURT]))
			
			message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
			write_byte(TE_SPRITE)
			write_coord(origin[0])
			write_coord(origin[1])
			write_coord(origin[2])
			write_short(iSprFlame)
			write_byte(10)
			write_byte(180)
			message_end()
			
			message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
			write_byte(3)
			write_string("dmg_heat")
			write_byte(255)
			write_byte(85)
			write_byte(0)
			message_end()
		}
		else
		{
			iUserFireDuration[id] = 0
			
			if (is_user_connected(iUserFireAttacker[id]))
			{
				ExecuteHamB(Ham_Killed, id, iUserFireAttacker[id], false)
			}
			else
			{
				ExecuteHamB(Ham_Killed, id, id, false)
			}
		}
	}
	
	if (iUserFireDuration[id])
	{
		set_task(1.0, "start_burn", taskid)
	}
	else
	{
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_SMOKE)
		write_coord(origin[0])
		write_coord(origin[1])
		write_coord(origin[2])
		write_short(iSprSmoke)
		write_byte(7)
		write_byte(30)
		message_end()
	}
}	

public user_freeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
		return
	}
	
	static Float:origin[3]
	pev(id, pev_origin, origin)
	origin[2] -= 35.0
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_KILLBEAM)
	write_short(id)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(3)
	write_string("dmg_cold")
	write_byte(0)
	write_byte(200)
	write_byte(255)
	message_end()
	
	fm_set_rendering(id, kRenderFxGlowShell, 0, 200, 255, kRenderNormal, 60.0)
	set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
	
	new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if (pev_valid(iEnt))
	{
		set_pev(iEnt, pev_classname, szIceBlockClassname)
		set_pev(iEnt, pev_movetype, MOVETYPE_NONE)
		set_pev(iEnt, pev_solid, SOLID_BBOX)
		set_pev(iEnt, pev_iuser1, id)
		set_pev(iEnt, pev_origin, origin)
		set_pev(iEnt, pev_size, Float:{ -4.67, -4.04, -4.62 }, Float:{ 4.68, 4.05, 13.01 })
		engfunc(EngFunc_SetModel, iEnt, szIceModel)
		fm_set_rendering(iEnt, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255.0)
	}
	
	set_task(get_pcvar_float(iCvars[FREEZE_TIME]), "user_unfreeze", TASK_FREEZE + id)
}

public user_unfreeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	new iEnt, iUser
	
	while ( (iEnt = engfunc(EngFunc_FindEntityByString, -1, "classname", szIceBlockClassname)) > 0)
	{
		iUser = pev(iEnt, pev_iuser1)
		
		if (iUser == id)
		{
			engfunc(EngFunc_RemoveEntity, iEnt)
			
			break
		}
	}
	
	if (!is_user_connected(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_cold")
	message_end()
	
	set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 16.0)
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_BREAKMODEL)
	write_coord(origin[0])
	write_coord(origin[1])
	write_coord(origin[2] + 24)
	write_coord(16)
	write_coord(16)
	write_coord(16)
	write_coord(random_num(-50,50))
	write_coord(random_num(-50,50))
	write_coord(25)
	write_byte(10)
	write_short(iGlassGibs)
	write_byte(14)
	write_byte(30)
	write_byte(0x01)
	message_end()
}

Load_File()
{
	new szFile[128]
	get_configsdir(szFile, charsmax(szFile))
	
	add(szFile, charsmax(szFile), "/weapon_list.ini")
	
	new iLine, szData[128], buffer

	new szName[32], szFlags[16], szVModel[64], szPModel[64]
	
	if (file_exists(szFile))
	{
		iTotalWeapons = 1
		
		ArrayPushString(WeaponNames, "Classic")
		ArrayPushString(WeaponAbbilities, "")
		ArrayPushString(WeaponViewModels, "")
		ArrayPushString(WeaponWorldModels, "")
		
		while ( (iLine = read_file(szFile, iLine, szData, charsmax(szData), buffer)) )
		{
			if (!szData[0] || szData[0] == '/' && szData[1] == '/' || szData[0] == ';') continue
			
			parse(szData, szName, charsmax(szName), szFlags, charsmax(szFlags), szVModel, charsmax(szVModel), szPModel, charsmax(szPModel))
			
			ArrayPushString(WeaponNames, szName)
			ArrayPushString(WeaponAbbilities, szFlags)
			ArrayPushString(WeaponViewModels, szVModel)
			ArrayPushString(WeaponWorldModels, szPModel)
			
			iTotalWeapons++
		}
	}
	else
	{
		new iFile = fopen(szFile, "wt")
		
		if (iFile)
		{
			new szLine[256]
			
			formatex(szLine, charsmax(szLine), "; Weapon Abilities by TheRedShoko^n; Flags:^n; a - Higher damage^n; b - Lower Gravity^n; c - Higher Speed^n; d - Less Visibility^n; e - No footsteps^n")
			
			fputs(iFile, szLine)
			
			formatex(szLine, charsmax(szLine), "; f - Health Regen^n; g - Burn Players^n; h - Freeze Players^n; ^"Weapon Name to be displayed^" ^"Flags^" ^"v_model path^" ^"p_model path^"^n")
			
			fputs(iFile, szLine)
			
			fclose(iFile)
		}
	}
}

public weapon_ability_menu(id)
{
	new team = get_user_team(id)
	if(team == 2)
	{
		new iMenu = menu_create("\rWeapon Abilities Menu^n\yChoose a weapon with ability:^n", "weapon_ability_handler")
		
		new szName[256], szFlags[16]
		
		for (new i = 0; i < iTotalWeapons; i++)
		{
			ArrayGetString(WeaponNames, i, szName, charsmax(szName))
			ArrayGetString(WeaponAbbilities, i, szFlags, charsmax(szFlags))
					
			menu_additem(iMenu, FormatItem(szName, szFlags), _, _, menu_makecallback("weapon_ability_callback"))
		}
		
		menu_display(id, iMenu)
		
		return PLUGIN_HANDLED
	}
	else
	{
		client_print(id, "You are T.You cannot use Weapon Special Abilities!")
		return PLUGIN_HANDLED
	}
}

public weapon_ability_callback(id, iMenu, Item)
{
	if (Item == iCurrentWeapon[id])
	{
		return ITEM_DISABLED
	}
	
	return ITEM_ENABLED
}

public weapon_ability_handler(id, iMenu, Item)
{
	if (Item == MENU_EXIT)
	{
		menu_destroy(iMenu)
		return PLUGIN_HANDLED
	}
	
	iCurrentWeapon[id] = Item
	
	if (is_user_alive(id) && get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
		eventCurrentWeapon(id)
	}
	
	menu_destroy(iMenu)
	
	return PLUGIN_HANDLED
}

SetWeapon(id)
{
	if (!iCurrentWeapon[id]) return
	
	new szVModel[64], szPModel[64]
	
	ArrayGetString(WeaponViewModels, iCurrentWeapon[id], szVModel, charsmax(szVModel))
	ArrayGetString(WeaponWorldModels, iCurrentWeapon[id], szPModel, charsmax(szPModel))
	
	set_pev(id, pev_viewmodel2, szVModel)
	set_pev(id, pev_weaponmodel2, szPModel)
}

FormatItem(szName[256], szFlags[16])
{
	if (has_ability(szFlags, "a"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Damage")
	}
	
	if (has_ability(szFlags, "b"))
	{
		add(szName, charsmax(szName), " \y| \rLower Gravity")
	}
	
	if (has_ability(szFlags, "c"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Speed")
	}
	
	if (has_ability(szFlags, "d"))
	{
		add(szName, charsmax(szName), " \y| \rLower visibility")
	}
	
	if (has_ability(szFlags, "e"))
	{
		add(szName, charsmax(szName), " \y| \rNo Footsteps")
	}
	
	if (has_ability(szFlags, "f"))
	{
		add(szName, charsmax(szName), " \y| \rHealth Regen")
	}
	
	if (has_ability(szFlags, "g"))
	{
		add(szName, charsmax(szName), " \y| \rBurn Players")
	}
	
	if (has_ability(szFlags, "h"))
	{
		add(szName, charsmax(szName), " \y| \rFreeze Players")
	}
	
	return szName
}

PrecacheModel(szModel[])
{
	if (file_exists(szModel))
	{
		precache_model(szModel)
	}
	else
	{
		log_amx("Failed to precache: ^"%s^"! It's missing or may have a wrong name!", szModel)
	}
}

stock has_ability(szFlags[], szFlag[])
{
	return (contain(szFlags, szFlag) != -1) ? true : false
}

//Set rendering from fakemeta_util
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, Float:amount)
{
	new Float:RenderColor[3]
	RenderColor[0] = float(r)
	RenderColor[1] = float(g)
	RenderColor[2] = float(b)

	set_pev(entity, pev_renderfx, fx)
	set_pev(entity, pev_rendercolor, RenderColor)
	set_pev(entity, pev_rendermode, render)
	set_pev(entity, pev_renderamt, amount)

	return 1;
}
[/quote]

Благодаря! А може ли да му се добави, както в плъгина "ModelsMenu", флагове, примерно за еди кой си нож да има определен флаг?

Потребителски аватар
Microxx
Newbie
Мнения: 5
Регистриран: съб авг 27, 2016 6:07 pm
Баланс: Locked

пон авг 29, 2016 9:57 pm

Може.Трябва само да се опише кое как да седи и с кой флаг.

Потребителски аватар
MuHaBaM
Member
Мнения: 56
Регистриран: ср май 25, 2016 12:50 pm
Баланс: Locked

вт авг 30, 2016 10:25 am

[quote="Irie"][quote="Microxx"][quote="Irie"]Искам плъгина на @TheRedShoko - Weapon Special Abilities, да го редактирате, за да бъде само за CT отбора![/quote]

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <xs>

#define VERSION "1.1"
#define TASK_REGEN 123
#define TASK_BURN 156
#define TASK_FREEZE 188

enum Cvars
{
	WEAPON_WHICH,
	MULT_DMG,
	GRAVITY,
	SPEED,
	VISIBILITY,
	REGEN,
	REGEN_TIME,
	REGEN_MAX,
	FIRE_DURATION,
	FIRE_HURT,
	FREEZE_TIME
}

new szWeaponCommands[][] =
{
	"say /weapon",
	"say /weapons",
	"say /abilities",
	"say_team /weapon",
	"say_team /weapons",
	"say_team /abilities"
}

new Array:WeaponNames, Array:WeaponAbbilities, Array:WeaponViewModels, Array:WeaponWorldModels
new iTotalWeapons, iCvars[Cvars], iCurrentWeapon[33], iUserFireAttacker[33], iUserFireDuration[33]
new iMsgStatusIcon, iSprFlame, iSprSmoke, iGlassGibs

new szIceModel[] = "models/wsa/ice_cube.mdl"
new szIceBlockClassname[] = "entity_ice_block"

public plugin_init()
{
	register_plugin("Weapon Special Abilities", VERSION, "TheRedShoko")
	register_cvar("weapon_abilities_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
	
	register_event("CurWeapon", "eventCurrentWeapon", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePre", 0)
	RegisterHam(Ham_TakeDamage, "player", "playerTakeDamagePost", 1)
	RegisterHam(Ham_TraceAttack, "player", "playerAttackPre", 0)
	
	for (new i = 0; i < sizeof(szWeaponCommands); i++)
	{
		register_clcmd(szWeaponCommands[i], "weapon_ability_menu")
	}
	
	iMsgStatusIcon = get_user_msgid("StatusIcon")
	
	iCvars[WEAPON_WHICH] = register_cvar("ability_weapon", "29") // The index of the weapon! Default: 29 - knife
	iCvars[MULT_DMG] = register_cvar("weapon_ability_damage", "2.0") // How many times the damage will be higher for weapons with flag "a"! Default: 2.0
	iCvars[GRAVITY] = register_cvar("weapon_ability_gravity", "500") // The amount of gravity for weapons with flag "b" using sv_gravity cvar! Default: 500
	iCvars[SPEED] = register_cvar("weapon_ability_speed", "340") // The amount of speed for weapons with flag "c"! Default: 340
	iCvars[VISIBILITY] = register_cvar("weapon_ability_invisibility", "60") //The amount in % of visibility for weapons with flag "d"! Default: 60
	iCvars[REGEN] = register_cvar("weapon_ability_regen", "5") // The amount of health that will be regenerated for weapons with flag "f"! Default: 5
	iCvars[REGEN_TIME] = register_cvar("weapon_ability_regen_time", "5.0") // The delay between every health delay in float! Default: 5.0
	iCvars[REGEN_MAX] = register_cvar("weapon_ability_regen_maxhp", "150") // The max amount of health that user can regen! Default: 150
	iCvars[FIRE_DURATION] = register_cvar("weapon_ability_fire_duration", "10") // The duration of the fire when user is burned. Default: 10
	iCvars[FIRE_HURT] = register_cvar("weapon_ability_fire_hurt", "10") // The amount of health that will be taken while burning. Default: 10
	iCvars[FREEZE_TIME] = register_cvar("weapon_ability_freeze_time", "10") //The frost duration. Defautl: 10
}

public plugin_precache()
{
	WeaponNames = ArrayCreate(32, 1)
	WeaponAbbilities = ArrayCreate(16, 1)
	WeaponViewModels = ArrayCreate(64, 1)
	WeaponWorldModels = ArrayCreate(64, 1)
	
	Load_File()
	
	new szModel[128]
	
	for (new i = 1; i < iTotalWeapons; i++)
	{
		ArrayGetString(WeaponViewModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
		
		ArrayGetString(WeaponWorldModels, i, szModel, charsmax(szModel))
		
		PrecacheModel(szModel)
	}
	
	PrecacheModel(szIceModel)
	
	iSprFlame = precache_model("sprites/flame.spr")
	iSprSmoke = precache_model("sprites/black_smoke1.spr")
	iGlassGibs = precache_model("models/glassgibs.mdl")
}

public client_connect(id)
{
	reset(id)
}

public client_disconnect(id)
{
	reset(id)
}

reset(id)
{
	if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	if (task_exists(TASK_FREEZE + id))
	{
		remove_task(TASK_FREEZE + id)
		user_unfreeze(TASK_FREEZE + id)
	}
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
	}
	
	iCurrentWeapon[id] = 0
}

public playerAttackPre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], tracehandle, damage_type)
{
	if (!is_user_connected(iAttacker) || iVictim == iAttacker)
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (task_exists(TASK_FREEZE + iVictim))
	{
		if (has_ability(szFlags, "g") && get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
		|| !has_ability(szFlags, "g"))
		{
			return HAM_SUPERCEDE
		}
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePre(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) 
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "a"))
	{
		SetHamParamFloat(4, flDamage * get_pcvar_float(iCvars[MULT_DMG]))
	}
	
	if (has_ability(szFlags, "h"))
	{
		set_task(0.1, "user_freeze", iVictim + TASK_FREEZE)
	}
	
	return HAM_IGNORED
}

public playerTakeDamagePost(iVictim, Inflictor, iAttacker, Float:flDamage, iDmgBits)
{
	if (iAttacker == iVictim || !is_user_connected(iAttacker) || !is_user_alive(iVictim)
	|| get_user_weapon(iAttacker) != get_pcvar_num(iCvars[WEAPON_WHICH])
	|| get_user_team(iAttacker) == get_user_team(iVictim))
	{
		return HAM_IGNORED
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[iAttacker], szFlags, charsmax(szFlags))
	
	if (has_ability(szFlags, "g"))
	{
		iUserFireAttacker[iVictim] = iAttacker
		iUserFireDuration[iVictim] = get_pcvar_num(iCvars[FIRE_DURATION])
		
		set_task(0.1, "start_burn", TASK_BURN + iVictim)
	}
	
	return HAM_IGNORED
}

public eventCurrentWeapon(id)
{
	new iWeapon = read_data(2)
	
	if (iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
	}
	
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	set_pev(id, pev_gravity, ((has_ability(szFlags, "b") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[GRAVITY]) : 800.0 ) / 800.0)
	
	set_pev(id, pev_maxspeed, (has_ability(szFlags, "c") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? get_pcvar_float(iCvars[SPEED]) : 270.0)
	
	set_user_footsteps(id, ((has_ability(szFlags, "e") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? 1 : 0))
	
	if (has_ability(szFlags, "f") && !task_exists(TASK_REGEN + id) && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_task(get_pcvar_float(iCvars[REGEN_TIME]), "user_regen", TASK_REGEN + id, .flags = "b")
	}
	else if (task_exists(TASK_REGEN + id))
	{
		remove_task(TASK_REGEN + id)
	}
	
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, (has_ability(szFlags, "d") && iWeapon == get_pcvar_num(iCvars[WEAPON_WHICH])) ? (255 - (2.55 * get_pcvar_float(iCvars[VISIBILITY]))) : 255.0)
}

public user_regen(taskid)
{
	new id = taskid - TASK_REGEN
	new szFlags[8]
	ArrayGetString(WeaponAbbilities, iCurrentWeapon[id], szFlags, charsmax(szFlags))
	
	if (pev(id, pev_health) < get_pcvar_float(iCvars[REGEN_MAX]) && has_ability(szFlags, "f")
	&& get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		set_pev(id, pev_health, ((pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) < get_pcvar_num(iCvars[REGEN_MAX])) ? (pev(id, pev_health) + get_pcvar_float(iCvars[REGEN])) : 150.0)
	}
}

public start_burn(taskid)
{
	static id; id = taskid - TASK_BURN
	
	if (!is_user_connected(id) || !is_user_alive(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_heat")
	message_end()
	
	if (~pev(id, pev_flags) & FL_INWATER && !task_exists(TASK_FREEZE + id))
	{
		iUserFireDuration[id]--
	}
	else
	{
		iUserFireDuration[id] = 0
		
		if (task_exists(TASK_FREEZE + id))
		{
			user_unfreeze(TASK_FREEZE + id)
			remove_task(TASK_FREEZE + id)
		}
	}
	
	if (iUserFireDuration[id])
	{
		if (pev(id, pev_health) > get_pcvar_float(iCvars[FIRE_HURT]))
		{
			set_pev(id, pev_health, pev(id, pev_health) - get_pcvar_float(iCvars[FIRE_HURT]))
			
			message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
			write_byte(TE_SPRITE)
			write_coord(origin[0])
			write_coord(origin[1])
			write_coord(origin[2])
			write_short(iSprFlame)
			write_byte(10)
			write_byte(180)
			message_end()
			
			message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
			write_byte(3)
			write_string("dmg_heat")
			write_byte(255)
			write_byte(85)
			write_byte(0)
			message_end()
		}
		else
		{
			iUserFireDuration[id] = 0
			
			if (is_user_connected(iUserFireAttacker[id]))
			{
				ExecuteHamB(Ham_Killed, id, iUserFireAttacker[id], false)
			}
			else
			{
				ExecuteHamB(Ham_Killed, id, id, false)
			}
		}
	}
	
	if (iUserFireDuration[id])
	{
		set_task(1.0, "start_burn", taskid)
	}
	else
	{
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_SMOKE)
		write_coord(origin[0])
		write_coord(origin[1])
		write_coord(origin[2])
		write_short(iSprSmoke)
		write_byte(7)
		write_byte(30)
		message_end()
	}
}	

public user_freeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	if (task_exists(TASK_BURN + id))
	{
		remove_task(TASK_BURN + id)
		return
	}
	
	static Float:origin[3]
	pev(id, pev_origin, origin)
	origin[2] -= 35.0
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_KILLBEAM)
	write_short(id)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(3)
	write_string("dmg_cold")
	write_byte(0)
	write_byte(200)
	write_byte(255)
	message_end()
	
	fm_set_rendering(id, kRenderFxGlowShell, 0, 200, 255, kRenderNormal, 60.0)
	set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
	
	new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if (pev_valid(iEnt))
	{
		set_pev(iEnt, pev_classname, szIceBlockClassname)
		set_pev(iEnt, pev_movetype, MOVETYPE_NONE)
		set_pev(iEnt, pev_solid, SOLID_BBOX)
		set_pev(iEnt, pev_iuser1, id)
		set_pev(iEnt, pev_origin, origin)
		set_pev(iEnt, pev_size, Float:{ -4.67, -4.04, -4.62 }, Float:{ 4.68, 4.05, 13.01 })
		engfunc(EngFunc_SetModel, iEnt, szIceModel)
		fm_set_rendering(iEnt, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255.0)
	}
	
	set_task(get_pcvar_float(iCvars[FREEZE_TIME]), "user_unfreeze", TASK_FREEZE + id)
}

public user_unfreeze(taskid)
{
	static id; id = taskid - TASK_FREEZE
	
	new iEnt, iUser
	
	while ( (iEnt = engfunc(EngFunc_FindEntityByString, -1, "classname", szIceBlockClassname)) > 0)
	{
		iUser = pev(iEnt, pev_iuser1)
		
		if (iUser == id)
		{
			engfunc(EngFunc_RemoveEntity, iEnt)
			
			break
		}
	}
	
	if (!is_user_connected(id))
	{
		return
	}
	
	static origin[3]
	get_user_origin(id,origin)
	
	message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id)
	write_byte(0)
	write_string("dmg_cold")
	message_end()
	
	set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
	fm_set_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 16.0)
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_BREAKMODEL)
	write_coord(origin[0])
	write_coord(origin[1])
	write_coord(origin[2] + 24)
	write_coord(16)
	write_coord(16)
	write_coord(16)
	write_coord(random_num(-50,50))
	write_coord(random_num(-50,50))
	write_coord(25)
	write_byte(10)
	write_short(iGlassGibs)
	write_byte(14)
	write_byte(30)
	write_byte(0x01)
	message_end()
}

Load_File()
{
	new szFile[128]
	get_configsdir(szFile, charsmax(szFile))
	
	add(szFile, charsmax(szFile), "/weapon_list.ini")
	
	new iLine, szData[128], buffer

	new szName[32], szFlags[16], szVModel[64], szPModel[64]
	
	if (file_exists(szFile))
	{
		iTotalWeapons = 1
		
		ArrayPushString(WeaponNames, "Classic")
		ArrayPushString(WeaponAbbilities, "")
		ArrayPushString(WeaponViewModels, "")
		ArrayPushString(WeaponWorldModels, "")
		
		while ( (iLine = read_file(szFile, iLine, szData, charsmax(szData), buffer)) )
		{
			if (!szData[0] || szData[0] == '/' && szData[1] == '/' || szData[0] == ';') continue
			
			parse(szData, szName, charsmax(szName), szFlags, charsmax(szFlags), szVModel, charsmax(szVModel), szPModel, charsmax(szPModel))
			
			ArrayPushString(WeaponNames, szName)
			ArrayPushString(WeaponAbbilities, szFlags)
			ArrayPushString(WeaponViewModels, szVModel)
			ArrayPushString(WeaponWorldModels, szPModel)
			
			iTotalWeapons++
		}
	}
	else
	{
		new iFile = fopen(szFile, "wt")
		
		if (iFile)
		{
			new szLine[256]
			
			formatex(szLine, charsmax(szLine), "; Weapon Abilities by TheRedShoko^n; Flags:^n; a - Higher damage^n; b - Lower Gravity^n; c - Higher Speed^n; d - Less Visibility^n; e - No footsteps^n")
			
			fputs(iFile, szLine)
			
			formatex(szLine, charsmax(szLine), "; f - Health Regen^n; g - Burn Players^n; h - Freeze Players^n; ^"Weapon Name to be displayed^" ^"Flags^" ^"v_model path^" ^"p_model path^"^n")
			
			fputs(iFile, szLine)
			
			fclose(iFile)
		}
	}
}

public weapon_ability_menu(id)
{
	new team = get_user_team(id)
	if(team == 2)
	{
		new iMenu = menu_create("\rWeapon Abilities Menu^n\yChoose a weapon with ability:^n", "weapon_ability_handler")
		
		new szName[256], szFlags[16]
		
		for (new i = 0; i < iTotalWeapons; i++)
		{
			ArrayGetString(WeaponNames, i, szName, charsmax(szName))
			ArrayGetString(WeaponAbbilities, i, szFlags, charsmax(szFlags))
					
			menu_additem(iMenu, FormatItem(szName, szFlags), _, _, menu_makecallback("weapon_ability_callback"))
		}
		
		menu_display(id, iMenu)
		
		return PLUGIN_HANDLED
	}
	else
	{
		client_print(id, "You are T.You cannot use Weapon Special Abilities!")
		return PLUGIN_HANDLED
	}
}

public weapon_ability_callback(id, iMenu, Item)
{
	if (Item == iCurrentWeapon[id])
	{
		return ITEM_DISABLED
	}
	
	return ITEM_ENABLED
}

public weapon_ability_handler(id, iMenu, Item)
{
	if (Item == MENU_EXIT)
	{
		menu_destroy(iMenu)
		return PLUGIN_HANDLED
	}
	
	iCurrentWeapon[id] = Item
	
	if (is_user_alive(id) && get_user_weapon(id) == get_pcvar_num(iCvars[WEAPON_WHICH]))
	{
		SetWeapon(id)
		eventCurrentWeapon(id)
	}
	
	menu_destroy(iMenu)
	
	return PLUGIN_HANDLED
}

SetWeapon(id)
{
	if (!iCurrentWeapon[id]) return
	
	new szVModel[64], szPModel[64]
	
	ArrayGetString(WeaponViewModels, iCurrentWeapon[id], szVModel, charsmax(szVModel))
	ArrayGetString(WeaponWorldModels, iCurrentWeapon[id], szPModel, charsmax(szPModel))
	
	set_pev(id, pev_viewmodel2, szVModel)
	set_pev(id, pev_weaponmodel2, szPModel)
}

FormatItem(szName[256], szFlags[16])
{
	if (has_ability(szFlags, "a"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Damage")
	}
	
	if (has_ability(szFlags, "b"))
	{
		add(szName, charsmax(szName), " \y| \rLower Gravity")
	}
	
	if (has_ability(szFlags, "c"))
	{
		add(szName, charsmax(szName), " \y| \rHigher Speed")
	}
	
	if (has_ability(szFlags, "d"))
	{
		add(szName, charsmax(szName), " \y| \rLower visibility")
	}
	
	if (has_ability(szFlags, "e"))
	{
		add(szName, charsmax(szName), " \y| \rNo Footsteps")
	}
	
	if (has_ability(szFlags, "f"))
	{
		add(szName, charsmax(szName), " \y| \rHealth Regen")
	}
	
	if (has_ability(szFlags, "g"))
	{
		add(szName, charsmax(szName), " \y| \rBurn Players")
	}
	
	if (has_ability(szFlags, "h"))
	{
		add(szName, charsmax(szName), " \y| \rFreeze Players")
	}
	
	return szName
}

PrecacheModel(szModel[])
{
	if (file_exists(szModel))
	{
		precache_model(szModel)
	}
	else
	{
		log_amx("Failed to precache: ^"%s^"! It's missing or may have a wrong name!", szModel)
	}
}

stock has_ability(szFlags[], szFlag[])
{
	return (contain(szFlags, szFlag) != -1) ? true : false
}

//Set rendering from fakemeta_util
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, Float:amount)
{
	new Float:RenderColor[3]
	RenderColor[0] = float(r)
	RenderColor[1] = float(g)
	RenderColor[2] = float(b)

	set_pev(entity, pev_renderfx, fx)
	set_pev(entity, pev_rendercolor, RenderColor)
	set_pev(entity, pev_rendermode, render)
	set_pev(entity, pev_renderamt, amount)

	return 1;
}
[/quote]

Благодаря! А може ли да му се добави, както в плъгина "ModelsMenu", флагове, примерно за еди кой си нож да има определен флаг?[/quote]


Нож и флаг? :?

Отговори

Върни се в “AMX Mod (X)”

  • Информация
  • Кой е на линия

    Потребители, разглеждащи този форум: Няма регистрирани потребители и 0 госта