added functions for target immunity testing

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40546
This commit is contained in:
David Anderson
2007-02-27 03:32:14 +00:00
parent 52de18813c
commit 09887584f4
4 changed files with 63 additions and 0 deletions
+6
View File
@@ -418,6 +418,11 @@ static cell_t FlagBitsToArray(IPluginContext *pContext, const cell_t *params)
}
}
static cell_t CanAdminTarget(IPluginContext *pContext, const cell_t *params)
{
return g_Admins.CanAdminTarget(params[1], params[2]) ? 1 : 0;
}
REGISTER_NATIVES(adminNatives)
{
{"DumpAdminCache", DumpAdminCache},
@@ -454,6 +459,7 @@ REGISTER_NATIVES(adminNatives)
{"FlagBitArrayToBits", FlagBitArrayToBits},
{"FlagArrayToBits", FlagArrayToBits},
{"FlagBitsToArray", FlagBitsToArray},
{"CanAdminTarget", CanAdminTarget},
/* -------------------------------------------------- */
{NULL, NULL},
};
+25
View File
@@ -345,6 +345,30 @@ static cell_t GetClientUserId(IPluginContext *pContext, const cell_t *params)
return engine->GetPlayerUserId(pPlayer->GetEdict());
}
static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
int target = params[2];
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return pContext->ThrowNativeError("Player %d is not a valid client", client);
} else if (!pPlayer->IsConnected()) {
return pContext->ThrowNativeError("Player %d is not connected", client);
}
CPlayer *pTarget = g_Players.GetPlayerByIndex(target);
if (!pTarget)
{
return pContext->ThrowNativeError("Player %d is not a valid client", target);
} else if (!pTarget->IsConnected()) {
return pContext->ThrowNativeError("Player %d is not connected", target);
}
return g_Admins.CanAdminTarget(pPlayer->GetAdminId(), pTarget->GetAdminId()) ? 1 : 0;
}
REGISTER_NATIVES(playernatives)
{
{"GetMaxClients", sm_GetMaxClients},
@@ -364,6 +388,7 @@ REGISTER_NATIVES(playernatives)
{"SetUserFlagBits", SetUserFlagBits},
{"GetUserFlagBits", GetUserFlagBits},
{"GetClientUserId", GetClientUserId},
{"CanUserTarget", CanUserTarget},
{NULL, NULL}
};