Merge branch 'master' of https://git.unloze.com/UNLOZE/sm-plugins-unloze
This commit is contained in:
commit
16f160decc
@ -11,6 +11,7 @@
|
|||||||
#define SPECMODE_FREELOOK 6
|
#define SPECMODE_FREELOOK 6
|
||||||
|
|
||||||
/* BOOLS */
|
/* BOOLS */
|
||||||
|
bool g_bEngineCSGO;
|
||||||
bool g_bHideCrown[MAXPLAYERS+1];
|
bool g_bHideCrown[MAXPLAYERS+1];
|
||||||
bool g_bHideDialog[MAXPLAYERS+1];
|
bool g_bHideDialog[MAXPLAYERS+1];
|
||||||
bool g_bProtection[MAXPLAYERS+1];
|
bool g_bProtection[MAXPLAYERS+1];
|
||||||
@ -34,15 +35,16 @@ int g_iPlayerWinner[3];
|
|||||||
int g_iPlayerDamage[MAXPLAYERS+1];
|
int g_iPlayerDamage[MAXPLAYERS+1];
|
||||||
int g_iPlayerDamageHits[MAXPLAYERS+1];
|
int g_iPlayerDamageHits[MAXPLAYERS+1];
|
||||||
int g_iPlayerDamageFrom1K[MAXPLAYERS + 1];
|
int g_iPlayerDamageFrom1K[MAXPLAYERS + 1];
|
||||||
|
int g_iPlayerInfections[MAXPLAYERS+1];
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "Top Defenders",
|
name = "Player Rankings",
|
||||||
author = "Neon & zaCade",
|
author = "Neon & zaCade",
|
||||||
description = "Show Top Defenders after each round",
|
description = "Show Top Defenders & Infections after each round",
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,8 +53,10 @@ 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("PlayerRankings_GetClientDamage", Native_GetClientDamage);
|
||||||
CreateNative("TopDefenders_GetClientHits", Native_GetClientHits);
|
CreateNative("PlayerRankings_GetClientHits", Native_GetClientHits);
|
||||||
|
|
||||||
|
CreateNative("PlayerRankings_GetClientInfections", Native_GetClientInfections);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -62,6 +66,8 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
LoadTranslations("plugin.topdefenders.phrases");
|
LoadTranslations("plugin.topdefenders.phrases");
|
||||||
|
|
||||||
|
g_bEngineCSGO = view_as<bool>(GetEngineVersion() == Engine_CSGO);
|
||||||
|
|
||||||
g_hCVar_Protection = CreateConVar("sm_topdefenders_protection", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
|
g_hCVar_Protection = CreateConVar("sm_topdefenders_protection", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
g_hCVar_ProtectionMinimal1 = CreateConVar("sm_topdefenders_minimal_1", "15", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
g_hCVar_ProtectionMinimal1 = CreateConVar("sm_topdefenders_minimal_1", "15", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
||||||
g_hCVar_ProtectionMinimal2 = CreateConVar("sm_topdefenders_minimal_2", "30", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
g_hCVar_ProtectionMinimal2 = CreateConVar("sm_topdefenders_minimal_2", "30", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
||||||
@ -84,7 +90,7 @@ public void OnPluginStart()
|
|||||||
HookEvent("player_spawn", OnClientSpawn);
|
HookEvent("player_spawn", OnClientSpawn);
|
||||||
HookEvent("player_death", OnClientDeath);
|
HookEvent("player_death", OnClientDeath);
|
||||||
|
|
||||||
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Top Defenders");
|
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Player Rankings");
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -273,6 +279,7 @@ public void OnClientDisconnect(int client)
|
|||||||
g_iPlayerDamage[client] = 0;
|
g_iPlayerDamage[client] = 0;
|
||||||
g_iPlayerDamageHits[client] = 0;
|
g_iPlayerDamageHits[client] = 0;
|
||||||
g_iPlayerDamageFrom1K[client] = 0;
|
g_iPlayerDamageFrom1K[client] = 0;
|
||||||
|
g_iPlayerInfections[client] = 0;
|
||||||
|
|
||||||
g_bHideCrown[client] = false;
|
g_bHideCrown[client] = false;
|
||||||
g_bHideDialog[client] = false;
|
g_bHideDialog[client] = false;
|
||||||
@ -282,7 +289,7 @@ public void OnClientDisconnect(int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int SortDefendersList(int[] elem1, int[] elem2, const int[][] array, Handle hndl)
|
public int SortRankingsList(int[] elem1, int[] elem2, const int[][] array, Handle hndl)
|
||||||
{
|
{
|
||||||
if (elem1[1] > elem2[1]) return -1;
|
if (elem1[1] > elem2[1]) return -1;
|
||||||
if (elem1[1] < elem2[1]) return 1;
|
if (elem1[1] < elem2[1]) return 1;
|
||||||
@ -313,7 +320,7 @@ public Action UpdateScoreboard(Handle timer)
|
|||||||
iSortedCount++;
|
iSortedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
SortCustom2D(iSortedList, iSortedCount, SortDefendersList);
|
SortCustom2D(iSortedList, iSortedCount, SortRankingsList);
|
||||||
|
|
||||||
for (int rank = 0; rank < iSortedCount; rank++)
|
for (int rank = 0; rank < iSortedCount; rank++)
|
||||||
{
|
{
|
||||||
@ -326,7 +333,7 @@ public Action UpdateScoreboard(Handle timer)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action UpdateDialog(Handle timer)
|
public Action UpdateDialog(Handle timer)
|
||||||
{
|
{
|
||||||
if (g_iDialogLevel <= 0)
|
if (g_bEngineCSGO || g_iDialogLevel <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int iSortedList[MAXPLAYERS+1][2];
|
int iSortedList[MAXPLAYERS+1][2];
|
||||||
@ -342,7 +349,7 @@ public Action UpdateDialog(Handle timer)
|
|||||||
iSortedCount++;
|
iSortedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
SortCustom2D(iSortedList, iSortedCount, SortDefendersList);
|
SortCustom2D(iSortedList, iSortedCount, SortRankingsList);
|
||||||
|
|
||||||
for (int rank = 0; rank < iSortedCount; rank++)
|
for (int rank = 0; rank < iSortedCount; rank++)
|
||||||
{
|
{
|
||||||
@ -369,6 +376,7 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
|||||||
g_iPlayerDamage[client] = 0;
|
g_iPlayerDamage[client] = 0;
|
||||||
g_iPlayerDamageHits[client] = 0;
|
g_iPlayerDamageHits[client] = 0;
|
||||||
g_iPlayerDamageFrom1K[client] = 0;
|
g_iPlayerDamageFrom1K[client] = 0;
|
||||||
|
g_iPlayerInfections[client] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,117 +387,146 @@ public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
|||||||
{
|
{
|
||||||
g_iPlayerWinner = {-1, -1, -1};
|
g_iPlayerWinner = {-1, -1, -1};
|
||||||
|
|
||||||
int iSortedList[MAXPLAYERS+1][3];
|
int iSortedListDefenders[MAXPLAYERS+1][3];
|
||||||
int iSortedCount;
|
int iSortedCountDefenders;
|
||||||
|
|
||||||
|
int iSortedListInfectors[MAXPLAYERS+1][2];
|
||||||
|
int iSortedCountInfectors;
|
||||||
|
|
||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if (!IsClientInGame(client) || !g_iPlayerDamage[client])
|
if (!IsClientInGame(client))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
iSortedList[iSortedCount][0] = client;
|
if (g_iPlayerDamage[client])
|
||||||
iSortedList[iSortedCount][1] = g_iPlayerDamage[client];
|
{
|
||||||
iSortedList[iSortedCount][2] = g_iPlayerDamageHits[client];
|
iSortedListDefenders[iSortedCountDefenders][0] = client;
|
||||||
iSortedCount++;
|
iSortedListDefenders[iSortedCountDefenders][1] = g_iPlayerDamage[client];
|
||||||
|
iSortedListDefenders[iSortedCountDefenders][2] = g_iPlayerDamageHits[client];
|
||||||
|
iSortedCountDefenders++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_iPlayerInfections[client])
|
||||||
|
{
|
||||||
|
iSortedListInfectors[iSortedCountInfectors][0] = client;
|
||||||
|
iSortedListInfectors[iSortedCountInfectors][1] = g_iPlayerInfections[client];
|
||||||
|
iSortedCountInfectors++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SortCustom2D(iSortedList, iSortedCount, SortDefendersList);
|
SortCustom2D(iSortedListDefenders, iSortedCountDefenders, SortRankingsList);
|
||||||
|
SortCustom2D(iSortedListInfectors, iSortedCountInfectors, SortRankingsList);
|
||||||
|
|
||||||
for (int rank = 0; rank < iSortedCount; rank++)
|
for (int rank = 0; rank < iSortedCountDefenders; rank++)
|
||||||
{
|
{
|
||||||
LogMessage("%d. %L - %d damage in %d hits", rank + 1, iSortedList[rank][0], iSortedList[rank][1], iSortedList[rank][2])
|
LogMessage("%d. %L - %d damage in %d hits", rank + 1, iSortedListDefenders[rank][0], iSortedListDefenders[rank][1], iSortedListDefenders[rank][2])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iSortedCount)
|
for (int rank = 0; rank < iSortedCountInfectors; rank++)
|
||||||
|
{
|
||||||
|
LogMessage("%d. %L - %d infections", rank + 1, iSortedListInfectors[rank][0], iSortedListInfectors[rank][1])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iSortedCountDefenders)
|
||||||
{
|
{
|
||||||
char sBuffer[512];
|
char sBuffer[512];
|
||||||
Format(sBuffer, sizeof(sBuffer), "TOP DEFENDERS:");
|
Format(sBuffer, sizeof(sBuffer), "TOP DEFENDERS:");
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n*************************", sBuffer);
|
|
||||||
|
|
||||||
if (iSortedList[0][0])
|
if (iSortedListDefenders[0][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d damage in %d hits", sBuffer, iSortedList[0][0], iSortedList[0][1], iSortedList[0][2]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d damage in %d hits", sBuffer, iSortedListDefenders[0][0], iSortedListDefenders[0][1], iSortedListDefenders[0][2]);
|
||||||
|
|
||||||
g_iPlayerWinner[0] = GetSteamAccountID(iSortedList[0][0]);
|
g_iPlayerWinner[0] = GetSteamAccountID(iSortedListDefenders[0][0]);
|
||||||
|
|
||||||
LH_LogPlayerEvent(iSortedList[0][0], "triggered", "ze_defender_first", true);
|
LH_LogPlayerEvent(iSortedListDefenders[0][0], "triggered", "ze_defender_first", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iSortedList[1][0])
|
if (iSortedListDefenders[1][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d damage in %d hits", sBuffer, iSortedList[1][0], iSortedList[1][1], iSortedList[1][2]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d damage in %d hits", sBuffer, iSortedListDefenders[1][0], iSortedListDefenders[1][1], iSortedListDefenders[1][2]);
|
||||||
|
|
||||||
g_iPlayerWinner[1] = GetSteamAccountID(iSortedList[1][0]);
|
g_iPlayerWinner[1] = GetSteamAccountID(iSortedListDefenders[1][0]);
|
||||||
|
|
||||||
LH_LogPlayerEvent(iSortedList[1][0], "triggered", "ze_defender_second", true);
|
LH_LogPlayerEvent(iSortedListDefenders[1][0], "triggered", "ze_defender_second", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iSortedList[2][0])
|
if (iSortedListDefenders[2][0])
|
||||||
{
|
{
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d damage in %d hits", sBuffer, iSortedList[2][0], iSortedList[2][1], iSortedList[2][2]);
|
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d damage in %d hits", sBuffer, iSortedListDefenders[2][0], iSortedListDefenders[2][1], iSortedListDefenders[2][2]);
|
||||||
|
|
||||||
g_iPlayerWinner[2] = GetSteamAccountID(iSortedList[2][0]);
|
g_iPlayerWinner[2] = GetSteamAccountID(iSortedListDefenders[2][0]);
|
||||||
|
|
||||||
LH_LogPlayerEvent(iSortedList[2][0], "triggered", "ze_defender_third", true);
|
LH_LogPlayerEvent(iSortedListDefenders[2][0], "triggered", "ze_defender_third", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Format(sBuffer, sizeof(sBuffer), "%s\n*************************", sBuffer);
|
if (g_bEngineCSGO)
|
||||||
|
|
||||||
Handle hMessage = StartMessageAll("HudMsg");
|
|
||||||
if (hMessage)
|
|
||||||
{
|
|
||||||
if (GetUserMessageType() == UM_Protobuf)
|
|
||||||
{
|
|
||||||
PbSetInt(hMessage, "channel", 50);
|
|
||||||
PbSetInt(hMessage, "effect", 0);
|
|
||||||
PbSetColor(hMessage, "clr1", {255, 255, 255, 255});
|
|
||||||
PbSetColor(hMessage, "clr2", {255, 255, 255, 255});
|
|
||||||
PbSetVector2D(hMessage, "pos", Float:{0.02, 0.45});
|
|
||||||
PbSetFloat(hMessage, "fade_in_time", 0.1);
|
|
||||||
PbSetFloat(hMessage, "fade_out_time", 0.1);
|
|
||||||
PbSetFloat(hMessage, "hold_time", 5.0);
|
|
||||||
PbSetFloat(hMessage, "fx_time", 0.0);
|
|
||||||
PbSetString(hMessage, "text", sBuffer);
|
|
||||||
EndMessage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BfWriteByte(hMessage, 50);
|
|
||||||
BfWriteFloat(hMessage, 0.02);
|
|
||||||
BfWriteFloat(hMessage, 0.25);
|
|
||||||
BfWriteByte(hMessage, 0);
|
|
||||||
BfWriteByte(hMessage, 128);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 255);
|
|
||||||
BfWriteByte(hMessage, 0);
|
|
||||||
BfWriteFloat(hMessage, 0.1);
|
|
||||||
BfWriteFloat(hMessage, 0.1);
|
|
||||||
BfWriteFloat(hMessage, 5.0);
|
|
||||||
BfWriteFloat(hMessage, 0.0);
|
|
||||||
BfWriteString(hMessage, sBuffer);
|
|
||||||
EndMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(GetEngineVersion() == Engine_CSGO)
|
|
||||||
{
|
{
|
||||||
int iSplits
|
int iSplits
|
||||||
char sSplits[16][512];
|
char sSplits[16][512];
|
||||||
|
|
||||||
if((iSplits = ExplodeString(sBuffer, "\n", sSplits, sizeof(sSplits), sizeof(sSplits[]))) != 0)
|
if ((iSplits = ExplodeString(sBuffer, "\n", sSplits, sizeof(sSplits), sizeof(sSplits[]))) != 0)
|
||||||
{
|
{
|
||||||
for (int iSplit; iSplit < iSplits; iSplit++)
|
for (int iSplit; iSplit < iSplits; iSplit++)
|
||||||
{
|
{
|
||||||
PrintToChatAll(sSplits[iSplit]);
|
PrintToChatAll(sSplits[iSplit]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintToMessageHUD(0, 50, Float:{0.02, 0.45}, {0, 128, 255, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, sBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
PrintToMessageHUD(0, 50, Float:{0.02, 0.25}, {0, 128, 255, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, sBuffer);
|
||||||
PrintToChatAll(sBuffer);
|
PrintToChatAll(sBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iSortedCountInfectors)
|
||||||
|
{
|
||||||
|
char sBuffer[512];
|
||||||
|
Format(sBuffer, sizeof(sBuffer), "TOP INFECTORS:");
|
||||||
|
|
||||||
|
if (iSortedListInfectors[0][0])
|
||||||
|
{
|
||||||
|
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d infections", sBuffer, iSortedListInfectors[0][0], iSortedListInfectors[0][1]);
|
||||||
|
|
||||||
|
LH_LogPlayerEvent(iSortedListInfectors[0][0], "triggered", "ze_infector_first", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iSortedListInfectors[1][0])
|
||||||
|
{
|
||||||
|
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d infections", sBuffer, iSortedListInfectors[1][0], iSortedListInfectors[1][1]);
|
||||||
|
|
||||||
|
LH_LogPlayerEvent(iSortedListInfectors[1][0], "triggered", "ze_infector_second", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iSortedListInfectors[2][0])
|
||||||
|
{
|
||||||
|
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d infections", sBuffer, iSortedListInfectors[2][0], iSortedListInfectors[2][1]);
|
||||||
|
|
||||||
|
LH_LogPlayerEvent(iSortedListInfectors[2][0], "triggered", "ze_infector_third", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_bEngineCSGO)
|
||||||
|
{
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintToMessageHUD(0, 55, Float:{0.02, 0.6}, {255, 0, 0, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, sBuffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintToMessageHUD(0, 55, Float:{0.02, 0.4}, {255, 0, 0, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, sBuffer);
|
||||||
|
PrintToChatAll(sBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,55 +657,31 @@ public Action ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:re
|
|||||||
(g_iPlayerWinner[1] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal2.IntValue) ||
|
(g_iPlayerWinner[1] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal2.IntValue) ||
|
||||||
(g_iPlayerWinner[2] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal3.IntValue))
|
(g_iPlayerWinner[2] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal3.IntValue))
|
||||||
{
|
{
|
||||||
Handle hMessageInfection = StartMessageOne("HudMsg", client);
|
PrintToMessageHUD(client, 60, Float:{-1.0, 0.3}, {255, 255, 255, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, "You have been protected from being Mother Zombie\nsince you were the Top Defender last round!");
|
||||||
if (hMessageInfection)
|
|
||||||
{
|
|
||||||
if (GetUserMessageType() == UM_Protobuf)
|
|
||||||
{
|
|
||||||
PbSetInt(hMessageInfection, "channel", 50);
|
|
||||||
PbSetInt(hMessageInfection, "effect", 0);
|
|
||||||
PbSetColor(hMessageInfection, "clr1", {255, 255, 255, 255});
|
|
||||||
PbSetColor(hMessageInfection, "clr2", {255, 255, 255, 255});
|
|
||||||
PbSetVector2D(hMessageInfection, "pos", Float:{-1.0, 0.3});
|
|
||||||
PbSetFloat(hMessageInfection, "fade_in_time", 0.1);
|
|
||||||
PbSetFloat(hMessageInfection, "fade_out_time", 0.1);
|
|
||||||
PbSetFloat(hMessageInfection, "hold_time", 5.0);
|
|
||||||
PbSetFloat(hMessageInfection, "fx_time", 0.0);
|
|
||||||
PbSetString(hMessageInfection, "text", "You have been protected from being Mother Zombie\nsince you were the Top Defender last round!");
|
|
||||||
EndMessage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BfWriteByte(hMessageInfection, 50);
|
|
||||||
BfWriteFloat(hMessageInfection, -1.0);
|
|
||||||
BfWriteFloat(hMessageInfection, 0.3);
|
|
||||||
BfWriteByte(hMessageInfection, 0);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 255);
|
|
||||||
BfWriteByte(hMessageInfection, 0);
|
|
||||||
BfWriteFloat(hMessageInfection, 0.1);
|
|
||||||
BfWriteFloat(hMessageInfection, 0.1);
|
|
||||||
BfWriteFloat(hMessageInfection, 5.0);
|
|
||||||
BfWriteFloat(hMessageInfection, 0.0);
|
|
||||||
BfWriteString(hMessageInfection, "You have been protected from being Mother Zombie\nsince you were the Top Defender last round!");
|
|
||||||
EndMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CPrintToChat(client, "{cyan}%t {white}%s", "Chat Prefix", "You have been protected from being Mother Zombie since you were the Top Defender last round!");
|
CPrintToChat(client, "{cyan}%t {white}%s", "Chat Prefix", "You have been protected from being Mother Zombie since you were the Top Defender last round!");
|
||||||
|
|
||||||
EmitSoundToClient(client, "unloze/holy.wav", .volume=1.0);
|
EmitSoundToClient(client, "unloze/holy.wav", .volume=1.0);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||||
|
{
|
||||||
|
if (client < 1 || client > MaxClients || attacker < 1 || attacker > MaxClients)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (client == attacker || (IsPlayerAlive(attacker) && ZR_IsClientHuman(attacker)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_iPlayerInfections[attacker] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -707,6 +720,25 @@ public int Native_GetClientHits(Handle hPlugin, int numParams)
|
|||||||
return g_iPlayerDamageHits[client];
|
return g_iPlayerDamageHits[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public int Native_GetClientInfections(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_iPlayerInfections[client];
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -721,10 +753,67 @@ void AddMenuItemTranslated(Menu menu, const char[] info, const char[] display, a
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
void SendDialog(int client, const char[] display, const int level, const int time, any ...)
|
void PrintToMessageHUD(int client, int channel, float position[2], int color1[4], int color2[4], int effect, float fadein, float fadeout, float hold, float fx, const char[] text, any ...)
|
||||||
|
{
|
||||||
|
char buffer[512];
|
||||||
|
VFormat(buffer, sizeof(buffer), text, 12);
|
||||||
|
|
||||||
|
Handle hMessage = ((client == 0) ? StartMessageAll("HudMsg") : StartMessageOne("HudMsg", client));
|
||||||
|
if (hMessage)
|
||||||
|
{
|
||||||
|
if (GetUserMessageType() == UM_Protobuf)
|
||||||
|
{
|
||||||
|
PbSetInt(hMessage, "channel", channel);
|
||||||
|
PbSetInt(hMessage, "effect", effect);
|
||||||
|
|
||||||
|
PbSetVector2D(hMessage, "pos", position);
|
||||||
|
|
||||||
|
PbSetColor(hMessage, "clr1", color1);
|
||||||
|
PbSetColor(hMessage, "clr2", color2);
|
||||||
|
|
||||||
|
PbSetFloat(hMessage, "fade_in_time", fadein);
|
||||||
|
PbSetFloat(hMessage, "fade_out_time", fadeout);
|
||||||
|
PbSetFloat(hMessage, "hold_time", hold);
|
||||||
|
PbSetFloat(hMessage, "fx_time", fx);
|
||||||
|
|
||||||
|
PbSetString(hMessage, "text", buffer);
|
||||||
|
EndMessage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BfWriteByte(hMessage, channel);
|
||||||
|
|
||||||
|
BfWriteFloat(hMessage, position[0]);
|
||||||
|
BfWriteFloat(hMessage, position[1]);
|
||||||
|
|
||||||
|
BfWriteByte(hMessage, color1[0]);
|
||||||
|
BfWriteByte(hMessage, color1[1]);
|
||||||
|
BfWriteByte(hMessage, color1[2]);
|
||||||
|
BfWriteByte(hMessage, color1[3]);
|
||||||
|
BfWriteByte(hMessage, color1[0]);
|
||||||
|
BfWriteByte(hMessage, color2[1]);
|
||||||
|
BfWriteByte(hMessage, color2[2]);
|
||||||
|
BfWriteByte(hMessage, color2[3]);
|
||||||
|
BfWriteByte(hMessage, effect);
|
||||||
|
|
||||||
|
BfWriteFloat(hMessage, fadein);
|
||||||
|
BfWriteFloat(hMessage, fadeout);
|
||||||
|
BfWriteFloat(hMessage, hold);
|
||||||
|
BfWriteFloat(hMessage, fx);
|
||||||
|
|
||||||
|
BfWriteString(hMessage, buffer);
|
||||||
|
EndMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
void SendDialog(int client, const char[] text, const int level, const int time, any ...)
|
||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
VFormat(buffer, sizeof(buffer), display, 5);
|
VFormat(buffer, sizeof(buffer), text, 5);
|
||||||
|
|
||||||
KeyValues kv = new KeyValues("dialog", "title", buffer);
|
KeyValues kv = new KeyValues("dialog", "title", buffer);
|
||||||
kv.SetColor("color", 255, 255, 255, 255);
|
kv.SetColor("color", 255, 255, 255, 255);
|
28
PlayerRankings/scripting/include/PlayerRankings.inc
Normal file
28
PlayerRankings/scripting/include/PlayerRankings.inc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#if defined _PlayerRankings_OnRoundEnd
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define _PlayerRankings_OnRoundEnd
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current damage of a client
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return The current damage of the client.
|
||||||
|
*/
|
||||||
|
native int PlayerRankings_GetClientDamage(int client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current hits of a client
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return The current hits of the client.
|
||||||
|
*/
|
||||||
|
native int PlayerRankings_GetClientHits(int client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current infections of a client
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return The current infections of the client.
|
||||||
|
*/
|
||||||
|
native int PlayerRankings_GetClientInfections(int client);
|
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
"Chat Prefix"
|
"Chat Prefix"
|
||||||
{
|
{
|
||||||
"en" "[TopDefenders]"
|
"en" "[PlayerRankings]"
|
||||||
}
|
}
|
||||||
"Cookie Menu"
|
"Cookie Menu"
|
||||||
{
|
{
|
||||||
"en" "Top Defenders"
|
"en" "Player Rankings"
|
||||||
}
|
}
|
||||||
"Cookie Menu Title"
|
"Cookie Menu Title"
|
||||||
{
|
{
|
||||||
"en" "Top Defenders Settings"
|
"en" "Player Rankings Settings"
|
||||||
}
|
}
|
||||||
"Enabled"
|
"Enabled"
|
||||||
{
|
{
|
@ -1,29 +0,0 @@
|
|||||||
#if defined _TopDefenders_OnRoundEnd
|
|
||||||
#endinput
|
|
||||||
#endif
|
|
||||||
#define _TopDefenders_OnRoundEnd
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when TopDefenders are being printed out.
|
|
||||||
*
|
|
||||||
* @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], int iHits[MAXPLAYERS+1]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current damage of a client
|
|
||||||
*
|
|
||||||
* @param client Client index.
|
|
||||||
* @return The current damage of the 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);
|
|
@ -282,7 +282,7 @@ public Action Command_DisplayStatus(int client, int args)
|
|||||||
}
|
}
|
||||||
else if (g_iRestrictIssued[target] && g_iRestrictExpire[target] >= GetTime())
|
else if (g_iRestrictIssued[target] && g_iRestrictExpire[target] >= GetTime())
|
||||||
{
|
{
|
||||||
char sTimeRemaining[32];
|
char sTimeRemaining[64];
|
||||||
int iTimeRemaining = g_iRestrictExpire[target] - GetTime();
|
int iTimeRemaining = g_iRestrictExpire[target] - GetTime();
|
||||||
|
|
||||||
int iDays = (iTimeRemaining / 86400);
|
int iDays = (iTimeRemaining / 86400);
|
||||||
@ -291,15 +291,15 @@ public Action Command_DisplayStatus(int client, int args)
|
|||||||
int iSeconds = (iTimeRemaining % 60);
|
int iSeconds = (iTimeRemaining % 60);
|
||||||
|
|
||||||
if (iDays)
|
if (iDays)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d:%02d:%02d", iDays, iHours, iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Days %d Hours %d Minutes %d Seconds", iDays, iHours, iMinutes, iSeconds);
|
||||||
else if (iHours)
|
else if (iHours)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d:%02d", iHours, iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours %d Minutes %d Seconds", iHours, iMinutes, iSeconds);
|
||||||
else if (iMinutes)
|
else if (iMinutes)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d", iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Minutes %d Seconds", iMinutes, iSeconds);
|
||||||
else
|
else
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d", iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Seconds", iSeconds);
|
||||||
|
|
||||||
CReplyToCommand(client, "\x07%s[entWatch] \x07%s%N\x07%s is currently restricted for another: \x07%s%s\x07%s.", "E01B5D", "EDEDED", target, "F16767", "EDEDED", sTimeRemaining, "F16767");
|
CReplyToCommand(client, "\x07%s[entWatch] \x07%s%N\x07%s is currently restricted for another \x07%s%s\x07%s.", "E01B5D", "EDEDED", target, "F16767", "EDEDED", sTimeRemaining, "F16767");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -327,7 +327,7 @@ public Action Command_DisplayStatus(int client, int args)
|
|||||||
}
|
}
|
||||||
else if (g_iRestrictIssued[client] && g_iRestrictExpire[client] >= GetTime())
|
else if (g_iRestrictIssued[client] && g_iRestrictExpire[client] >= GetTime())
|
||||||
{
|
{
|
||||||
char sTimeRemaining[32];
|
char sTimeRemaining[64];
|
||||||
int iTimeRemaining = g_iRestrictExpire[client] - GetTime();
|
int iTimeRemaining = g_iRestrictExpire[client] - GetTime();
|
||||||
|
|
||||||
int iDays = (iTimeRemaining / 86400);
|
int iDays = (iTimeRemaining / 86400);
|
||||||
@ -336,15 +336,15 @@ public Action Command_DisplayStatus(int client, int args)
|
|||||||
int iSeconds = (iTimeRemaining % 60);
|
int iSeconds = (iTimeRemaining % 60);
|
||||||
|
|
||||||
if (iDays)
|
if (iDays)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d:%02d:%02d", iDays, iHours, iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Days %d Hours %d Minutes %d Seconds", iDays, iHours, iMinutes, iSeconds);
|
||||||
else if (iHours)
|
else if (iHours)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d:%02d", iHours, iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours %d Minutes %d Seconds", iHours, iMinutes, iSeconds);
|
||||||
else if (iMinutes)
|
else if (iMinutes)
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d:%02d", iMinutes, iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Minutes %d Seconds", iMinutes, iSeconds);
|
||||||
else
|
else
|
||||||
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d", iSeconds);
|
Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Seconds", iSeconds);
|
||||||
|
|
||||||
CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou are currently restricted for another: \x07%s%s\x07%s.", "E01B5D", "F16767", "EDEDED", sTimeRemaining, "F16767");
|
CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou are currently restricted for another \x07%s%s\x07%s.", "E01B5D", "F16767", "EDEDED", sTimeRemaining, "F16767");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user