added a whitelist
This commit is contained in:
parent
9342356b8b
commit
77c7cc0b04
3
leader2/configs/leader/leaders.ini
Normal file
3
leader2/configs/leader/leaders.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"STEAM_0:0:22286324" // rogan
|
||||||
|
"STEAM_0:1:32247009" // neon
|
||||||
|
"STEAM_0:1:39773416" // omar
|
@ -6,7 +6,8 @@
|
|||||||
#include <zombiereloaded>
|
#include <zombiereloaded>
|
||||||
#include <leader>
|
#include <leader>
|
||||||
|
|
||||||
#define PLUGIN_VERSION "2.9"
|
#define PLUGIN_VERSION "3.0"
|
||||||
|
#define MAXLEADERS 64
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
|
|
||||||
int leaderMVP, leaderScore, currentSprite = -1, spriteEntities[MAXPLAYERS+1], markerEntities[MAXPLAYERS+1], leaderClient = -1;
|
int leaderMVP, leaderScore, currentSprite = -1, spriteEntities[MAXPLAYERS+1], markerEntities[MAXPLAYERS+1], leaderClient = -1;
|
||||||
@ -26,6 +27,8 @@ char DefendVTF[PLATFORM_MAX_PATH];
|
|||||||
char FollowVMT[PLATFORM_MAX_PATH];
|
char FollowVMT[PLATFORM_MAX_PATH];
|
||||||
char FollowVTF[PLATFORM_MAX_PATH];
|
char FollowVTF[PLATFORM_MAX_PATH];
|
||||||
char leaderTag[64];
|
char leaderTag[64];
|
||||||
|
char g_sDataFile[128];
|
||||||
|
char g_sLeaderAuth[MAXLEADERS][64];
|
||||||
|
|
||||||
int g_BeamSprite = -1;
|
int g_BeamSprite = -1;
|
||||||
int g_HaloSprite = -1;
|
int g_HaloSprite = -1;
|
||||||
@ -33,16 +36,24 @@ int greyColor[4] = {128, 128, 128, 255};
|
|||||||
int g_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
|
int g_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
|
||||||
int g_Serial_Gen = 0;
|
int g_Serial_Gen = 0;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Plugin myinfo = {
|
public Plugin myinfo = {
|
||||||
name = "Leader",
|
name = "Leader",
|
||||||
author = "AntiTeal",
|
author = "AntiTeal + Neon",
|
||||||
description = "Allows for a human to be a leader, and give them special functions with it.",
|
description = "Allows for a human to be a leader, and give them special functions with it.",
|
||||||
version = PLUGIN_VERSION,
|
version = PLUGIN_VERSION,
|
||||||
url = "https://antiteal.com"
|
url = "https://antiteal.com"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
|
BuildPath(Path_SM, g_sDataFile, sizeof(g_sDataFile), "configs/leader/leaders.ini");
|
||||||
|
|
||||||
CreateConVar("sm_leader_version", PLUGIN_VERSION, "Leader Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
|
CreateConVar("sm_leader_version", PLUGIN_VERSION, "Leader Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
|
||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
LoadTranslations("core.phrases");
|
LoadTranslations("core.phrases");
|
||||||
@ -53,8 +64,10 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
RegConsoleCmd("sm_leader", Leader);
|
RegConsoleCmd("sm_leader", Leader);
|
||||||
RegConsoleCmd("sm_currentleader", CurrentLeader);
|
RegConsoleCmd("sm_currentleader", CurrentLeader);
|
||||||
|
RegConsoleCmd("sm_leaders", Leaders);
|
||||||
RegConsoleCmd("sm_voteleader", VoteLeader);
|
RegConsoleCmd("sm_voteleader", VoteLeader);
|
||||||
RegAdminCmd("sm_removeleader", RemoveTheLeader, ADMFLAG_GENERIC);
|
RegAdminCmd("sm_removeleader", RemoveTheLeader, ADMFLAG_GENERIC);
|
||||||
|
RegAdminCmd("sm_reloadleaders", ReloadLeaders, ADMFLAG_GENERIC);
|
||||||
|
|
||||||
g_cVDefendVMT = CreateConVar("sm_leader_defend_vmt", "materials/sg/sgdefend.vmt", "The defend here .vmt file");
|
g_cVDefendVMT = CreateConVar("sm_leader_defend_vmt", "materials/sg/sgdefend.vmt", "The defend here .vmt file");
|
||||||
g_cVDefendVTF = CreateConVar("sm_leader_defend_vtf", "materials/sg/sgdefend.vtf", "The defend here .vtf file");
|
g_cVDefendVTF = CreateConVar("sm_leader_defend_vtf", "materials/sg/sgdefend.vtf", "The defend here .vtf file");
|
||||||
@ -113,8 +126,24 @@ public void OnPluginStart()
|
|||||||
AddCommandListener(Radio, "getout");
|
AddCommandListener(Radio, "getout");
|
||||||
AddCommandListener(Radio, "negative");
|
AddCommandListener(Radio, "negative");
|
||||||
AddCommandListener(Radio, "enemydown");
|
AddCommandListener(Radio, "enemydown");
|
||||||
|
|
||||||
|
AddMultiTargetFilter("@leaders", Filter_Leaders, "Possible Leaders", false);
|
||||||
|
AddMultiTargetFilter("@leader", Filter_Leader, "Current Leader", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void OnPluginEnd()
|
||||||
|
{
|
||||||
|
RemoveMultiTargetFilter("@leaders", Filter_Leaders);
|
||||||
|
RemoveMultiTargetFilter("@leader", Filter_Leader);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void ConVarChange(ConVar CVar, const char[] oldVal, const char[] newVal)
|
public void ConVarChange(ConVar CVar, const char[] oldVal, const char[] newVal)
|
||||||
{
|
{
|
||||||
g_cVDefendVTF.GetString(DefendVTF, sizeof(DefendVTF));
|
g_cVDefendVTF.GetString(DefendVTF, sizeof(DefendVTF));
|
||||||
@ -135,6 +164,9 @@ public void ConVarChange(ConVar CVar, const char[] oldVal, const char[] newVal)
|
|||||||
allowVoting = g_cVAllowVoting.BoolValue;
|
allowVoting = g_cVAllowVoting.BoolValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
AddFileToDownloadsTable(DefendVTF);
|
AddFileToDownloadsTable(DefendVTF);
|
||||||
@ -163,14 +195,22 @@ public void OnMapStart()
|
|||||||
{
|
{
|
||||||
g_HaloSprite = PrecacheModel(buffer);
|
g_HaloSprite = PrecacheModel(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateLeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void CreateBeacon(int client)
|
public void CreateBeacon(int client)
|
||||||
{
|
{
|
||||||
g_BeaconSerial[client] = ++g_Serial_Gen;
|
g_BeaconSerial[client] = ++g_Serial_Gen;
|
||||||
CreateTimer(1.0, Timer_Beacon, client | (g_Serial_Gen << 7), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(1.0, Timer_Beacon, client | (g_Serial_Gen << 7), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void KillBeacon(int client)
|
public void KillBeacon(int client)
|
||||||
{
|
{
|
||||||
g_BeaconSerial[client] = 0;
|
g_BeaconSerial[client] = 0;
|
||||||
@ -181,6 +221,9 @@ public void KillBeacon(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void KillAllBeacons()
|
public void KillAllBeacons()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
@ -189,6 +232,9 @@ public void KillAllBeacons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void PerformBeacon(int client)
|
public void PerformBeacon(int client)
|
||||||
{
|
{
|
||||||
if (g_BeaconSerial[client] == 0)
|
if (g_BeaconSerial[client] == 0)
|
||||||
@ -203,6 +249,9 @@ public void PerformBeacon(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Timer_Beacon(Handle timer, any value)
|
public Action Timer_Beacon(Handle timer, any value)
|
||||||
{
|
{
|
||||||
int client = value & 0x7f;
|
int client = value & 0x7f;
|
||||||
@ -238,6 +287,9 @@ public Action Timer_Beacon(Handle timer, any value)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int AttachSprite(int client, char[] sprite) //https://forums.alliedmods.net/showpost.php?p=1880207&postcount=5
|
public int AttachSprite(int client, char[] sprite) //https://forums.alliedmods.net/showpost.php?p=1880207&postcount=5
|
||||||
{
|
{
|
||||||
if(!IsPlayerAlive(client))
|
if(!IsPlayerAlive(client))
|
||||||
@ -274,6 +326,9 @@ public int AttachSprite(int client, char[] sprite) //https://forums.alliedmods.n
|
|||||||
return Ent;
|
return Ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void RemoveSprite(int client)
|
public void RemoveSprite(int client)
|
||||||
{
|
{
|
||||||
if (spriteEntities[client] != -1 && IsValidEdict(spriteEntities[client]))
|
if (spriteEntities[client] != -1 && IsValidEdict(spriteEntities[client]))
|
||||||
@ -286,6 +341,9 @@ public void RemoveSprite(int client)
|
|||||||
spriteEntities[client] = -1;
|
spriteEntities[client] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void RemoveMarker(int client)
|
public void RemoveMarker(int client)
|
||||||
{
|
{
|
||||||
if (markerEntities[client] != -1 && IsValidEdict(markerEntities[client]))
|
if (markerEntities[client] != -1 && IsValidEdict(markerEntities[client]))
|
||||||
@ -298,6 +356,9 @@ public void RemoveMarker(int client)
|
|||||||
markerEntities[client] = -1;
|
markerEntities[client] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void SetLeader(int client)
|
public void SetLeader(int client)
|
||||||
{
|
{
|
||||||
if(IsValidClient(leaderClient))
|
if(IsValidClient(leaderClient))
|
||||||
@ -323,6 +384,9 @@ public void SetLeader(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void RemoveLeader(int client)
|
public void RemoveLeader(int client)
|
||||||
{
|
{
|
||||||
//CS_SetClientClanTag(client, leaderTag);
|
//CS_SetClientClanTag(client, leaderTag);
|
||||||
@ -343,6 +407,9 @@ public void RemoveLeader(int client)
|
|||||||
beaconActive = false;
|
beaconActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int SpawnMarker(int client, char[] sprite)
|
public int SpawnMarker(int client, char[] sprite)
|
||||||
{
|
{
|
||||||
if(!IsPlayerAlive(client))
|
if(!IsPlayerAlive(client))
|
||||||
@ -369,6 +436,9 @@ public int SpawnMarker(int client, char[] sprite)
|
|||||||
return Ent;
|
return Ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action CurrentLeader(int client, int args)
|
public Action CurrentLeader(int client, int args)
|
||||||
{
|
{
|
||||||
if(IsValidClient(leaderClient))
|
if(IsValidClient(leaderClient))
|
||||||
@ -383,6 +453,9 @@ public Action CurrentLeader(int client, int args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action RemoveTheLeader(int client, int args)
|
public Action RemoveTheLeader(int client, int args)
|
||||||
{
|
{
|
||||||
if(IsValidClient(leaderClient))
|
if(IsValidClient(leaderClient))
|
||||||
@ -398,6 +471,9 @@ public Action RemoveTheLeader(int client, int args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Leader(int client, int args)
|
public Action Leader(int client, int args)
|
||||||
{
|
{
|
||||||
if(CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC, false))
|
if(CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC, false))
|
||||||
@ -415,6 +491,7 @@ public Action Leader(int client, int args)
|
|||||||
if(target == leaderClient)
|
if(target == leaderClient)
|
||||||
{
|
{
|
||||||
LeaderMenu(target);
|
LeaderMenu(target);
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -424,10 +501,12 @@ public Action Leader(int client, int args)
|
|||||||
PrintToChatAll("[SM] %N is the new leader!", target);
|
PrintToChatAll("[SM] %N is the new leader!", target);
|
||||||
PrintToChat(target, "[SM] You are now the leader! Type !leader to open up the leader menu.");
|
PrintToChat(target, "[SM] You are now the leader! Type !leader to open up the leader menu.");
|
||||||
LeaderMenu(target);
|
LeaderMenu(target);
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] The target has to be alive!");
|
ReplyToCommand(client, "[SM] The target has to be alive!");
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,24 +523,201 @@ public Action Leader(int client, int args)
|
|||||||
PrintToChatAll("[SM] %N is the new leader!", client);
|
PrintToChatAll("[SM] %N is the new leader!", client);
|
||||||
PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
|
PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
|
||||||
LeaderMenu(client);
|
LeaderMenu(client);
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] The target has to be alive!");
|
ReplyToCommand(client, "[SM] The target has to be alive!");
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_leader <optional: client|#userid>");
|
ReplyToCommand(client, "[SM] Usage: sm_leader <optional: client|#userid>");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsPossibleLeader(client))
|
||||||
|
{
|
||||||
|
if(client == leaderClient)
|
||||||
|
{
|
||||||
|
LeaderMenu(client);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
if(IsPlayerAlive(client))
|
||||||
|
{
|
||||||
|
SetLeader(client);
|
||||||
|
PrintToChatAll("[SM] %N is the new leader!", client);
|
||||||
|
PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
|
||||||
|
LeaderMenu(client);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] The target has to be alive!");
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(client == leaderClient)
|
if(client == leaderClient)
|
||||||
{
|
{
|
||||||
LeaderMenu(client);
|
LeaderMenu(client);
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public Action Leaders(int client, int args)
|
||||||
|
{
|
||||||
|
char aBuf[1024];
|
||||||
|
char aBuf2[MAX_NAME_LENGTH];
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(IsClientInGame(i) && !IsFakeClient(i) && IsPossibleLeader(i))
|
||||||
|
{
|
||||||
|
GetClientName(i, aBuf2, sizeof(aBuf2));
|
||||||
|
StrCat(aBuf, sizeof(aBuf), aBuf2);
|
||||||
|
StrCat(aBuf, sizeof(aBuf), ", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(aBuf))
|
||||||
|
{
|
||||||
|
aBuf[strlen(aBuf) - 2] = 0;
|
||||||
|
ReplyToCommand(client, "[SM] Possible Leaders currently online: %s", aBuf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ReplyToCommand(client, "[SM] Possible Leaders currently online: none");
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public Action ReloadLeaders(int client, int args)
|
||||||
|
{
|
||||||
|
UpdateLeaders();
|
||||||
|
ReplyToCommand(client, "[SM] Reloaded Leader File");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public bool Filter_Leaders(const char[] sPattern, Handle hClients)
|
||||||
|
{
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(IsClientInGame(i) && !IsFakeClient(i) && IsPossibleLeader(i))
|
||||||
|
{
|
||||||
|
PushArrayCell(hClients, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public bool Filter_Leader(const char[] sPattern, Handle hClients)
|
||||||
|
{
|
||||||
|
if(IsValidClient(leaderClient))
|
||||||
|
{
|
||||||
|
PushArrayCell(hClients, leaderClient);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public bool IsPossibleLeader(int client)
|
||||||
|
{
|
||||||
|
char sAuth[64];
|
||||||
|
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||||
|
|
||||||
|
for (int i = 0; i <= (MAXLEADERS - 1); i++)
|
||||||
|
{
|
||||||
|
if (StrEqual(sAuth, g_sLeaderAuth[i]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void UpdateLeaders()
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= (MAXLEADERS - 1); i++)
|
||||||
|
g_sLeaderAuth[i] = "";
|
||||||
|
|
||||||
|
File fFile = OpenFile(g_sDataFile, "rt");
|
||||||
|
if (!fFile)
|
||||||
|
{
|
||||||
|
SetFailState("Could not read from: %s", g_sDataFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sAuth[64];
|
||||||
|
int iIndex = 0;
|
||||||
|
|
||||||
|
while (!fFile.EndOfFile())
|
||||||
|
{
|
||||||
|
char line[255];
|
||||||
|
if (!fFile.ReadLine(line, sizeof(line)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Trim comments */
|
||||||
|
int len = strlen(line);
|
||||||
|
bool ignoring = false;
|
||||||
|
for (int i=0; i<len; i++)
|
||||||
|
{
|
||||||
|
if (ignoring)
|
||||||
|
{
|
||||||
|
if (line[i] == '"')
|
||||||
|
ignoring = false;
|
||||||
|
} else {
|
||||||
|
if (line[i] == '"')
|
||||||
|
{
|
||||||
|
ignoring = true;
|
||||||
|
} else if (line[i] == ';') {
|
||||||
|
line[i] = '\0';
|
||||||
|
break;
|
||||||
|
} else if (line[i] == '/'
|
||||||
|
&& i != len - 1
|
||||||
|
&& line[i+1] == '/')
|
||||||
|
{
|
||||||
|
line[i] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TrimString(line);
|
||||||
|
|
||||||
|
if ((line[0] == '/' && line[1] == '/')
|
||||||
|
|| (line[0] == ';' || line[0] == '\0'))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sAuth = "";
|
||||||
|
BreakString(line, sAuth, sizeof(sAuth));
|
||||||
|
g_sLeaderAuth[iIndex] = sAuth;
|
||||||
|
iIndex ++;
|
||||||
|
}
|
||||||
|
fFile.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void LeaderMenu(int client)
|
public void LeaderMenu(int client)
|
||||||
{
|
{
|
||||||
Handle menu = CreateMenu(LeaderMenu_Handler);
|
Handle menu = CreateMenu(LeaderMenu_Handler);
|
||||||
@ -498,6 +754,9 @@ public void LeaderMenu(int client)
|
|||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int LeaderMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
public int LeaderMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
||||||
{
|
{
|
||||||
if(leaderClient == client && IsValidClient(client))
|
if(leaderClient == client && IsValidClient(client))
|
||||||
@ -534,6 +793,9 @@ public int LeaderMenu_Handler(Handle menu, MenuAction action, int client, int po
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void ToggleBeacon(int client)
|
public void ToggleBeacon(int client)
|
||||||
{
|
{
|
||||||
if(beaconActive)
|
if(beaconActive)
|
||||||
@ -544,6 +806,9 @@ public void ToggleBeacon(int client)
|
|||||||
PerformBeacon(client);
|
PerformBeacon(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void SpriteMenu(int client)
|
public void SpriteMenu(int client)
|
||||||
{
|
{
|
||||||
Handle menu = CreateMenu(SpriteMenu_Handler);
|
Handle menu = CreateMenu(SpriteMenu_Handler);
|
||||||
@ -580,6 +845,9 @@ public void SpriteMenu(int client)
|
|||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int SpriteMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
public int SpriteMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
||||||
{
|
{
|
||||||
if(leaderClient == client && IsValidClient(client))
|
if(leaderClient == client && IsValidClient(client))
|
||||||
@ -624,6 +892,9 @@ public int SpriteMenu_Handler(Handle menu, MenuAction action, int client, int po
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void MarkerMenu(int client)
|
public void MarkerMenu(int client)
|
||||||
{
|
{
|
||||||
Handle menu = CreateMenu(MarkerMenu_Handler);
|
Handle menu = CreateMenu(MarkerMenu_Handler);
|
||||||
@ -659,6 +930,9 @@ public void MarkerMenu(int client)
|
|||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int MarkerMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
public int MarkerMenu_Handler(Handle menu, MenuAction action, int client, int position)
|
||||||
{
|
{
|
||||||
if(leaderClient == client && IsValidClient(client))
|
if(leaderClient == client && IsValidClient(client))
|
||||||
@ -694,6 +968,10 @@ public int MarkerMenu_Handler(Handle menu, MenuAction action, int client, int po
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
if(client == leaderClient)
|
if(client == leaderClient)
|
||||||
@ -704,6 +982,9 @@ public void OnClientDisconnect(int client)
|
|||||||
voteCount[client] = 0;
|
voteCount[client] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Event_PlayerDeath(Handle event, char[] name, bool dontBroadcast)
|
public Action Event_PlayerDeath(Handle event, char[] name, bool dontBroadcast)
|
||||||
{
|
{
|
||||||
int client = GetClientOfUserId(GetEventInt(event, "userid"));
|
int client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
@ -715,6 +996,9 @@ public Action Event_PlayerDeath(Handle event, char[] name, bool dontBroadcast)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||||
{
|
{
|
||||||
if(client == leaderClient)
|
if(client == leaderClient)
|
||||||
@ -724,6 +1008,9 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnMapEnd()
|
public void OnMapEnd()
|
||||||
{
|
{
|
||||||
if(IsValidClient(leaderClient))
|
if(IsValidClient(leaderClient))
|
||||||
@ -734,6 +1021,9 @@ public void OnMapEnd()
|
|||||||
KillAllBeacons();
|
KillAllBeacons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool IsValidClient(int client, bool nobots = true)
|
bool IsValidClient(int client, bool nobots = true)
|
||||||
{
|
{
|
||||||
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
|
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
|
||||||
@ -743,6 +1033,9 @@ bool IsValidClient(int client, bool nobots = true)
|
|||||||
return IsClientInGame(client);
|
return IsClientInGame(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Event_RoundEnd(Handle event, char[] name, bool dontBroadcast)
|
public Action Event_RoundEnd(Handle event, char[] name, bool dontBroadcast)
|
||||||
{
|
{
|
||||||
if(IsValidClient(leaderClient))
|
if(IsValidClient(leaderClient))
|
||||||
@ -753,6 +1046,9 @@ public Action Event_RoundEnd(Handle event, char[] name, bool dontBroadcast)
|
|||||||
KillAllBeacons();
|
KillAllBeacons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action HookPlayerChat(int client, char[] command, int args)
|
public Action HookPlayerChat(int client, char[] command, int args)
|
||||||
{
|
{
|
||||||
if(IsValidClient(client) && leaderClient == client)
|
if(IsValidClient(client) && leaderClient == client)
|
||||||
@ -773,6 +1069,9 @@ public Action HookPlayerChat(int client, char[] command, int args)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
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("Leader_CurrentLeader", Native_CurrentLeader);
|
CreateNative("Leader_CurrentLeader", Native_CurrentLeader);
|
||||||
@ -780,16 +1079,25 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int Native_CurrentLeader(Handle plugin, int numParams)
|
public int Native_CurrentLeader(Handle plugin, int numParams)
|
||||||
{
|
{
|
||||||
return leaderClient;
|
return leaderClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public int Native_SetLeader(Handle plugin, int numParams)
|
public int Native_SetLeader(Handle plugin, int numParams)
|
||||||
{
|
{
|
||||||
SetLeader(GetNativeCell(1));
|
SetLeader(GetNativeCell(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Radio(int client, const char[] command, int argc)
|
public Action Radio(int client, const char[] command, int argc)
|
||||||
{
|
{
|
||||||
if(client == leaderClient)
|
if(client == leaderClient)
|
||||||
@ -821,6 +1129,9 @@ public Action Radio(int client, const char[] command, int argc)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void PrintRadio(int client, char[] text)
|
public void PrintRadio(int client, char[] text)
|
||||||
{
|
{
|
||||||
char szClantag[32], szMessage[64];
|
char szClantag[32], szMessage[64];
|
||||||
@ -830,6 +1141,9 @@ public void PrintRadio(int client, char[] text)
|
|||||||
PrintToChatAll(szMessage);
|
PrintToChatAll(szMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action VoteLeader(int client, int argc)
|
public Action VoteLeader(int client, int argc)
|
||||||
{
|
{
|
||||||
if(!allowVoting)
|
if(!allowVoting)
|
||||||
@ -886,4 +1200,4 @@ public Action VoteLeader(int client, int argc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user