Rework of bullet damage plugin

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
Kobra
Извън линия
Foreigner
Foreigner
Мнения: 20
Регистриран на: 06 Ное 2018, 20:55
Се отблагодари: 1 път
Получена благодарност: 1 път

Rework of bullet damage plugin

Мнение от Kobra » 03 Юли 2022, 23:28

Hey everyone . Could someone add flag support to this plugin ? https://forums.alliedmods.net/showthread.php?t=151190
I would like only the VIP players to receive bullet damage benefit.Thank you !

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

Rework of bullet damage plugin

Мнение от YankoNL » 10 Юли 2022, 20:25

I have a one that is a bit modified, but it's the same I guess. I haven't tested it.
You can change the flag from here #define VIP_FLAG ADMIN_RESERVATION and the setting for the plugin can be change from /cstrike/addons/amxmodx/configs/plugins/"plugin_name".cfg

For example if the plugin is called bulletDMG and the path will be /cstrike/addons/amxmodx/configs/plugins/bulletDMG.cfg

Hope this helps you.

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <engine>

#define VERSION "2.1"

#define DIRECTOR_HUD_MESSAGE 0
#define NORMAL_HUD_MESSAGE 1

#define VIP_FLAG ADMIN_RESERVATION

enum _:Cvars
{
	BULLET_MODE, BULLET_DISTANCE, BULLET_WALL, BULLET_HS_MODE, BULLET_SPEC,
	BULLET_TEXT_MODE, BULLET_SHOW_MODE, BULLET_ACCUMULATED,
	COLOR_VICTIM, COLOR_OURSELF, COLOR_ATTACKER
}

new g_eCvars[Cvars]

const FCVAR_TYPE = FCVAR_NONE	//FCVAR_SPONLY|FCVAR_PROTECTED

new Float:Yv[33], Float:Xv[33] /* Victim*/, Float:Ya[33], Float:Xa[33] // Attacker

new bool:isHudOn[33], iCurrentDMG[33], g_SyncHudObj

