TopDefenders: JUDGE ME I DARE YA.
This commit is contained in:
parent
db13adc4aa
commit
e197cc83e0
@ -35,6 +35,7 @@ int g_iCrownEntity = -1;
|
|||||||
int g_iDialogLevel = 100000;
|
int g_iDialogLevel = 100000;
|
||||||
|
|
||||||
int g_iPlayerWinner[3];
|
int g_iPlayerWinner[3];
|
||||||
|
int g_iPlayerHits[MAXPLAYERS+1];
|
||||||
int g_iPlayerDamage[MAXPLAYERS+1];
|
int g_iPlayerDamage[MAXPLAYERS+1];
|
||||||
int g_iPlayerDamageFrom1K[MAXPLAYERS + 1];
|
int g_iPlayerDamageFrom1K[MAXPLAYERS + 1];
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ public Plugin myinfo =
|
|||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
{
|
{
|
||||||
CreateNative("TopDefenders_GetClientDamage", Native_GetClientDamage);
|
CreateNative("TopDefenders_GetClientDamage", Native_GetClientDamage);
|
||||||
|
CreateNative("TopDefenders_GetClientHits", Native_GetClientHits);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -276,6 +278,7 @@ public void OnClientCookiesCached(int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
|
g_iPlayerHits[client] = 0;
|
||||||
g_iPlayerDamage[client] = 0;
|
g_iPlayerDamage[client] = 0;
|
||||||
|
|
||||||
g_bHideCrown[client] = false;
|
g_bHideCrown[client] = false;
|
||||||
@ -370,6 +373,7 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
|||||||
|
|
||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
|
g_iPlayerHits[client] = 0;
|
||||||
g_iPlayerDamage[client] = 0;
|
g_iPlayerDamage[client] = 0;
|
||||||
g_iPlayerDamageFrom1K[client] = 0;
|
g_iPlayerDamageFrom1K[client] = 0;
|
||||||
}
|
}
|
||||||
@ -382,7 +386,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
{
|
{
|
||||||
g_iPlayerWinner = {-1, -1, -1};
|
g_iPlayerWinner = {-1, -1, -1};
|
||||||
|
|
||||||
int iSortedList[MAXPLAYERS+1][2];
|
int iSortedList[MAXPLAYERS+1][3];
|
||||||
int iSortedCount;
|
int iSortedCount;
|
||||||
|
|
||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
@ -392,6 +396,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
|
|
||||||
iSortedList[iSortedCount][0] = client;
|
iSortedList[iSortedCount][0] = client;
|
||||||
iSortedList[iSortedCount][1] = g_iPlayerDamage[client];
|
iSortedList[iSortedCount][1] = g_iPlayerDamage[client];
|
||||||
|
iSortedList[iSortedCount][2] = g_iPlayerHits[client];
|
||||||
iSortedCount++;
|
iSortedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,11 +411,13 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
{
|
{
|
||||||
int iPlayers[MAXPLAYERS+1];
|
int iPlayers[MAXPLAYERS+1];
|
||||||
int iDamage[MAXPLAYERS+1];
|
int iDamage[MAXPLAYERS+1];
|
||||||
|
int iHits[MAXPLAYERS+1];
|
||||||
|
|
||||||
for (int rank = 0; rank < iSortedCount; rank++)
|
for (int rank = 0; rank < iSortedCount; rank++)
|
||||||
{
|
{
|
||||||
iPlayers[rank] = iSortedList[rank][0];
|
iPlayers[rank] = iSortedList[rank][0];
|
||||||
iDamage[rank] = iSortedList[rank][1];
|
iDamage[rank] = iSortedList[rank][1];
|
||||||
|
iHits[rank] = iSortedList[rank][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
char sBuffer[512];
|
char sBuffer[512];
|
||||||
@ -419,7 +426,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
|
|
||||||
if (iSortedList[0][0])
|
if (iSortedList[0][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d DMG", sBuffer, iSortedList[0][0], iSortedList[0][1]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d DMG in %d hits", sBuffer, iSortedList[0][0], iSortedList[0][1], iSortedList[0][2]);
|
||||||
LogPlayerEvent(iSortedList[0][0], "triggered", "top_defender");
|
LogPlayerEvent(iSortedList[0][0], "triggered", "top_defender");
|
||||||
|
|
||||||
g_iPlayerWinner[0] = GetSteamAccountID(iSortedList[0][0]);
|
g_iPlayerWinner[0] = GetSteamAccountID(iSortedList[0][0]);
|
||||||
@ -427,7 +434,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
|
|
||||||
if (iSortedList[1][0])
|
if (iSortedList[1][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d DMG", sBuffer, iSortedList[1][0], iSortedList[1][1]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d DMG in %d hits", sBuffer, iSortedList[1][0], iSortedList[1][1], iSortedList[0][2]);
|
||||||
LogPlayerEvent(iSortedList[1][0], "triggered", "second_defender");
|
LogPlayerEvent(iSortedList[1][0], "triggered", "second_defender");
|
||||||
|
|
||||||
g_iPlayerWinner[1] = GetSteamAccountID(iSortedList[1][0]);
|
g_iPlayerWinner[1] = GetSteamAccountID(iSortedList[1][0]);
|
||||||
@ -435,7 +442,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
|
|
||||||
if (iSortedList[2][0])
|
if (iSortedList[2][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d DMG", sBuffer, iSortedList[2][0], iSortedList[2][1]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d DMG in %d hits", sBuffer, iSortedList[2][0], iSortedList[2][1], iSortedList[0][2]);
|
||||||
LogPlayerEvent(iSortedList[2][0], "triggered", "third_defender");
|
LogPlayerEvent(iSortedList[2][0], "triggered", "third_defender");
|
||||||
|
|
||||||
g_iPlayerWinner[2] = GetSteamAccountID(iSortedList[2][0]);
|
g_iPlayerWinner[2] = GetSteamAccountID(iSortedList[2][0]);
|
||||||
@ -499,7 +506,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
else
|
else
|
||||||
PrintToChatAll(sBuffer);
|
PrintToChatAll(sBuffer);
|
||||||
|
|
||||||
TopDefenders_OnRoundEnd(iPlayers, iDamage);
|
TopDefenders_OnRoundEnd(iPlayers, iDamage, iHits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,6 +526,7 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
|||||||
|
|
||||||
int iDamage = hEvent.GetInt("dmg_health");
|
int iDamage = hEvent.GetInt("dmg_health");
|
||||||
|
|
||||||
|
g_iPlayerHits[client] += 1;
|
||||||
g_iPlayerDamage[client] += iDamage;
|
g_iPlayerDamage[client] += iDamage;
|
||||||
g_iPlayerDamageFrom1K[client] += iDamage;
|
g_iPlayerDamageFrom1K[client] += iDamage;
|
||||||
|
|
||||||
@ -663,11 +671,12 @@ public Action ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:re
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAXPLAYERS+1])
|
bool TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAXPLAYERS+1], int iHits[MAXPLAYERS+1])
|
||||||
{
|
{
|
||||||
Call_StartForward(g_hForward_OnRoundEndingWithTopDefenders);
|
Call_StartForward(g_hForward_OnRoundEndingWithTopDefenders);
|
||||||
Call_PushArray(iPlayers, sizeof(iPlayers));
|
Call_PushArray(iPlayers, sizeof(iPlayers));
|
||||||
Call_PushArray(iDamage, sizeof(iDamage));
|
Call_PushArray(iDamage, sizeof(iDamage));
|
||||||
|
Call_PushArray(iHits, sizeof(iHits));
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,6 +699,25 @@ public int Native_GetClientDamage(Handle hPlugin, int numParams)
|
|||||||
return g_iPlayerDamage[client];
|
return g_iPlayerDamage[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public int Native_GetClientHits(Handle hPlugin, int numParams)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
if (client < 1 || client > MaxClients)
|
||||||
|
{
|
||||||
|
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsClientInGame(client))
|
||||||
|
{
|
||||||
|
return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_iPlayerHits[client];
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
*
|
*
|
||||||
* @param iPlayers The sorted array of the Defenders' Client IDs. (iPlayers[0] is the TopDefender)
|
* @param iPlayers The sorted array of the Defenders' Client IDs. (iPlayers[0] is the TopDefender)
|
||||||
* @param iDamage The sorted array of the Defenders' Damages. (iDamage[0] is the TopDefender's Damage)
|
* @param iDamage The sorted array of the Defenders' Damages. (iDamage[0] is the TopDefender's Damage)
|
||||||
|
* @param iHits The sorted array of the Defenders' Hits. (iHits[0] is the TopDefender's Hits)
|
||||||
*/
|
*/
|
||||||
forward void TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAXPLAYERS+1]);
|
forward void TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAXPLAYERS+1], int iHits[MAXPLAYERS+1]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current damage of a client
|
* Returns the current damage of a client
|
||||||
@ -17,4 +18,12 @@ forward void TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAX
|
|||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @return The current damage of the client.
|
* @return The current damage of the client.
|
||||||
*/
|
*/
|
||||||
native int TopDefenders_GetClientDamage(int client);
|
native int TopDefenders_GetClientDamage(int client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current hits of a client
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return The current hits of the client.
|
||||||
|
*/
|
||||||
|
native int TopDefenders_GetClientHits(int client);
|
Loading…
Reference in New Issue
Block a user