Accurate "Show Damage" Plugin

El NegroEl Negro The Genuinely Only Sane PersonGuests
edited November 2015 in Scripting
AFTER THE 3.3 UPDATE, THIS IS NOW AN OBSOLETE PLUGIN. USE ONLY IF YOU WANT TO LEARN, TO DEBUG SOMETHING OR ANYTHING ELSE, BUT NOT FOR PRACTICAL REASONS.

One of SMs plugins, "Show damage" I think it is called, made by exvel's, is actually inaccurate.
The damage it shows is not valid, you can see that by hitting an archer, in which it deals -225 damage or so, that's enough to kill them but they are still alive.
So, for this, I'd like to give you guys a script I made (With the help from Felis, thanks to him...And to be honest, I wouldn't say I made it but oh well) that is exactly like the "Show Damage" plugin but shows the correct numbers;
#include <sourcemod>
#include <clientprefs>

public Plugin:myinfo = {
		name = "Damage Indicator",
		author = "",
		description = "Accurate PVK2 damage and hit indicator via text",
		version = "1.0",
		url = "http://www.pvkii.com/"
};

bool:block_timer[MAXPLAYERS + 1] = {false,...},
player_damage[MAXPLAYERS + 1],
player_old_health[MAXPLAYERS + 1],
String:DamageEventName[16];
new bool:FrameMod = true;

public OnPluginStart()
{

		// Hook all the events and use OnPlayerDamage as callback
		HookEvent("player_melee_swing", OnPlayerDamage, EventHookMode_Pre);

		HookEvent("player_ranged_impact", OnPlayerDamage, EventHookMode_Pre);

		HookEvent("player_bomb_explode", OnPlayerDamage, EventHookMode_Pre);



		FrameMod = false;
}

public OnClientConnected(client)
		block_timer[client] = false;

public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
		new client = GetClientOfUserId(GetEventInt(event, "userid"));
		block_timer[client] = false;
		
		return Plugin_Continue;
}

public Action:ShowDamage(Handle:timer, any:client)
{
		block_timer[client] = false;
		
		if (player_damage[client] <= 0 || !client || !IsClientInGame(client))
				return;

		PrintCenterText(client, "%i HP", player_damage[client]);
		player_damage[client] = 0;
}

CalcDamage(client, damage)
{		
			player_damage[client] += damage;
		  
			if (block_timer[client])
							return;
		  
			CreateTimer(0.01, ShowDamage, client);
			block_timer[client] = true;
}

public OnGameFrame()
{
		if (FrameMod)
		{
				for (new client = 1; client <= MaxClients; client++)
				{
						if (IsClientInGame(client))
						{
								player_old_health[client] = GetClientHealth(client);
						}
				}
		}
}

public Action:OnPlayerDamage(Handle:event, const String:name[], bool:dontBroadcast)
{		
			new client = GetClientOfUserId(GetEventInt(event, "userid")),
			damage = GetEventInt(event, "damage");
		  
			CalcDamage(client, damage);
			return Plugin_Continue;
}


All you have to do (the Server Owner, anyone who can change the server's files, plugins and stuff) is copy that code I put and paste it somewhere, make sure it is saved as .sp and not .txt or so, then move it into *servernamehere*\pirates, vikings and knights ii\pvkii\addons\sourcemod\scripting, add it there. Then move that .sp into spcomp.exe, it will make an .smx file. Add it on your "plugins" folder. Make sure you remove or replace the old "showdamage.smx".
Then, in the console, you have to type "sm plugins reload *thepluginnamehere*.sp".

If you're seriously too lazy to do that, I have attached a file already.
I make mods.
Your soul cannot be saved.
Like my mods and think I deserve something? It's always money, you can pay me up on PayPal using this e-mail; TheSandhog@outlook.com
Or just use this link; https://www.paypal.me/TheSandhog

Comments

  • El NegroEl Negro The Genuinely Only Sane Person Guests
    edited 6:30PM
    Known quirks (Bugs?):

    1. It won't show the exact damage you deal when delivering critical hits (Man-At-Arms' fart).
    2. Explosive damage might not be accurate, this is because it may affect friends as well. Also due to it being used to kill multiple targets, not just one, in which case it makes a total damage of all affected targets.
    I make mods.
    Your soul cannot be saved.
    Like my mods and think I deserve something? It's always money, you can pay me up on PayPal using this e-mail; TheSandhog@outlook.com
    Or just use this link; https://www.paypal.me/TheSandhog

Sign In or Register to comment.