fuck you botox xD
This commit is contained in:
parent
f961e7ff0e
commit
1667fc28bb
@ -11,26 +11,34 @@
|
||||
#define SPECMODE_THIRDPERSON 5
|
||||
#define SPECMODE_FREELOOK 6
|
||||
|
||||
/* BOOLS */
|
||||
bool g_bHideCrown[MAXPLAYERS+1];
|
||||
bool g_bHideDialog[MAXPLAYERS+1];
|
||||
bool g_bProtection[MAXPLAYERS+1];
|
||||
|
||||
/* COOKIES */
|
||||
Handle g_hCookie_HideCrown;
|
||||
Handle g_hCookie_HideDialog;
|
||||
Handle g_hCookie_Protection;
|
||||
|
||||
/* CONVARS */
|
||||
ConVar g_hCVar_Protection;
|
||||
ConVar g_hCVar_ProtectionMinimal1;
|
||||
ConVar g_hCVar_ProtectionMinimal2;
|
||||
ConVar g_hCVar_ProtectionMinimal3;
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iCrownEntity = -1;
|
||||
int g_iDialogLevel = 100000;
|
||||
|
||||
int g_iPlayerWinner[3];
|
||||
int g_iPlayerDamage[MAXPLAYERS+1];
|
||||
int g_iPlayerDamageFrom1K[MAXPLAYERS+1];
|
||||
int g_iPlayerDamageHits[MAXPLAYERS+1];
|
||||
int g_iPlayerDamageFrom1K[MAXPLAYERS + 1];
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Top Defenders",
|
||||
@ -39,6 +47,18 @@ public Plugin myinfo =
|
||||
version = "1.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
CreateNative("TopDefenders_GetClientDamage", Native_GetClientDamage);
|
||||
CreateNative("TopDefenders_GetClientHits", Native_GetClientHits);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("plugin.topdefenders.phrases");
|
||||
@ -68,24 +88,36 @@ public void OnPluginStart()
|
||||
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Top Defenders");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleCrown(int client, int args)
|
||||
{
|
||||
ToggleCrown(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleDialog(int client, int args)
|
||||
{
|
||||
ToggleDialog(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleImmunity(int client, int args)
|
||||
{
|
||||
ToggleImmunity(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleCrown(int client)
|
||||
{
|
||||
g_bHideCrown[client] = !g_bHideCrown[client];
|
||||
@ -95,6 +127,9 @@ public void ToggleCrown(int client)
|
||||
CPrintToChat(client, "{cyan}%t {white}%t", "Chat Prefix", g_bHideCrown[client] ? "Crown Disabled" : "Crown Enabled");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleDialog(int client)
|
||||
{
|
||||
g_bHideDialog[client] = !g_bHideDialog[client];
|
||||
@ -104,6 +139,9 @@ public void ToggleDialog(int client)
|
||||
CPrintToChat(client, "{cyan}%t {white}%t", "Chat Prefix", g_bHideDialog[client] ? "Dialog Disabled" : "Dialog Enabled");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleImmunity(int client)
|
||||
{
|
||||
g_bProtection[client] = !g_bProtection[client];
|
||||
@ -113,6 +151,9 @@ public void ToggleImmunity(int client)
|
||||
CPrintToChat(client, "{cyan}%t {white}%t", "Chat Prefix", g_bProtection[client] ? "Immunity Disabled" : "Immunity Enabled");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ShowSettingsMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_MainMenu);
|
||||
@ -128,6 +169,9 @@ public void ShowSettingsMenu(int client)
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
|
||||
{
|
||||
switch(action)
|
||||
@ -143,6 +187,9 @@ public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
||||
{
|
||||
switch(action)
|
||||
@ -169,6 +216,9 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapStart()
|
||||
{
|
||||
PrecacheSound("unloze/holy.wav");
|
||||
@ -190,6 +240,9 @@ public void OnMapStart()
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientCookiesCached(int client)
|
||||
{
|
||||
char sBuffer[4];
|
||||
@ -215,15 +268,23 @@ public void OnClientCookiesCached(int client)
|
||||
g_bProtection[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_iPlayerDamage[client] = 0;
|
||||
g_iPlayerDamageHits[client] = 0;
|
||||
g_iPlayerDamageFrom1K[client] = 0;
|
||||
|
||||
g_bHideCrown[client] = false;
|
||||
g_bHideDialog[client] = false;
|
||||
g_bProtection[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int SortDefendersList(int[] elem1, int[] elem2, const int[][] array, Handle hndl)
|
||||
{
|
||||
if (elem1[1] > elem2[1]) return -1;
|
||||
@ -232,6 +293,9 @@ public int SortDefendersList(int[] elem1, int[] elem2, const int[][] array, Hand
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action UpdateScoreboard(Handle timer)
|
||||
{
|
||||
int iSortedList[MAXPLAYERS+1][2];
|
||||
@ -260,6 +324,9 @@ public Action UpdateScoreboard(Handle timer)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action UpdateDialog(Handle timer)
|
||||
{
|
||||
if (g_iDialogLevel <= 0)
|
||||
@ -293,6 +360,9 @@ public Action UpdateDialog(Handle timer)
|
||||
g_iDialogLevel--;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
g_iDialogLevel = 100000;
|
||||
@ -300,15 +370,19 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
g_iPlayerDamage[client] = 0;
|
||||
g_iPlayerDamageHits[client] = 0;
|
||||
g_iPlayerDamageFrom1K[client] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
g_iPlayerWinner = {-1, -1, -1};
|
||||
|
||||
int iSortedList[MAXPLAYERS+1][2];
|
||||
int iSortedList[MAXPLAYERS+1][3];
|
||||
int iSortedCount;
|
||||
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
@ -318,6 +392,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
iSortedList[iSortedCount][0] = client;
|
||||
iSortedList[iSortedCount][1] = g_iPlayerDamage[client];
|
||||
iSortedList[iSortedCount][2] = g_iPlayerDamageHits[client];
|
||||
iSortedCount++;
|
||||
}
|
||||
|
||||
@ -325,7 +400,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
for (int rank = 0; rank < iSortedCount; rank++)
|
||||
{
|
||||
LogMessage("%d - %L (%d)", rank + 1, iSortedList[rank][0], iSortedList[rank][1])
|
||||
LogMessage("%d. %L - %d damage in %d hits", rank + 1, iSortedList[rank][0], iSortedList[rank][1], iSortedList[rank][2])
|
||||
}
|
||||
|
||||
if (iSortedCount)
|
||||
@ -336,7 +411,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
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 damage in %d hits", sBuffer, iSortedList[0][0], iSortedList[0][1], iSortedList[0][2]);
|
||||
LogPlayerEvent(iSortedList[0][0], "triggered", "top_defender");
|
||||
|
||||
g_iPlayerWinner[0] = GetSteamAccountID(iSortedList[0][0]);
|
||||
@ -344,7 +419,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
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 damage in %d hits", sBuffer, iSortedList[1][0], iSortedList[1][1], iSortedList[1][2]);
|
||||
LogPlayerEvent(iSortedList[1][0], "triggered", "second_defender");
|
||||
|
||||
g_iPlayerWinner[1] = GetSteamAccountID(iSortedList[1][0]);
|
||||
@ -352,7 +427,7 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
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 damage in %d hits", sBuffer, iSortedList[2][0], iSortedList[2][1], iSortedList[2][2]);
|
||||
LogPlayerEvent(iSortedList[2][0], "triggered", "third_defender");
|
||||
|
||||
g_iPlayerWinner[2] = GetSteamAccountID(iSortedList[2][0]);
|
||||
@ -400,10 +475,27 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
}
|
||||
}
|
||||
|
||||
PrintToChatAll(sBuffer);
|
||||
if(GetEngineVersion() == Engine_CSGO)
|
||||
{
|
||||
int iSplits
|
||||
char sSplits[16][512];
|
||||
|
||||
if((iSplits = ExplodeString(sBuffer, "\n", sSplits, sizeof(sSplits), sizeof(sSplits[]))) != 0)
|
||||
{
|
||||
for (int iSplit; iSplit < iSplits; iSplit++)
|
||||
{
|
||||
PrintToChatAll(sSplits[iSplit]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
PrintToChatAll(sBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
@ -418,6 +510,7 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
int iDamage = hEvent.GetInt("dmg_health");
|
||||
|
||||
g_iPlayerDamage[client] += iDamage;
|
||||
g_iPlayerDamageHits[client] += 1;
|
||||
g_iPlayerDamageFrom1K[client] += iDamage;
|
||||
|
||||
if (g_iPlayerDamageFrom1K[client] >= 1000)
|
||||
@ -427,6 +520,9 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
@ -437,6 +533,9 @@ public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnClientSpawnPost(Handle timer, int client)
|
||||
{
|
||||
if (!IsClientInGame(client) || IsFakeClient(client) || !IsPlayerAlive(client))
|
||||
@ -476,6 +575,9 @@ public Action OnClientSpawnPost(Handle timer, int client)
|
||||
AcceptEntityInput(g_iCrownEntity, "SetParent", client);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
@ -489,6 +591,9 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:respawnOverride, &bool:respawn)
|
||||
{
|
||||
if (g_hCVar_Protection.BoolValue && motherInfect && !g_bProtection[client])
|
||||
@ -546,6 +651,47 @@ public Action ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:re
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_GetClientDamage(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_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_iPlayerDamageHits[client];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void AddMenuItemTranslated(Menu menu, const char[] info, const char[] display, any ...)
|
||||
{
|
||||
char buffer[128];
|
||||
@ -554,6 +700,9 @@ void AddMenuItemTranslated(Menu menu, const char[] info, const char[] display, a
|
||||
menu.AddItem(info, buffer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SendDialog(int client, const char[] display, const int level, const int time, any ...)
|
||||
{
|
||||
char buffer[128];
|
||||
@ -586,12 +735,18 @@ void SendDialog(int client, const char[] display, const int level, const int tim
|
||||
delete kv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
int GetClientSpectatorMode(int client)
|
||||
{
|
||||
return GetEntProp(client, Prop_Send, "m_iObserverMode");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
int GetClientSpectatorTarget(int client)
|
||||
{
|
||||
return GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
|
||||
}
|
||||
}
|
@ -8,8 +8,9 @@
|
||||
*
|
||||
* @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 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
|
||||
@ -17,4 +18,12 @@ forward void TopDefenders_OnRoundEnd(int iPlayers[MAXPLAYERS+1], int iDamage[MAX
|
||||
* @param client Client index.
|
||||
* @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