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; }
尋找差異