MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / CanAdminTarget

Method CanAdminTarget

core/logic/AdminCache.cpp:1494–1599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1492}
1493
1494bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
1495{
1496 /**
1497 * Zeroth, if the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
1498 * First, if the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
1499 */
1500
1501 if (id == INVALID_ADMIN_ID)
1502 {
1503 return false;
1504 }
1505
1506 if (target == INVALID_ADMIN_ID)
1507 {
1508 return true;
1509 }
1510
1511 if (id == target)
1512 {
1513 return true;
1514 }
1515
1516 AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id);
1517 if (!pUser || pUser->magic != USR_MAGIC_SET)
1518 {
1519 return false;
1520 }
1521
1522 AdminUser *pTarget = (AdminUser *)m_pMemory->GetAddress(target);
1523 if (!pTarget || pTarget->magic != USR_MAGIC_SET)
1524 {
1525 return false;
1526 }
1527
1528 /**
1529 * Second, if the targeting admin is root, targeting succeeds.
1530 */
1531 if (pUser->eflags & ADMFLAG_ROOT)
1532 {
1533 return true;
1534 }
1535
1536 /** Fourth, if the targeted admin is immune from targeting admin. */
1537 int mode = bridge->GetImmunityMode();
1538 switch (mode)
1539 {
1540 case 1:
1541 {
1542 if (pTarget->immunity_level > pUser->immunity_level)
1543 {
1544 return false;
1545 }
1546 break;
1547 }
1548 case 3:
1549 {
1550 /* If neither has any immunity, let this pass. */
1551 if (!pUser->immunity_level && !pTarget->immunity_level)

Callers 3

CanAdminTargetFunction · 0.80
CanUserTargetFunction · 0.80

Calls 1

GetAddressMethod · 0.45

Tested by

no test coverage detected