Raised This Month: $ Target: $400
 0% 

Edit plugin Damage informer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlueSkiLz
BANNED
Join Date: Mar 2022
Location: GB
Old 04-01-2022 , 17:54   Edit plugin Damage informer
Reply With Quote #1

Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

ConVar g_cvEnable;
ConVar g_cvShow_damage_type;
ConVar g_cvShow_damage_mode;

public Plugin myinfo = 
{
	name = "Show Damage [Multi methods]",
	author = "TheBΦ$$♚#2967",
	description = "Show damage in hint message or HUD",
	version = "1.0",
	url = "http://sourcemod.net"
};

public void OnPluginStart()
{
	LoadTranslations("Simple_Show_Damage.phrases");

	g_cvEnable = CreateConVar("sm_show_damage_enable", "1", "Enable/Disable plugin?");
	g_cvShow_damage_type = CreateConVar("sm_show_damage_type", "1", "0 = Show damage in Hint message\n1 = Show damage in HUD message");
	g_cvShow_damage_mode = CreateConVar("sm_show_damage_mode", "1", "0 = Show damage to victim only\n1 = Show damage and remaining health of victim");

	HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
	AutoExecConfig(true, "Simple_Show_Damage");
}

public Action Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast)
{
	int victim = GetClientOfUserId(event.GetInt("userid"));
	int attacker = GetClientOfUserId(event.GetInt("attacker"));
	int health = event.GetInt("health");
	int damage = event.GetInt("dmg_health");

	if (g_cvEnable.BoolValue)
	{
		if (IsValidClient(attacker) && attacker != victim && victim != 0)
		{
			if (!g_cvShow_damage_type.BoolValue)
			{
				if (!g_cvShow_damage_mode.BoolValue)
					PrintHintText(attacker, "%t %i %t %N", "Damage Giver", damage, "Damage Taker", victim);
				else
					PrintHintText(attacker, "%t %i %t %N \n %t %i", "Damage Giver", damage, "Damage Taker", victim, "Health Remaining", health);
			}
			else
			{
				if (!g_cvShow_damage_mode.BoolValue)
				{
					if (health > 50)
						SetHudTextParams(-1.0, 0.45, 1.3, 0, 253, 30, 200, 1); // green
					else if ((health <= 50) && (health > 20))
						SetHudTextParams(-1.0, 0.45, 1.3, 253, 229, 0, 200, 1); // yellow
					else
						SetHudTextParams(-1.0, 0.45, 1.3, 255, 0, 0, 200, 1); // red
					ShowHudText(attacker, -1, "%i", damage);
				}
				else
				{
					if (health > 50)
						SetHudTextParams(0.43, 0.45, 1.3, 0, 253, 30, 200, 1); // green
					else if ((health <= 50) && (health > 20))
						SetHudTextParams(0.43, 0.45, 1.3, 253, 229, 0, 200, 1); // yellow
					else
						SetHudTextParams(0.43, 0.45, 1.3, 255, 0, 0, 200, 1); // red
					ShowHudText(attacker, -1, "%i", health);
	
					SetHudTextParams(0.57, 0.45, 1.3, 255, 255, 255, 200, 1); // white
					ShowHudText(attacker, -1, "%i", damage);
				}
			}
		}
		return Plugin_Continue;
	}
	return Plugin_Continue;
}

bool IsValidClient(int client)
{
	if (!(0 < client <= MaxClients)) return false;
	if (!IsClientInGame(client)) return false;
	return true;
}
who can color my plugin too?
And I would like to see type 1 and mode 1 because my cvars is not set
even if they are 1 both cvars
BlueSkiLz is offline
Send a message via ICQ to BlueSkiLz Send a message via AIM to BlueSkiLz Send a message via Yahoo to BlueSkiLz Send a message via Skype™ to BlueSkiLz
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 04-02-2022 , 16:31   Re: Edit plugin Damage informer
Reply With Quote #2

If you set the cvars to 1 but they're still showing as "0" then you should probably install Command and ConVar - Buffer Overflow Fixer to fix that issue.

SetHudTextParams is not showing color? This is for CS:GO or something?
__________________
Silvers is offline
BlueSkiLz
BANNED
Join Date: Mar 2022
Location: GB
Old 04-03-2022 , 07:25   Re: Edit plugin Damage informer
Reply With Quote #3

for CSGO
shows me exactly what the text looks like with {FFFFFF} text but not colored
BlueSkiLz is offline
Send a message via ICQ to BlueSkiLz Send a message via AIM to BlueSkiLz Send a message via Yahoo to BlueSkiLz Send a message via Skype™ to BlueSkiLz
BlueSkiLz
BANNED
Join Date: Mar 2022
Location: GB
Old 04-03-2022 , 15:34   Re: Edit plugin Damage informer
Reply With Quote #4

I solved it thank you, I needed a plugin to fix that message
BlueSkiLz is offline
Send a message via ICQ to BlueSkiLz Send a message via AIM to BlueSkiLz Send a message via Yahoo to BlueSkiLz Send a message via Skype™ to BlueSkiLz
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode