Implemented amb423 - Added IsClientObserver() native
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401007
This commit is contained in:
parent
3e88c91ad2
commit
aef5ba1d09
@ -18,7 +18,6 @@
|
|||||||
#include "HalfLife2.h"
|
#include "HalfLife2.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "ChatTriggers.h"
|
#include "ChatTriggers.h"
|
||||||
#include "GameConfigs.h"
|
|
||||||
#include <inetchannel.h>
|
#include <inetchannel.h>
|
||||||
#include <iclient.h>
|
#include <iclient.h>
|
||||||
|
|
||||||
@ -168,6 +167,27 @@ static cell_t sm_IsClientFakeClient(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return (pPlayer->IsFakeClient()) ? 1 : 0;
|
return (pPlayer->IsFakeClient()) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t IsClientObserver(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
int client = params[1];
|
||||||
|
|
||||||
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
|
if (!pPlayer)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
|
} else if (!pPlayer->IsInGame()) {
|
||||||
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
|
||||||
|
if (!pInfo)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("IPlayerInfo not supported by game");
|
||||||
|
}
|
||||||
|
|
||||||
|
return pInfo->IsObserver() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
int client = params[1];
|
int client = params[1];
|
||||||
@ -970,6 +990,7 @@ REGISTER_NATIVES(playernatives)
|
|||||||
{"IsFakeClient", sm_IsClientFakeClient},
|
{"IsFakeClient", sm_IsClientFakeClient},
|
||||||
{"IsPlayerInGame", sm_IsClientInGame}, /* Backwards compat shim */
|
{"IsPlayerInGame", sm_IsClientInGame}, /* Backwards compat shim */
|
||||||
{"IsClientInGame", sm_IsClientInGame},
|
{"IsClientInGame", sm_IsClientInGame},
|
||||||
|
{"IsClientObserver", IsClientObserver},
|
||||||
{"RemoveUserFlags", RemoveUserFlags},
|
{"RemoveUserFlags", RemoveUserFlags},
|
||||||
{"SetUserAdmin", SetUserAdmin},
|
{"SetUserAdmin", SetUserAdmin},
|
||||||
{"SetUserFlagBits", SetUserFlagBits},
|
{"SetUserFlagBits", SetUserFlagBits},
|
||||||
|
@ -187,6 +187,14 @@ native bool:IsClientAuthorized(client);
|
|||||||
*/
|
*/
|
||||||
native bool:IsFakeClient(client);
|
native bool:IsFakeClient(client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a certain player is an observer/spectator.
|
||||||
|
*
|
||||||
|
* @param client Player index.
|
||||||
|
* @return True if player is an obverser, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsClientObserver(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves values from client replicated keys.
|
* Retrieves values from client replicated keys.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user