WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Check another players permissions (https://www.wowinterface.com/forums/showthread.php?t=57293)

Aeriez 07-15-19 11:54 PM

Check another players permissions
 
I'm trying to set permissions for certain broadcasts within an addon. C_GuildInfo.CanEditOfficerNote() identifies if the native user is able to edit officer notes. But is there a method/function that can determine if another player in your guild has those permissions? Or is GetGuildRosterInfo rankIndex 0 and 1 the best bet in that case? Have been reluctant to find another method.

Ketho 07-16-19 05:43 AM

Check https://wow.gamepedia.com/API_C_Guil...olGetRankFlags
Code:

C_GuildInfo.GuildControlGetRankFlags(rankOrder) == 12

Ketho 07-16-19 04:31 PM

ughh I meant
Code:

if C_GuildInfo.GuildControlGetRankFlags(rankOrder)[12] then
        -- do stuff
end


Aeriez 07-16-19 08:09 PM

Quote:

Originally Posted by Ketho (Post 332909)
ughh I meant
Code:

if C_GuildInfo.GuildControlGetRankFlags(rankOrder)[12] then
        -- do stuff
end


That actually just appears to give rank permissions. I already know Guild Master and Officer ranks have Officer Note permissions. That's implicit. I'm looking more for something that checks if X player has officer note permissions. Not if a specific rank has the permissions. But I suppose I could run multiple functions to determine what ranks grant permissions and then see if the player has that rank. Seems like an awefully round about way to do it though. Was hoping there'd be a DoesPlayerHaveOfficerPermissions("Player name/uuid") sort of thing :p

Ketho 07-16-19 10:03 PM

Quote:

Originally Posted by Aeriez (Post 332910)
That actually just appears to give rank permissions.


Just pointing you in the right direction. It's not that much of roundabout way

Lua Code:
  1. local members, ranks = {}, {}
  2.  
  3. local function GetPermissions()
  4.     for i = 1, GetNumGuildMembers() do
  5.         local name, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, _, guid = GetGuildRosterInfo(i)
  6.         members[guid] = rankIndex + 1
  7.     end
  8.     for i = 1, MAX_GUILDRANKS or 10 do
  9.         ranks[i] = C_GuildInfo.GuildControlGetRankFlags(i)
  10.     end
  11. end
  12.  
  13. -- /dump DoesPlayerHavePermissions("target", 12)
  14. function DoesPlayerHavePermissions(unit, flag)
  15.     if IsInGuild() then
  16.         if not next(members) then
  17.             GetPermissions()
  18.         end
  19.         local guid = UnitGUID(unit)
  20.         local member = ranks[members[guid]]
  21.         return member and member[flag]
  22.     end
  23. end

Modify it if you want it to check against names (GGRI includes realm) instead of guids


All times are GMT -6. The time now is 09:51 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI