Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
Untitled Diff
创建于
6年前
差异永不过期
清除
导出
分享
解释
11 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
248 行
全部复制
10 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
248 行
全部复制
#pragma semicolon 1
#pragma semicolon 1
#pragma newdecls required
#pragma newdecls required
#include <sourcemod>
#include <sourcemod>
#include <clientprefs>
#include <clientprefs>
#include <sdktools>
#include <sdktools>
#include <sdkhooks>
#include <sdkhooks>
#include <cstrike>
#include <cstrike>
#define SPECMODE_NONE 0
#define SPECMODE_NONE 0
#define SPECMODE_FIRSTPERSON 4
#define SPECMODE_FIRSTPERSON 4
#define SPECMODE_3RDPERSON 5
#define SPECMODE_3RDPERSON 5
#define SPECMODE_FREELOOK 6
#define SPECMODE_FREELOOK 6
#define UPDATE_INTERVAL 2.5
#define UPDATE_INTERVAL 2.5
Handle HudHintTimers[MAXPLAYERS + 1];
Handle HudHintTimers[MAXPLAYERS + 1];
bool speclist_stealth[MAXPLAYERS + 1];
bool speclist_stealth[MAXPLAYERS + 1];
bool speclist_enabled[MAXPLAYERS + 1];
bool speclist_enabled[MAXPLAYERS + 1];
Handle g_cEnabled = null;
Handle g_cEnabled = null;
public Plugin myinfo =
public Plugin myinfo =
{
{
复制
已复制
复制
已复制
name = "SpecList
",
name = "SpecList
/Fix
",
author = "cra88y
",
author = "cra88y
/Timid
",
version = "
6.9
",
version = "
7.1
",
};
};
public void OnPluginStart()
public void OnPluginStart()
{
{
RegConsoleCmd("sm_speclist", Command_SpecList);
RegConsoleCmd("sm_speclist", Command_SpecList);
RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_ROOT);
RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_ROOT);
g_cEnabled = RegClientCookie("Speclist_Enabled", "Speclist on or off", CookieAccess_Protected);
g_cEnabled = RegClientCookie("Speclist_Enabled", "Speclist on or off", CookieAccess_Protected);
HookEvent("player_spawn", Event_Player_Spawn);
HookEvent("player_spawn", Event_Player_Spawn);
for (int i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
{
if (IsClientConnected(i) && IsValidClient(i) && AreClientCookiesCached(i))
if (IsClientConnected(i) && IsValidClient(i) && AreClientCookiesCached(i))
{
{
OnClientCookiesCached(i);
OnClientCookiesCached(i);
}
}
}
}
}
}
public void OnClientPostAdminCheck(int client)
public void OnClientPostAdminCheck(int client)
{
{
CreateHudHintTimer(client);
CreateHudHintTimer(client);
speclist_enabled[client] = true;
speclist_enabled[client] = true;
speclist_stealth[client] = false;
speclist_stealth[client] = false;
}
}
public void OnClientDisconnect(int client)
public void OnClientDisconnect(int client)
{
{
if (IsClientInGame(client))
if (IsClientInGame(client))
KillHudHintTimer(client);
KillHudHintTimer(client);
}
}
public void OnClientCookiesCached(int client)
public void OnClientCookiesCached(int client)
{
{
char CookieEnabled[16];
char CookieEnabled[16];
GetClientCookie(client, g_cEnabled, CookieEnabled, sizeof(CookieEnabled));
GetClientCookie(client, g_cEnabled, CookieEnabled, sizeof(CookieEnabled));
speclist_enabled[client] = CookieEnabled[0] == '\0' ? true : view_as<bool>(StringToInt(CookieEnabled));
speclist_enabled[client] = CookieEnabled[0] == '\0' ? true : view_as<bool>(StringToInt(CookieEnabled));
if (!speclist_enabled[client])
if (!speclist_enabled[client])
{
{
KillHudHintTimer(client);
KillHudHintTimer(client);
}
}
/*if (g_iSpecEnabled[client] == 1)
/*if (g_iSpecEnabled[client] == 1)
{
{
speclist_enabled[client] = true;
speclist_enabled[client] = true;
}
}
else
else
{
{
speclist_enabled[client] = false;
speclist_enabled[client] = false;
KillHudHintTimer(client);
KillHudHintTimer(client);
}*/
}*/
}
}
public Action Event_Player_Spawn(Event event, const char[] name, bool dontBroadcast)
public Action Event_Player_Spawn(Event event, const char[] name, bool dontBroadcast)
{
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsClientConnected(client) && IsValidClient(client) && !AreClientCookiesCached(client))
if (IsClientConnected(client) && IsValidClient(client) && !AreClientCookiesCached(client))
{
{
OnClientCookiesCached(client);
OnClientCookiesCached(client);
}
}
}
}
public Action Command_Stealth(int client, int args)
public Action Command_Stealth(int client, int args)
{
{
speclist_stealth[client] = !speclist_stealth[client];
speclist_stealth[client] = !speclist_stealth[client];
if (speclist_stealth[client] == true)
if (speclist_stealth[client] == true)
ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be hidden from speclist.");
ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be hidden from speclist.");
if (speclist_stealth[client] == false)
if (speclist_stealth[client] == false)
ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be shown on speclist.");
ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be shown on speclist.");
}
}
public Action Command_SpecList(int client, int args)
public Action Command_SpecList(int client, int args)
{
{
if (speclist_enabled[client] == true)
if (speclist_enabled[client] == true)
{
{
speclist_enabled[client] = false;
speclist_enabled[client] = false;
KillHudHintTimer(client);
KillHudHintTimer(client);
ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list disabled.");
ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list disabled.");
SetClientCookie(client, g_cEnabled, "0");
SetClientCookie(client, g_cEnabled, "0");
}
}
else if (speclist_enabled[client] == false)
else if (speclist_enabled[client] == false)
{
{
speclist_enabled[client] = true;
speclist_enabled[client] = true;
CreateHudHintTimer(client);
CreateHudHintTimer(client);
ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list enabled.");
ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list enabled.");
SetClientCookie(client, g_cEnabled, "1");
SetClientCookie(client, g_cEnabled, "1");
}
}
return Plugin_Handled;
return Plugin_Handled;
}
}
public Action Timer_UpdateHudHint(Handle timer, any client)
public Action Timer_UpdateHudHint(Handle timer, any client)
{
{
int iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode");
int iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode");
int iSpecMode, iTarget, iTargetUser;
int iSpecMode, iTarget, iTargetUser;
bool bDisplayHint = false;
bool bDisplayHint = false;
char szText[2048];
char szText[2048];
szText[0] = '\0';
szText[0] = '\0';
if (IsPlayerAlive(client))
if (IsPlayerAlive(client))
{
{
for (int i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
{
if (!IsClientInGame(i) || !IsClientObserver(i))
if (!IsClientInGame(i) || !IsClientObserver(i))
continue;
continue;
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
continue;
continue;
iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
if (speclist_stealth[i] == true)
if (speclist_stealth[i] == true)
continue;
continue;
if (iTarget == client)
if (iTarget == client)
{
{
if (IsPlayerVip(i) == true && speclist_stealth[i] == false)
if (IsPlayerVip(i) == true && speclist_stealth[i] == false)
{
{
if (IsPlayerAdmin(i) == true)
if (IsPlayerAdmin(i) == true)
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
<font color='#21618C'>
%N.
</font>
", szText, i);
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
}
}
else
else
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
<font color='#D4AC0D'>
%N.
</font>
", szText, i);
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
}
}
}
}
else
else
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
}
}
bDisplayHint = true;
bDisplayHint = true;
}
}
}
}
}
}
else if (iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON)
else if (iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON)
{
{
iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
for (int i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
{
if (!IsClientInGame(i) || !IsClientObserver(i))
if (!IsClientInGame(i) || !IsClientObserver(i))
continue;
continue;
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
continue;
continue;
iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
if (speclist_stealth[i] == true)
if (speclist_stealth[i] == true)
continue;
continue;
if (iTarget == iTargetUser)
if (iTarget == iTargetUser)
{
{
if (IsPlayerVip(i) == true)
if (IsPlayerVip(i) == true)
{
{
if (IsPlayerAdmin(i) == true)
if (IsPlayerAdmin(i) == true)
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
<font color='#21618C'>
%N.
</font>
", szText, i);
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
}
}
else
else
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
<font color='#D4AC0D'>
%N.
</font>
", szText, i);
Format(szText, sizeof(szText), "%s
%N.
", szText, i);
}
}
}
}
else
else
{
{
复制
已复制
复制
已复制
Format(szText, sizeof(szText), "%s
%N. ", szText, i);
Format(szText, sizeof(szText), "%s
%N. ", szText, i);
}
}
bDisplayHint = true;
bDisplayHint = true;
}
}
}
}
}
}
if (bDisplayHint)
if (bDisplayHint)
{
{
if (speclist_enabled[client] == true)
if (speclist_enabled[client] == true)
{
{
复制
已复制
复制
已复制
PrintHintText(client, "
<font size='12'><u>Spectators:\n</u></font><font size='15'>%s</font>
", szText);
PrintHintText(client, "
%s
", szText);
bDisplayHint = false;
bDisplayHint = false;
}
}
}
}
return Plugin_Continue;
return Plugin_Continue;
}
}
void CreateHudHintTimer(int client)
void CreateHudHintTimer(int client)
{
{
HudHintTimers[client] = CreateTimer(UPDATE_INTERVAL, Timer_UpdateHudHint, client, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
HudHintTimers[client] = CreateTimer(UPDATE_INTERVAL, Timer_UpdateHudHint, client, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
}
void KillHudHintTimer(int client)
void KillHudHintTimer(int client)
{
{
if (HudHintTimers[client] != INVALID_HANDLE)
if (HudHintTimers[client] != INVALID_HANDLE)
{
{
KillTimer(HudHintTimers[client]);
KillTimer(HudHintTimers[client]);
HudHintTimers[client] = INVALID_HANDLE;
HudHintTimers[client] = INVALID_HANDLE;
}
}
}
}
bool IsPlayerAdmin(int client)
bool IsPlayerAdmin(int client)
{
{
if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_UNBAN))
if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_UNBAN))
return true;
return true;
return false;
return false;
}
}
bool IsPlayerVip(int client)
bool IsPlayerVip(int client)
{
{
if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_CUSTOM1))
if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_CUSTOM1))
return true;
return true;
return false;
return false;
}
}
stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
{
{
if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
{
{
return false;
return false;
}
}
return true;
return true;
}
}
已保存差异
原始文本
打开文件
#pragma semicolon 1 #pragma newdecls required #include <sourcemod> #include <clientprefs> #include <sdktools> #include <sdkhooks> #include <cstrike> #define SPECMODE_NONE 0 #define SPECMODE_FIRSTPERSON 4 #define SPECMODE_3RDPERSON 5 #define SPECMODE_FREELOOK 6 #define UPDATE_INTERVAL 2.5 Handle HudHintTimers[MAXPLAYERS + 1]; bool speclist_stealth[MAXPLAYERS + 1]; bool speclist_enabled[MAXPLAYERS + 1]; Handle g_cEnabled = null; public Plugin myinfo = { name = "SpecList", author = "cra88y", version = "6.9", }; public void OnPluginStart() { RegConsoleCmd("sm_speclist", Command_SpecList); RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_ROOT); g_cEnabled = RegClientCookie("Speclist_Enabled", "Speclist on or off", CookieAccess_Protected); HookEvent("player_spawn", Event_Player_Spawn); for (int i = 1; i <= MaxClients; i++) { if (IsClientConnected(i) && IsValidClient(i) && AreClientCookiesCached(i)) { OnClientCookiesCached(i); } } } public void OnClientPostAdminCheck(int client) { CreateHudHintTimer(client); speclist_enabled[client] = true; speclist_stealth[client] = false; } public void OnClientDisconnect(int client) { if (IsClientInGame(client)) KillHudHintTimer(client); } public void OnClientCookiesCached(int client) { char CookieEnabled[16]; GetClientCookie(client, g_cEnabled, CookieEnabled, sizeof(CookieEnabled)); speclist_enabled[client] = CookieEnabled[0] == '\0' ? true : view_as<bool>(StringToInt(CookieEnabled)); if (!speclist_enabled[client]) { KillHudHintTimer(client); } /*if (g_iSpecEnabled[client] == 1) { speclist_enabled[client] = true; } else { speclist_enabled[client] = false; KillHudHintTimer(client); }*/ } public Action Event_Player_Spawn(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(GetEventInt(event, "userid")); if (IsClientConnected(client) && IsValidClient(client) && !AreClientCookiesCached(client)) { OnClientCookiesCached(client); } } public Action Command_Stealth(int client, int args) { speclist_stealth[client] = !speclist_stealth[client]; if (speclist_stealth[client] == true) ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be hidden from speclist."); if (speclist_stealth[client] == false) ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be shown on speclist."); } public Action Command_SpecList(int client, int args) { if (speclist_enabled[client] == true) { speclist_enabled[client] = false; KillHudHintTimer(client); ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list disabled."); SetClientCookie(client, g_cEnabled, "0"); } else if (speclist_enabled[client] == false) { speclist_enabled[client] = true; CreateHudHintTimer(client); ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list enabled."); SetClientCookie(client, g_cEnabled, "1"); } return Plugin_Handled; } public Action Timer_UpdateHudHint(Handle timer, any client) { int iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode"); int iSpecMode, iTarget, iTargetUser; bool bDisplayHint = false; char szText[2048]; szText[0] = '\0'; if (IsPlayerAlive(client)) { for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsClientObserver(i)) continue; iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue; iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget"); if (speclist_stealth[i] == true) continue; if (iTarget == client) { if (IsPlayerVip(i) == true && speclist_stealth[i] == false) { if (IsPlayerAdmin(i) == true) { Format(szText, sizeof(szText), "%s<font color='#21618C'>%N.</font> ", szText, i); } else { Format(szText, sizeof(szText), "%s<font color='#D4AC0D'>%N.</font> ", szText, i); } } else { Format(szText, sizeof(szText), "%s%N. ", szText, i); } bDisplayHint = true; } } } else if (iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON) { iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsClientObserver(i)) continue; iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue; iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget"); if (speclist_stealth[i] == true) continue; if (iTarget == iTargetUser) { if (IsPlayerVip(i) == true) { if (IsPlayerAdmin(i) == true) { Format(szText, sizeof(szText), "%s<font color='#21618C'>%N.</font> ", szText, i); } else { Format(szText, sizeof(szText), "%s<font color='#D4AC0D'>%N.</font> ", szText, i); } } else { Format(szText, sizeof(szText), "%s%N. ", szText, i); } bDisplayHint = true; } } } if (bDisplayHint) { if (speclist_enabled[client] == true) { PrintHintText(client, "<font size='12'><u>Spectators:\n</u></font><font size='15'>%s</font>", szText); bDisplayHint = false; } } return Plugin_Continue; } void CreateHudHintTimer(int client) { HudHintTimers[client] = CreateTimer(UPDATE_INTERVAL, Timer_UpdateHudHint, client, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); } void KillHudHintTimer(int client) { if (HudHintTimers[client] != INVALID_HANDLE) { KillTimer(HudHintTimers[client]); HudHintTimers[client] = INVALID_HANDLE; } } bool IsPlayerAdmin(int client) { if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_UNBAN)) return true; return false; } bool IsPlayerVip(int client) { if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_CUSTOM1)) return true; return false; } stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true) { if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client))) { return false; } return true; }
更改后文本
打开文件
#pragma semicolon 1 #pragma newdecls required #include <sourcemod> #include <clientprefs> #include <sdktools> #include <sdkhooks> #include <cstrike> #define SPECMODE_NONE 0 #define SPECMODE_FIRSTPERSON 4 #define SPECMODE_3RDPERSON 5 #define SPECMODE_FREELOOK 6 #define UPDATE_INTERVAL 2.5 Handle HudHintTimers[MAXPLAYERS + 1]; bool speclist_stealth[MAXPLAYERS + 1]; bool speclist_enabled[MAXPLAYERS + 1]; Handle g_cEnabled = null; public Plugin myinfo = { name = "SpecList/Fix", author = "cra88y/Timid", version = "7.1", }; public void OnPluginStart() { RegConsoleCmd("sm_speclist", Command_SpecList); RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_ROOT); g_cEnabled = RegClientCookie("Speclist_Enabled", "Speclist on or off", CookieAccess_Protected); HookEvent("player_spawn", Event_Player_Spawn); for (int i = 1; i <= MaxClients; i++) { if (IsClientConnected(i) && IsValidClient(i) && AreClientCookiesCached(i)) { OnClientCookiesCached(i); } } } public void OnClientPostAdminCheck(int client) { CreateHudHintTimer(client); speclist_enabled[client] = true; speclist_stealth[client] = false; } public void OnClientDisconnect(int client) { if (IsClientInGame(client)) KillHudHintTimer(client); } public void OnClientCookiesCached(int client) { char CookieEnabled[16]; GetClientCookie(client, g_cEnabled, CookieEnabled, sizeof(CookieEnabled)); speclist_enabled[client] = CookieEnabled[0] == '\0' ? true : view_as<bool>(StringToInt(CookieEnabled)); if (!speclist_enabled[client]) { KillHudHintTimer(client); } /*if (g_iSpecEnabled[client] == 1) { speclist_enabled[client] = true; } else { speclist_enabled[client] = false; KillHudHintTimer(client); }*/ } public Action Event_Player_Spawn(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(GetEventInt(event, "userid")); if (IsClientConnected(client) && IsValidClient(client) && !AreClientCookiesCached(client)) { OnClientCookiesCached(client); } } public Action Command_Stealth(int client, int args) { speclist_stealth[client] = !speclist_stealth[client]; if (speclist_stealth[client] == true) ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be hidden from speclist."); if (speclist_stealth[client] == false) ReplyToCommand(client, "\x01[\x02SpecList\x01] You will now be shown on speclist."); } public Action Command_SpecList(int client, int args) { if (speclist_enabled[client] == true) { speclist_enabled[client] = false; KillHudHintTimer(client); ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list disabled."); SetClientCookie(client, g_cEnabled, "0"); } else if (speclist_enabled[client] == false) { speclist_enabled[client] = true; CreateHudHintTimer(client); ReplyToCommand(client, "\x01[\x02SpecList\x01] Spectator list enabled."); SetClientCookie(client, g_cEnabled, "1"); } return Plugin_Handled; } public Action Timer_UpdateHudHint(Handle timer, any client) { int iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode"); int iSpecMode, iTarget, iTargetUser; bool bDisplayHint = false; char szText[2048]; szText[0] = '\0'; if (IsPlayerAlive(client)) { for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsClientObserver(i)) continue; iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue; iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget"); if (speclist_stealth[i] == true) continue; if (iTarget == client) { if (IsPlayerVip(i) == true && speclist_stealth[i] == false) { if (IsPlayerAdmin(i) == true) { Format(szText, sizeof(szText), "%s %N.", szText, i); } else { Format(szText, sizeof(szText), "%s %N.", szText, i); } } else { Format(szText, sizeof(szText), "%s %N.", szText, i); } bDisplayHint = true; } } } else if (iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON) { iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsClientObserver(i)) continue; iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue; iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget"); if (speclist_stealth[i] == true) continue; if (iTarget == iTargetUser) { if (IsPlayerVip(i) == true) { if (IsPlayerAdmin(i) == true) { Format(szText, sizeof(szText), "%s %N.", szText, i); } else { Format(szText, sizeof(szText), "%s %N.", szText, i); } } else { Format(szText, sizeof(szText), "%s %N. ", szText, i); } bDisplayHint = true; } } } if (bDisplayHint) { if (speclist_enabled[client] == true) { PrintHintText(client, "%s", szText); bDisplayHint = false; } } return Plugin_Continue; } void CreateHudHintTimer(int client) { HudHintTimers[client] = CreateTimer(UPDATE_INTERVAL, Timer_UpdateHudHint, client, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); } void KillHudHintTimer(int client) { if (HudHintTimers[client] != INVALID_HANDLE) { KillTimer(HudHintTimers[client]); HudHintTimers[client] = INVALID_HANDLE; } } bool IsPlayerAdmin(int client) { if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_UNBAN)) return true; return false; } bool IsPlayerVip(int client) { if (IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_CUSTOM1)) return true; return false; } stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true) { if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client))) { return false; } return true; }
查找差异