PDA

View Full Version : [REQ][CSGO]Show team damage to admins


LeetDonkey
06-13-2016, 02:18
Hello

It seems CS:GO only shows your own team if someone team damages.
This means if an admin is on the opposite team he won't be notified about the offender.

I'd like a plugin that notifies an admin about team damage on BOTH teams in the following format:

"PLAYERNAME team damaged OTHER PLAYERNAME for xx points"

I've been searching for a plugin doing this, or something similar but I've come up with nothing

If you know of a plugin doing something similar I would appreciate it if you informed me of where I could find it.

Thanks

shanapu
06-13-2016, 12:04
take a try for this...
not tested

//includes
#include <sourcemod>

//Compiler Options
#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = {
name = "Teamattack message",
author = "shanapu",
description = "Teamattack message to admin",
version = "1.0",
url = "shanapu.de"
};

public void OnPluginStart()
{
HookEvent("player_hurt", PlayerHurt, EventHookMode_Pre);
}

public Action PlayerHurt(Handle event, char [] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int dhealth = GetEventInt(event, "dmg_health");
char wname[64];
GetEventString(event, "weapon", wname, sizeof(wname));

if(GetClientTeam(victim) == GetClientTeam(attacker))
{
for(int i = 1; i <= MaxClients; i++) if (CheckCommandAccess(i, "sm_map", ADMFLAG_CHANGEMAP, true)) PrintToChat(i, "TEAMATTACK! victim: %N attacker: %N damage: %i HP",victim, attacker, dhealth);
}
return Plugin_Handled;
}

LeetDonkey
06-13-2016, 17:20
Hello

Thanks
I tested it, and when you damage an opponent SRCDS crashes:

./srcds_run: line 318: 575 Segmentation fault $HL_CMD
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Mon Jun 13 23:15:32 CEST 2016: Server restart in 10 seconds

I tried unloading all other plugins and it still crashes when teamattack.smx is loaded
I updated sourcemod to the latest stable as well, it doesn't change anything.

Anyways, thank you for giving it a shot, if you are able to fix the crashes it would be greatly appreciated.

Edit: I performed the test with both bots and humans, the result is the same.

Maxximou5
06-13-2016, 18:00
Try this one.
public void OnPluginStart()
{
HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
}

public Action Event_PlayerHurt(Handle event, char [] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int dhealth = GetEventInt(event, "dmg_health");

if (attacker != victim && victim != 0)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && CheckCommandAccess(i, "sm_map", ADMFLAG_CHANGEMAP, true))
{
PrintToChat(i, "%N team damaged %N for %i points!", attacker, victim, dhealth);
}
}
}
return Plugin_Handled;
}


stock bool IsValidClient(int client)
{
if (!(0 < client <= MaxClients)) return false;
if (!IsClientInGame(client)) return false;
return true;
}

LeetDonkey
06-14-2016, 03:55
Thanks, I'll give it a try when I get home from work

LeetDonkey
06-14-2016, 08:56
The new one still crashes the server once an opponent is damaged:

./srcds_run: line 318: 10590 Segmentation fault $HL_CMD
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Tue Jun 14 14:47:37 CEST 2016: Server restart in 10 seconds

I tried both the 'get plugin' and download source and compile it locally

Edit: I tested it with just bots this time, I didn't want to crash a server full of people :)

yash1441
06-14-2016, 09:47
Check this out.

LeetDonkey
06-14-2016, 14:19
Check this out.

Thank you for your suggestion

Getting closer - This one outputs info to chat without crashing BUT:

- It shows both friendly fire and non-friendly fire
- Damage is way off, it's showing millions of HP damage per shot

Edit: It also seems to show each shot multiple times

Arkarr
06-14-2016, 16:37
Not tested but should do the trick...


#include <sourcemod>
#include <sdkhooks>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
name = "Team Damage Show",
author = PLUGIN_AUTHOR,
description = "Shows team damage to admins.",
version = PLUGIN_VERSION,
url = "www.sourcemod.net"
};

public void OnPluginStart()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}

