core/smn_player.cpp
changeset 540 27a380082863
parent 518 52810a1a9620
child 591 86e97f3eda1f
     1.1 --- a/core/smn_player.cpp	Mon Feb 26 09:21:08 2007 +0000
     1.2 +++ b/core/smn_player.cpp	Tue Feb 27 03:32:14 2007 +0000
     1.3 @@ -345,6 +345,30 @@
     1.4  	return engine->GetPlayerUserId(pPlayer->GetEdict());
     1.5  }
     1.6  
     1.7 +static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	int client = params[1];
    1.10 +	int target = params[2];
    1.11 +
    1.12 +	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
    1.13 +	if (!pPlayer)
    1.14 +	{
    1.15 +		return pContext->ThrowNativeError("Player %d is not a valid client", client);
    1.16 +	} else if (!pPlayer->IsConnected()) {
    1.17 +		return pContext->ThrowNativeError("Player %d is not connected", client);
    1.18 +	}
    1.19 +
    1.20 +	CPlayer *pTarget = g_Players.GetPlayerByIndex(target);
    1.21 +	if (!pTarget)
    1.22 +	{
    1.23 +		return pContext->ThrowNativeError("Player %d is not a valid client", target);
    1.24 +	} else if (!pTarget->IsConnected()) {
    1.25 +		return pContext->ThrowNativeError("Player %d is not connected", target);
    1.26 +	}
    1.27 +
    1.28 +	return g_Admins.CanAdminTarget(pPlayer->GetAdminId(), pTarget->GetAdminId()) ? 1 : 0;
    1.29 +}
    1.30 +
    1.31  REGISTER_NATIVES(playernatives)
    1.32  {
    1.33  	{"GetMaxClients",			sm_GetMaxClients},
    1.34 @@ -364,6 +388,7 @@
    1.35  	{"SetUserFlagBits",			SetUserFlagBits},
    1.36  	{"GetUserFlagBits",			GetUserFlagBits},
    1.37  	{"GetClientUserId",			GetClientUserId},
    1.38 +	{"CanUserTarget",			CanUserTarget},
    1.39  	{NULL,						NULL}
    1.40  };
    1.41