public plugin_init() 
{
	register_plugin("Bullet Damage", VERSION, "Bboy Grun")
	
	register_cvar("Director_bullet_dmg", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
	set_cvar_string("Director_bullet_dmg", VERSION)
	
	register_event("Damage", "Event_Damage", "b", "2!0", "3=0", "4!0") 
	
	register_clcmd("say /showbd", "Say_showbd")
	
	g_SyncHudObj = CreateHudSyncObj()
	
	bind_pcvar_num(create_cvar("Bullet_Damage_Mode", "0", FCVAR_TYPE, "Change DMG display Mode", true, 0.0, true, 1.0), g_eCvars[BULLET_MODE])
	bind_pcvar_num(create_cvar("Bullet_Damage_Distance", "600", FCVAR_TYPE, "When the attacker and the victim are at X distance *uses HudMessage*"), g_eCvars[BULLET_DISTANCE])
	bind_pcvar_num(create_cvar("Bullet_Damage_NoShowWalls", "0", FCVAR_TYPE, "Hide DMG display when shooting thru walls", true, 0.0, true, 1.0), g_eCvars[BULLET_WALL])
	bind_pcvar_num(create_cvar("Bullet_Show_Spec", "1", FCVAR_TYPE, "Display DMG to the spectators", true, 0.0, true, 1.0), g_eCvars[BULLET_SPEC])
	bind_pcvar_num(create_cvar("Bullet_Hs_Mode", "2", FCVAR_TYPE, "Headshot display mode ^n- 0 : Disabled^n- 1 : Always show HUD^n- 2 : Show *HEADSHOT* to the Victim & Attacker", true, 0.0, true, 2.0), g_eCvars[BULLET_HS_MODE])
	bind_pcvar_num(create_cvar("Bullet_Text_Mode", "0", FCVAR_TYPE, "Switch between 0 - DHUD & 1 - HUD", true, 0.0, true, 1.0), g_eCvars[BULLET_TEXT_MODE])
	bind_pcvar_num(create_cvar("Bullet_Show_Mode", "3", FCVAR_TYPE, "Switch DMG display Mode^n- 0 : Circle^n- 1 : Vertical^n- 2 : Horizontal^n 3 : Arch of circle", true, 0.0, true, 3.0), g_eCvars[BULLET_SHOW_MODE])
	bind_pcvar_num(create_cvar("Show_Accumulated_Damage", "1", FCVAR_TYPE, "Show the accumulated damages for the last 5.0 seconds", true, 0.0, true, 1.0), g_eCvars[BULLET_ACCUMULATED])
	bind_pcvar_num(create_cvar("Color_RGB_Victim", "255000000", FCVAR_TYPE, "DMG Color for the Victim in RGB code"), g_eCvars[COLOR_VICTIM])
	bind_pcvar_num(create_cvar("Color_RGB_Attacker", "000255000", FCVAR_TYPE, "DMG Color for the Attacker in RGB code"), g_eCvars[COLOR_ATTACKER])
	bind_pcvar_num(create_cvar("Color_RGB_Ourself_Teammate", "255102021", FCVAR_TYPE, "DMG Color for Ourself or Teammates in RGB code"), g_eCvars[COLOR_OURSELF])
}

public Event_Damage(Victim)
{    
	static Attacker, AttackerWpn, VictimBodyPart
	Attacker = get_user_attacker(Victim, AttackerWpn, VictimBodyPart)
	
	if(!is_user_alive(Attacker) || !is_user_vip(Attacker) || g_eCvars[BULLET_WALL] && !is_visible(Attacker, Victim))
		return
		
	static iDMG, R, G, B, iHSMode, iTextMode
	iDMG = read_data(2)
	
	iHSMode = g_eCvars[BULLET_HS_MODE]
	iTextMode = g_eCvars[BULLET_TEXT_MODE]
	
	static AttackerOrigin[3], VictimOrigin[3]
	
	if(Attacker != Victim && get_user_team(Attacker) != get_user_team(Victim))
	{
		if(iHSMode > 0 && VictimBodyPart == HIT_HEAD)
		{
			if(iHSMode == 1)
			{
				show_client_value(Victim, iDMG, 0, DIRECTOR_HUD_MESSAGE)
				show_client_value(Attacker, iDMG, 1, DIRECTOR_HUD_MESSAGE)
			}
			else
			{
				show_client_text(Victim, "HEADSHOT", 0, iTextMode)
				show_client_text(Attacker, "HEADSHOT", 1, iTextMode)
			}
		}
		else
		{
			if(!g_eCvars[BULLET_MODE])
			{
				show_client_value(Victim, iDMG, 0, DIRECTOR_HUD_MESSAGE)
				show_client_value(Attacker, iDMG, 1, DIRECTOR_HUD_MESSAGE)
			}
		
			else
			{
				get_user_origin(Attacker, AttackerOrigin)
				get_user_origin(Victim, VictimOrigin)
				
				if(get_distance(AttackerOrigin, VictimOrigin) >  g_eCvars[BULLET_DISTANCE])
				{
					show_client_value(Victim, iDMG, 0, NORMAL_HUD_MESSAGE)
					show_client_value(Attacker, iDMG, 1, NORMAL_HUD_MESSAGE)
				}
				else
				{
					show_client_value(Victim, iDMG, 0, DIRECTOR_HUD_MESSAGE)
					show_client_value(Attacker, iDMG, 1, DIRECTOR_HUD_MESSAGE)
				}
			}
		}
        
		CheckPosition(Victim, 0)
		CheckPosition(Attacker, 1)
		
		if(iCurrentDMG[Attacker] == -1 || !g_eCvars[BULLET_ACCUMULATED])
			return
		
		iCurrentDMG[Attacker] += iDMG
		UpdateDamages(Attacker)
	}
	else
	{
		static iColor; iColor = g_eCvars[COLOR_OURSELF]
		R = iColor / 1000000
		iColor %= 1000000
		G = iColor / 1000
		B = iColor % 1000
		
		set_dhudmessage(R, G, B, -1.0, -1.0, 2, 0.0, 2.0, 0.1, 0.1)
		show_dhudmessage(Victim, "%i", iDMG)
	}
}

public Say_showbd(id) 
{
	if(!is_user_vip(id))
	{
		client_print(id, print_chat, "[BULLET DAMAGE %s] This function is only for V.I.P Players!", VERSION)
		return
	}

	if(isHudOn[id])
	{
		isHudOn[id] = false
		client_print(id, print_chat, "[BULLET DAMAGE %s] STATUS : OFF", VERSION)
		return
	}
	
	client_print(id, print_chat, "[BULLET DAMAGE %s] STATUS : ON", VERSION)
	isHudOn[id] = true
}

public client_putinserver(id)
{
	iRefreshHudPosition(id)
	
	isHudOn[id] = true
	iCurrentDMG[id] = is_user_bot(id) ? -1 : 0
}

UpdateDamages(id)
{
	if(!isHudOn[id])
		return
	
	set_hudmessage(0, 255, 0, -1.0, -0.50, 0, 0.0, 4.0, 0.0, 1.0, -1)
	ShowSyncHudMsg(id, g_SyncHudObj, "%d", iCurrentDMG[id])
	
	if(task_exists(999_666_999 + id))
		remove_task(999_666_999 + id) 
	
	set_task(5.0, "ResetCurrentDamages", 999_666_999 + id)
}

public ResetCurrentDamages(TaskID)
	iCurrentDMG[TaskID - 999_666_999] = 0

show_client_value(id, iDMG, Attacker, iSize)
{
	if(!isHudOn[id])
		return
	
	static iColor, R, G, B, Float: Y_Pos, Float: X_Pos
	
	if(Attacker) // The user is the Attacker (Attacker value = 1)
	{
		iColor = g_eCvars[COLOR_ATTACKER]
		Y_Pos = Ya[id]
		X_Pos = Xa[id]
	}
	else
	{
		iColor = g_eCvars[COLOR_VICTIM]
		Y_Pos = Yv[id]
		X_Pos = Xv[id]
	}
	
	R = iColor / 1000000
	iColor %= 1000000
	G = iColor / 1000
	B = iColor % 1000
	
	if(iSize)
	{
		set_hudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02)
		show_hudmessage(id, "%i", iDMG)
	}
	else
	{
		set_dhudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02)
		show_dhudmessage(id, "%i", iDMG)
	}
	
	if(!g_eCvars[BULLET_SPEC])
		return
	
	SpectatorHud(id, iDMG, _, 0, iSize, Float:X_Pos, Float:Y_Pos, R, G, B)
}