public void OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (attacker == victim || attacker == 0)
return Plugin_Continue;

if(GetClientTeam(victim) != GetClientTeam(attacker))
return Plugin_Continue;

for(new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
if (CheckCommandAccess(i, "PRINT_ONLY_TO_ADMIN", ADMFLAG_CHANGEMAP, true))
PrintToChat(i, "[Team Damage] %N team damaged %N for %.2f HP", attacker, victim, damage);
}
}

return Plugin_Continue;
}

LeetDonkey
06-16-2016, 10:31
Hello

It seems to be working, there's just one thing:
The damage is off, could it be that it does not factor in the damage reduction for team damage set in the .cfg file?

A team mate stabbed me in the back, it showed 180 damage but I didn't die :>

Anyways, it's just a minor thing, it's quite usable as it is.

Thanks for helping me out.

LeetDonkey
06-16-2016, 10:46
Also, if you ever feel like making some modifications to it an admin on my server suggested that it also outputs to the console window of admins as the chat sometimes scroll away very fast, I don't even know if it's possible but he suggested it and it seemed like a good idea :-)

Anyways, I'm sure I'm not the only one who can put this to good use.

Arkarr
06-16-2016, 17:05
Also, if you ever feel like making some modifications to it an admin on my server suggested that it also outputs to the console window of admins as the chat sometimes scroll away very fast, I don't even know if it's possible but he suggested it and it seemed like a good idea :-)

Anyways, I'm sure I'm not the only one who can put this to good use.
Well, I made your plugin, but I can't post it right now, AM seems to have troubles with couldflare.

LeetDonkey
06-18-2016, 13:00
Alright I'll check in regularly to see if you manage to post it :-)

Arkarr
06-18-2016, 15:29
Alright, take this : download link (http://puu.sh/py9TE/488d7ba3ac.sp)
Installation :
1. Compille it and put the smx in your plugins folder
2. Load the plugin using : sm plugins load TeamDamageReporter OR reload map
3. Go to configs folder, find the file TDRRanks.cfg and edit it. Here (http://puu.sh/pxrIB/31673e9c9c.cfg) is an exemple.
4. Type the command sm_reload_tdr or type in console sm_reload_tdr and you are done !

LeetDonkey
06-19-2016, 06:18
I get theese each time a player joins:

L 06/19/2016 - 12:11:35: [SM] Call stack trace:
L 06/19/2016 - 12:11:35: [SM] [0] SDKHook
L 06/19/2016 - 12:11:35: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: Error log file session closed.
L 06/19/2016 - 12:13:41: SourceMod error session started
L 06/19/2016 - 12:13:41: Info (map "de_cbble") (file "errors_20160619.log")
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 6 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 11 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 8 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 12 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 5 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 9 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:13:41: [SM] Exception reported: Entity 4 is invalid
L 06/19/2016 - 12:13:41: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:13:41: [SM] Call stack trace:
L 06/19/2016 - 12:13:41: [SM] [0] SDKHook
L 06/19/2016 - 12:13:41: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:14:34: [SM] Exception reported: Entity 2 is invalid
L 06/19/2016 - 12:14:34: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:14:34: [SM] Call stack trace:
L 06/19/2016 - 12:14:34: [SM] [0] SDKHook
L 06/19/2016 - 12:14:34: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()
L 06/19/2016 - 12:14:51: [SM] Exception reported: Entity 3 is invalid
L 06/19/2016 - 12:14:51: [SM] Blaming: teamdamage2.smx()
L 06/19/2016 - 12:14:51: [SM] Call stack trace:
L 06/19/2016 - 12:14:51: [SM] [0] SDKHook
L 06/19/2016 - 12:14:51: [SM] [1] Line 75, teamdamage2.sp::OnClientConnected()

The nametags work fine, but it doesn't print the damage to admins anymore :-S
I'm guessing it has something to do with the errors in the log?

Arkarr
06-19-2016, 07:14
No more error, you can redownload it using the previous link (https://forums.alliedmods.net/showpost.php?p=2428619&postcount=14).