core/smn_player.cpp
changeset 1273 9afc766f8e9c
parent 1231 17badaf66ce4
child 1330 ab94316bb52b
     1.1 --- a/core/smn_player.cpp	Wed Aug 08 15:08:01 2007 +0000
     1.2 +++ b/core/smn_player.cpp	Wed Aug 08 16:22:51 2007 +0000
     1.3 @@ -1020,6 +1020,11 @@
     1.4  	char buffer[256];
     1.5  	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
     1.6  
     1.7 +	if (pContext->GetContext()->n_err != SP_ERROR_NONE)
     1.8 +	{
     1.9 +		return 0;
    1.10 +	}
    1.11 +
    1.12  	pClient->Disconnect("%s", buffer);
    1.13  
    1.14  	return 1;
    1.15 @@ -1048,6 +1053,45 @@
    1.16  	return 1;
    1.17  }
    1.18  
    1.19 +static cell_t RunAdminCacheChecks(IPluginContext *pContext, const cell_t *params)
    1.20 +{
    1.21 +	int client = params[1];
    1.22 +
    1.23 +	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
    1.24 +	if (!pPlayer)
    1.25 +	{
    1.26 +		return pContext->ThrowNativeError("Client index %d is invalid", client);
    1.27 +	} else if (!pPlayer->IsInGame()) {
    1.28 +		return pContext->ThrowNativeError("Client %d is not in game", client);
    1.29 +	} else if (!pPlayer->IsAuthorized()) {
    1.30 +		return pContext->ThrowNativeError("Client %d is not authorized", client);
    1.31 +	}
    1.32 +
    1.33 +	AdminId id = pPlayer->GetAdminId();
    1.34 +	pPlayer->DoBasicAdminChecks();
    1.35 +
    1.36 +	return (id != pPlayer->GetAdminId()) ? 1 : 0;
    1.37 +}
    1.38 +
    1.39 +static cell_t NotifyPostAdminCheck(IPluginContext *pContext, const cell_t *params)
    1.40 +{
    1.41 +	int client = params[1];
    1.42 +
    1.43 +	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
    1.44 +	if (!pPlayer)
    1.45 +	{
    1.46 +		return pContext->ThrowNativeError("Client index %d is invalid", client);
    1.47 +	} else if (!pPlayer->IsInGame()) {
    1.48 +		return pContext->ThrowNativeError("Client %d is not in game", client);
    1.49 +	} else if (!pPlayer->IsAuthorized()) {
    1.50 +		return pContext->ThrowNativeError("Client %d is not authorized", client);
    1.51 +	}
    1.52 +
    1.53 +	pPlayer->NotifyPostAdminChecks();
    1.54 +
    1.55 +	return 1;
    1.56 +}
    1.57 +
    1.58  REGISTER_NATIVES(playernatives)
    1.59  {
    1.60  	{"AddUserFlags",			AddUserFlags},
    1.61 @@ -1095,5 +1139,7 @@
    1.62  	{"ShowActivity",			ShowActivity},
    1.63  	{"ShowActivityEx",			ShowActivityEx},
    1.64  	{"KickClient",				KickClient},
    1.65 +	{"RunAdminCacheChecks",		RunAdminCacheChecks},
    1.66 +	{"NotifyPostAdminCheck",	NotifyPostAdminCheck},
    1.67  	{NULL,						NULL}
    1.68  };