#include <sourcemod>
Handle g_hWS;
Function g_ptrReloadPlayerMeta;
public void OnPluginStart()
{
RegServerCmd("sm_reload_ws_player", CmdReloadWsPlayer);
}
public void OnAllPluginsLoaded()
{
// Сканируем плагин-лист в поисках WS.
Handle hIter = GetPluginIterator();
Handle hPlugin = null;
char szTitle[64];
do
{
hPlugin = ReadPlugin(hIter);
if (!GetPluginInfo(hPlugin, PlInfo_Name, szTitle, sizeof(szTitle)) || strcmp("Weapons & Knives", szTitle, false))
{
continue;
}
g_hWS = hPlugin;
break;
}
while (MorePlugins(hIter) && g_hWS == null);
CloseHandle(hIter);
if (!g_hWS)
{
SetFailState("Weapons & Knifes not found, nothing to do.");
return;
}
g_ptrReloadPlayerMeta = GetFunctionByName(g_hWS, "OnClientPostAdminCheck");
}
public Action CmdReloadWsPlayer(int iArgC)
{
if (g_hWS == null || g_ptrReloadPlayerMeta == INVALID_FUNCTION)
{
return Plugin_Continue;
}
char szAccountId[16];
GetCmdArg(1, szAccountId, sizeof(szAccountId));
int iAccountId = StringToInt(szAccountId);
for (int iClient = MaxClients; iClient != 0; --iClient)
{
if (!IsClientInGame(iClient) || !IsClientAuthorized(iClient))
{
continue;
}
if (iAccountId == GetSteamAccountID(iClient))
{
Call_StartFunction(g_hWS, g_ptrReloadPlayerMeta);
Call_PushCell(iClient);
Call_Finish();
PrintToServer("OK");
return Plugin_Handled;
}
}
PrintToServer("No player");
return Plugin_Handled;
}