show_client_text(id, iText[], Attacker, iSize)
{
	if(!isHudOn[id])
	{
		return;
	}
	
	static iColor, R, G, B, Float: Y_Pos, Float: X_Pos
	
	if(Attacker) // The user is the Attacker (Attacker value = 1)
	{
		iColor = g_eCvars[COLOR_ATTACKER]
		Y_Pos = Ya[id]
		X_Pos = Xa[id]
	}
	else
	{
		iColor = g_eCvars[COLOR_VICTIM]
		Y_Pos = Yv[id]
		X_Pos = Xv[id]
	}
	
	R = iColor / 1000000
	iColor %= 1000000
	G = iColor / 1000
	B = iColor % 1000
	
	if(!iSize)
	{
		set_dhudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02)
		show_dhudmessage(id, "%s", iText)
	}
	else
	{
		set_hudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02, -1)
		show_hudmessage(id, "%s", iText)
	}
	
	if(!g_eCvars[BULLET_SPEC])
		return
	
	SpectatorHud(id, _, iText, 1, iSize, Float: X_Pos, Float: Y_Pos, R, G, B)
}

SpectatorHud(id, iDMG = 0, iText[] = "", TextMode, Size, Float: X_Pos, Float: Y_Pos, R, G, B)
{
	static iPlayers[32], iNum
	get_players(iPlayers, iNum, "bch")
	
	for(new i = 0, Spectator = iPlayers[0]; i < iNum; Spectator = iPlayers[i++])
	{		
		if(isHudOn[Spectator] && entity_get_int(Spectator, EV_INT_iuser2) == id)
		{
			if(!Size)
			{
				set_dhudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02)
				TextMode ? show_dhudmessage(Spectator, "%s", iText) : show_dhudmessage(Spectator, "%d", iDMG)
			}
			else
			{
				set_hudmessage(R, G, B, X_Pos, Y_Pos, 2, 0.0, 1.0, 0.02, 0.02, -1)
				TextMode ? show_hudmessage(Spectator, "%s", iText) : show_hudmessage(Spectator, "%d", iDMG)
			}
		}
	}
}

iRefreshHudPosition(id)
{
	switch(g_eCvars[BULLET_SHOW_MODE])
	{
		case 0:
		{
			Ya[id] = -0.50
			Xa[id] = -0.70
			
			Yv[id] = -0.45
			Xv[id] = -0.30
			
		}
		case 1:
		{
			Ya[id] = 0.55
			Xa[id] = 0.53
			
			Xv[id] = 0.45
			Yv[id] = 0.50
		}
		case 2:
		{
			Ya[id] = -0.35
			Xa[id] = -0.70
			
			Yv[id] = -0.20
			Xv[id] = -0.70
		}
		case 3:
		{
			Xv[id] = -0.80
			Yv[id] = -0.90
			
			Xa[id] = -0.20
			Ya[id] = -0.90
		}
	}
}

