1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Writing out custom value from array

Discussion in 'DarkRP Modding Questions & Help' started by [TXG] Church, Oct 13, 2016.

  1. [TXG] Church

    [TXG] Church New Member

    So I've got an array like this:
    Code (Text):

    -- ULX Groups
    AdminGroups={
         ["admin"]="Admin",
         ["superadmin"]="Super Admin",
         ["headadmin"]="Head Admin",
    }
     
    and my for loop is

    Code (Text):

    if LocalPlayer():GetUserGroup() !="user" then
         for key,value in ipairs(AdminRanks) do
              if LocalPlayer():GetUserGroup() == value then
                   draw.DrawText(TRANSLATEDRANK,"CloseCaption_Bold",105,ScrH()-115,Color(255,255,255,25))-- Draw Rank
              end
         end
    end
     
    how can I adjust the loop to display the 'translated rank'. By that I mean instead of superadmin, it displays the value its equal to, 'Super Admin'.
    Ex: will display "Head Admin" instead of headadmin if the player is the rank
     
  2. Reverse

    Reverse Member

    Code (Text):
    local groups = {}
    groups["admin"] = "Admin"
    groups["superadmin"] = "Super Admin"
    groups["headadmin"] = "Head Admin"

    -- function( ply ) return groups[ ply:GetUserGroup() ] or ply:GetUserGroup() end }

    -- the above SHOULD return "Super Admin" if they're superadmin, so I guess you can do

    TRANSLATEDRANK = function( ply ) return groups[ ply:GetUserGroup() ] or ply:GetUserGroup() end }
    Test it by throwing print(TRANSLATEDRANK) somewhere.
     

Share This Page