I am writing a pluginfor CSGO that when a player dies if they have a weapon_healthshot a center text message will print.
This works but I only want to see this message if I was the person that killed them and made them drop the healthshot.
Edit:
After a LOT of messing around, Got it working!
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
new droppedShot[MAXPLAYERS];
public OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
for (int i = 1; i <= MaxClients; i++)
droppedShot[i] = 0;
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponDropPost, Hook_WeaponDropPost);
}
public Hook_WeaponDropPost(client, weapon)
{
if(weapon >= 0)
{
new String:weaponName[128];
GetEdictClassname(weapon, weaponName, sizeof(weaponName));
if (strcmp(weaponName, "weapon_healthshot") == 0)
if (0 < client <= MaxClients)
droppedShot[client] = 1;
}
}
public Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int attacked = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));
if (droppedShot[attacked] == 1 && ((0 < attacked <= MaxClients) && (0 < attacker <= MaxClients)))
{
droppedShot[attacked] = 0;
PrintToServer("Event_PlayerDeath - %d-%N - Dropped Shot! - <><><><><><><><>", attacked, attacked);
PrintCenterText(attacker,"<><><><><><><><><> - %N - Dropped SHOT! - <><><><><><><><><>", attacked);
}
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (0 < client <= MaxClients)
droppedShot[client] = 0;
}