1.1 --- a/core/smn_player.cpp Thu Sep 18 18:42:13 2008 +1200
1.2 +++ b/core/smn_player.cpp Tue Sep 23 01:17:15 2008 -0500
1.3 @@ -1467,6 +1467,90 @@
1.4 }
1.5 }
1.6
1.7 +static cell_t FormatActivitySource(IPluginContext *pContext, const cell_t *params)
1.8 +{
1.9 + int value;
1.10 + int client;
1.11 + int target;
1.12 + CPlayer *pTarget;
1.13 + AdminId aidTarget;
1.14 + const char *identity[2] = {"Console", "ADMIN"};
1.15 +
1.16 + client = params[1];
1.17 + target = params[2];
1.18 +
1.19 + if ((pTarget = g_Players.GetPlayerByIndex(target)) == NULL)
1.20 + {
1.21 + return pContext->ThrowNativeError("Invalid client index %d", target);
1.22 + }
1.23 + if (!pTarget->IsConnected())
1.24 + {
1.25 + return pContext->ThrowNativeError("Client %d not connected", target);
1.26 + }
1.27 +
1.28 + value = sm_show_activity.GetInt();
1.29 +
1.30 + if (client != 0)
1.31 + {
1.32 + CPlayer *pPlayer;
1.33 +
1.34 + if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL)
1.35 + {
1.36 + return pContext->ThrowNativeError("Invalid client index %d", client);
1.37 + }
1.38 + if (!pPlayer->IsConnected())
1.39 + {
1.40 + return pContext->ThrowNativeError("Client %d not connected", client);
1.41 + }
1.42 +
1.43 + identity[0] = pPlayer->GetName();
1.44 +
1.45 + AdminId id = pPlayer->GetAdminId();
1.46 + if (id == INVALID_ADMIN_ID
1.47 + || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
1.48 + {
1.49 + identity[1] = "PLAYER";
1.50 + }
1.51 + }
1.52 +
1.53 + int mode = 1;
1.54 + bool bShowActivity = false;
1.55 +
1.56 + if ((aidTarget = pTarget->GetAdminId()) == INVALID_ADMIN_ID
1.57 + || !g_Admins.GetAdminFlag(aidTarget, Admin_Generic, Access_Effective))
1.58 + {
1.59 + /* Treat this as a normal user */
1.60 + if ((value & 1) || (value & 2))
1.61 + {
1.62 + if ((value & 2) || (target == client))
1.63 + {
1.64 + mode = 0;
1.65 + }
1.66 + bShowActivity = true;
1.67 + }
1.68 + }
1.69 + else
1.70 + {
1.71 + /* Treat this as an admin user */
1.72 + bool is_root = g_Admins.GetAdminFlag(aidTarget, Admin_Root, Access_Effective);
1.73 + if ((value & 4)
1.74 + || (value & 8)
1.75 + || ((value & 16) && is_root))
1.76 + {
1.77 + if ((value & 8) || ((value & 16) && is_root) || (target == client))
1.78 + {
1.79 + mode = 0;
1.80 + }
1.81 + bShowActivity = true;
1.82 + }
1.83 + }
1.84 +
1.85 + /* Otherwise, send it back to the script. */
1.86 + pContext->StringToLocalUTF8(params[3], params[4], identity[mode], NULL);
1.87 +
1.88 + return bShowActivity ? 1 : 0;
1.89 +}
1.90 +
1.91 REGISTER_NATIVES(playernatives)
1.92 {
1.93 {"AddUserFlags", AddUserFlags},
1.94 @@ -1519,6 +1603,7 @@
1.95 {"NotifyPostAdminCheck", NotifyPostAdminCheck},
1.96 {"IsClientInKickQueue", IsClientInKickQueue},
1.97 {"ProcessTargetString", ProcessTargetString},
1.98 + {"FormatActivitySource", FormatActivitySource},
1.99 {NULL, NULL}
1.100 };
1.101