#How to get information the custom keycard?

7 messages · Page 1 of 1 (latest)

scenic sleet
#

Hi! I'm creating a plugin for creating user roles. I need information about the user's keycard: access levels, name, color, etc. How can I get this information?
I know there's this code for creating a custom card.

 public static KeycardItem? CreateCustomCard(ItemType itemType, Player targetPlayer, params object[] args)
 {
     if (targetPlayer == null)
     {
         return null;
     }

     if (!itemType.TryGetTemplate<InventorySystem.Items.Keycards.KeycardItem>(out var item))
     {
         throw new ArgumentException("Template for itemType not found");
     }

     if (!item.Customizable)
     {
         return null;
     }

     int num = 0;
     DetailBase[] details = item.Details;
     for (int i = 0; i < details.Length; i++)
     {
         if (details[i] is ICustomizableDetail customizableDetail)
         {
             customizableDetail.SetArguments(new ArraySegment<object>(args, num, customizableDetail.CustomizablePropertiesAmount));
             num += customizableDetail.CustomizablePropertiesAmount;
         }
     }

     return (KeycardItem)targetPlayer.AddItem(itemType);
 }
jolly aspen
#

I’d suggest saving the keycards data in a dictionary with its serial whenever you create a keycard, you can get the permissions from the dictionary in CustomPermsDetail, but don’t know how to get the other keycard data from the item instance. If you use EXILED you can just safely cast the EXILED wrapper to stuff like CustomKeycardItem or INameTagKeycard depending on what you need, then just get the values from the wrappers

solemn umbra
clear furnace
#

You can avoid the saving-in-a-dictionary nonsense if you're working with items and not pickups

clear furnace
solemn umbra
#

Ye i wish it didn't have static stuff in places

clear furnace
#

I really hate how SL prevents us from easily accessing data on different objects
I mean if plugin devs hate it, I can only imagine what it's like to actually work in that codebase