Skip to content

Commit

Permalink
Add TTT_OnPlayerDeath
Browse files Browse the repository at this point in the history
Close #302
  • Loading branch information
Bara committed Apr 14, 2018
1 parent b9aab05 commit d88b3f6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
10 changes: 9 additions & 1 deletion addons/sourcemod/scripting/include/ttt.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ forward void TTT_OnRoundEnd(int winner);
forward void TTT_OnClientGetRole(int client, int role);

/*
* Called when a client dies.
* Called when a client dies, after RDM process
*
* @param victim Person who died.
* @param attacker Attacker.
Expand Down Expand Up @@ -115,6 +115,14 @@ forward void TTT_OnModelUpdate(int client, const char[] model);
forward int TTT_OnButtonPress(int client, int button);
forward int TTT_OnButtonRelease(int client, int button);

/*
* Called before RDM will be handled.
*
* @param victim Person who died.
* @param attacker Attacker.
*/
forward Action TTT_OnPlayerDeath(int victim, int attacker);

/*
* Checks if the round is active.
*/
Expand Down
6 changes: 6 additions & 0 deletions addons/sourcemod/scripting/tests/ttt_api_test.sp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public void TTT_OnBodyScanned(int client, int victim, const char[] deadPlayer)
PrintToServer("(TTT_OnBodyScanned) client: %d - victim: %d - deadPlayer: %s", client, victim, deadPlayer);
}

public Action TTT_OnPlayerDeath(int victim, int attacker)
{
PrintToServer("TTT_OnPlayerDeath was called!");
PrintToServer("(TTT_OnPlayerDeath) victim: %d - attacker: %d", victim, attacker);
}

public void TTT_OnSQLConnect(Database db)
{
PrintToServer("TTT_OnSQLConnect was called!");
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/ttt/core/globals.sp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Handle g_hOnBodyChecked = null;
Handle g_hOnButtonPress = null;
Handle g_hOnButtonRelease = null;
Handle g_hOnModelUpdate = null;
Handle g_hOnPlayerDeath = null;

bool g_bSourcebans = false;

Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/ttt/core/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void InitForwards()
g_hOnButtonPress = CreateGlobalForward("TTT_OnButtonPress", ET_Ignore, Param_Cell, Param_Cell);
g_hOnButtonRelease = CreateGlobalForward("TTT_OnButtonRelease", ET_Ignore, Param_Cell, Param_Cell);
g_hOnModelUpdate = CreateGlobalForward("TTT_OnModelUpdate", ET_Ignore, Param_Cell, Param_String);
g_hOnPlayerDeath = CreateGlobalForward("TTT_OnPlayerDeath", ET_Event, Param_Cell, Param_Cell);
}

void InitNatives()
Expand Down
14 changes: 13 additions & 1 deletion addons/sourcemod/scripting/ttt/ttt.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,19 @@ public Action Event_PlayerDeathPre(Event event, const char[] menu, bool dontBroa

SetEntPropEnt(client, Prop_Send, "m_hRagdoll", iEntity);

Action res = Plugin_Continue;

Call_StartForward(g_hOnPlayerDeath);
Call_PushCell(client);
Call_PushCell(iAttacker);
Call_Finish(res);

if (res == Plugin_Stop || res == Plugin_Changed)
{
event.BroadcastDisabled = true;
return Plugin_Changed;
}

if (client != iAttacker && iAttacker != 0 && !g_bImmuneRDMManager[iAttacker] && !g_bHoldingProp[client] && !g_bHoldingSilencedWep[client])
{
if (g_iRole[iAttacker] == TTT_TEAM_TRAITOR && g_iRole[client] == TTT_TEAM_TRAITOR)
Expand Down Expand Up @@ -2400,7 +2413,6 @@ public Action Event_ChangeName(Event event, const char[] name, bool dontBroadcas

int iRagdollC[Ragdolls];

//TODO Make this based on the userid to prevent abuse
for (int i = 0; i < g_aRagdoll.Length; i++)
{
g_aRagdoll.GetArray(i, iRagdollC[0]);
Expand Down

0 comments on commit d88b3f6

Please sign in to comment.