Add SourceTV_IsClientProxy native
See if a spectator is a SourceTV relay client.
This commit is contained in:
parent
61f59c5b9b
commit
00c6f56c69
@ -8,6 +8,7 @@ sourceFiles = [
|
|||||||
'extension.cpp',
|
'extension.cpp',
|
||||||
'natives.cpp',
|
'natives.cpp',
|
||||||
'forwards.cpp',
|
'forwards.cpp',
|
||||||
|
'hltvserverwrapper.cpp',
|
||||||
'hltvdirectorwrapper.cpp',
|
'hltvdirectorwrapper.cpp',
|
||||||
'hltvclientwrapper.cpp'
|
'hltvclientwrapper.cpp'
|
||||||
]
|
]
|
||||||
|
24
natives.cpp
24
natives.cpp
@ -623,6 +623,29 @@ static cell_t Native_IsClientConnected(IPluginContext *pContext, const cell_t *p
|
|||||||
return pClient->IsConnected();
|
return pClient->IsConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// native bool:SourceTV_IsClientProxy(client);
|
||||||
|
static cell_t Native_IsClientProxy(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
if (hltvserver == nullptr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cell_t client = params[1];
|
||||||
|
if (client < 1 || client > hltvserver->GetBaseServer()->GetClientCount())
|
||||||
|
{
|
||||||
|
pContext->ReportError("Invalid spectator client index %d.", client);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HLTVClientWrapper *pClient = hltvserver->GetClient(client);
|
||||||
|
if (!pClient->IsConnected())
|
||||||
|
{
|
||||||
|
pContext->ReportError("Client %d is not connected.", client);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pClient->BaseClient()->IsHLTV();
|
||||||
|
}
|
||||||
|
|
||||||
// native SourceTV_GetSpectatorName(client, String:name[], maxlen);
|
// native SourceTV_GetSpectatorName(client, String:name[], maxlen);
|
||||||
static cell_t Native_GetSpectatorName(IPluginContext *pContext, const cell_t *params)
|
static cell_t Native_GetSpectatorName(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
@ -756,6 +779,7 @@ const sp_nativeinfo_t sourcetv_natives[] =
|
|||||||
{ "SourceTV_GetSpectatorName", Native_GetSpectatorName },
|
{ "SourceTV_GetSpectatorName", Native_GetSpectatorName },
|
||||||
{ "SourceTV_GetSpectatorIP", Native_GetSpectatorIP },
|
{ "SourceTV_GetSpectatorIP", Native_GetSpectatorIP },
|
||||||
{ "SourceTV_GetSpectatorPassword", Native_GetSpectatorPassword },
|
{ "SourceTV_GetSpectatorPassword", Native_GetSpectatorPassword },
|
||||||
|
{ "SourceTV_IsClientProxy", Native_IsClientProxy },
|
||||||
{ "SourceTV_KickClient", Native_KickClient },
|
{ "SourceTV_KickClient", Native_KickClient },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -189,7 +189,7 @@ public Action:Cmd_Spectators(client, args)
|
|||||||
|
|
||||||
SourceTV_GetSpectatorName(i, sName, sizeof(sName));
|
SourceTV_GetSpectatorName(i, sName, sizeof(sName));
|
||||||
SourceTV_GetSpectatorIP(i, sIP, sizeof(sIP));
|
SourceTV_GetSpectatorIP(i, sIP, sizeof(sIP));
|
||||||
ReplyToCommand(client, "Client %d: %s - %s", i, sName, sIP);
|
ReplyToCommand(client, "Client %d%s: %s - %s", i, (SourceTV_IsClientProxy(i)?" (RELAY)":""), sName, sIP);
|
||||||
}
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
@ -332,6 +332,15 @@ native SourceTV_GetClientCount();
|
|||||||
*/
|
*/
|
||||||
native bool:SourceTV_IsClientConnected(client);
|
native bool:SourceTV_IsClientConnected(client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the spectator is a relay proxy.
|
||||||
|
*
|
||||||
|
* @param client The spectator client index.
|
||||||
|
* @return True if client is a proxy, false otherwise.
|
||||||
|
* @error Invalid client index.
|
||||||
|
*/
|
||||||
|
native bool:SourceTV_IsClientProxy(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a SourceTV spectator client.
|
* Get the name of a SourceTV spectator client.
|
||||||
*
|
*
|
||||||
@ -479,6 +488,7 @@ public __ext_stvmngr_SetNTVOptional()
|
|||||||
MarkNativeAsOptional("SourceTV_GetSpectatorName");
|
MarkNativeAsOptional("SourceTV_GetSpectatorName");
|
||||||
MarkNativeAsOptional("SourceTV_GetSpectatorIP");
|
MarkNativeAsOptional("SourceTV_GetSpectatorIP");
|
||||||
MarkNativeAsOptional("SourceTV_GetSpectatorPassword");
|
MarkNativeAsOptional("SourceTV_GetSpectatorPassword");
|
||||||
|
MarkNativeAsOptional("SourceTV_IsClientProxy");
|
||||||
MarkNativeAsOptional("SourceTV_KickClient");
|
MarkNativeAsOptional("SourceTV_KickClient");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user