CheckPosition(id, Attacker)
{
	switch(g_eCvars[BULLET_SHOW_MODE]) 
	// [0 = CIRCLE] [1 = VERTICAL] [2 = HORIZONTAL] [3 = ARCH OF CIRCLE ]
	{
		case 0:
		{
			if(Attacker)
			{
				switch(Xa[id])
				{
					case -0.70: // First attack
					{
						Xa[id] = -0.575
						Ya[id] = -0.60
					}
					case -0.575: // Second
					{
						Xa[id] = -0.50
						Ya[id] = -0.625
					}
					case -0.50: // Third
					{
						Xa[id] = -0.425
						Ya[id] = -0.60
					}
					case -0.425: // Fourth
					{		
						Xa[id] = -0.30
						Ya[id] = -0.50
					}
					case -0.30: // Last
					{
						Xa[id] = -0.70
					}
					default: iRefreshHudPosition(id)
				}
			}
			else
			{
				switch(Xv[id])
				{
					case -0.30: // First attack
					{
						Xv[id] = -0.425
						Yv[id] = -0.35
					}
					case -0.425: // Second
					{		
						Xv[id] = -0.50
						Yv[id] = -0.30
					}
					case -0.50: // Third
					{
						Xv[id] = -0.575
						Yv[id] = -0.35
					}
					case -0.575: // fourth
					{
						Xv[id] = -0.70
						Yv[id] = -0.45
					}
					case -0.70: // Last
					{
						Xv[id] = -0.30
					}
					default: iRefreshHudPosition(id)
				}
			}
		}
		case 1:
		{
			if(Attacker) 
			{
				Ya[id] += 0.05
				if(Ya[id] >= 0.90)
				{
					Ya[id] = 0.55
				}
			}
			else
			{
				Yv[id] += 0.05
				if(Yv[id] >= 0.85)
				{
					Yv[id] = 0.50
				}
			}
		}
		case 2:
		{
			if(Attacker)
			{
				Xa[id] += 0.05
				if(Xa[id] >= -0.35)
				{
					Xa[id] = -0.70
				}
			}
			else
			{
				Xa[id] += 0.05
				if(Xv[id] >= -0.35)
				{
					Xv[id] = -0.70
				}
			}
		}
		case 3:
		{
			if(Attacker)
			{
				switch(Xa[id])
				{
					case -0.20: // First attack
					{
						
						if(Ya[id] == -0.20)
						{
							Xa[id] = -0.20
							Ya[id] = -0.90
						}
						else
						{
							Xa[id] = -0.15
							Ya[id] = -0.80
						}
					}
					case -0.15:
					{
						switch(Ya[id])
						{
							case -0.80: Ya[id] = -0.70
							case -0.70: Ya[id] = -0.60
							case -0.60: Ya[id] = -0.50
							case -0.50: Ya[id] = -0.40
							case -0.40: Ya[id] = -0.30
							case -0.30:
							{
								Xa[id] = -0.20
								Ya[id] = -0.20
							}
						}
					}
					default: iRefreshHudPosition(id)
				}
			}
			else
			{
				switch(Xv[id])
				{
					case -0.80: // First attack
					{
						
						if(Yv[id] == -0.20)
						{
							Xv[id] = -0.80
							Yv[id] = -0.90
						}
						else
						{
							Xv[id] = -0.85
							Yv[id] = -0.80
						}
					}
					case -0.85:
					{
						switch(Yv[id])
						{
							case -0.80: Yv[id] = -0.70
							case -0.70: Yv[id] = -0.60
							case -0.60: Yv[id] = -0.50
							case -0.50: Yv[id] = -0.40
							case -0.40: Yv[id] = -0.30
							case -0.30:
							{
								Xv[id] = -0.80
								Yv[id] = -0.20
							}
						}
					}
					default: iRefreshHudPosition(id)
				}
			}
		}
		default: iRefreshHudPosition(id)
	}
}

bool:is_user_vip(id)
	return bool:(get_user_flags(id) & VIP_FLAG)
	

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

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