-
Notifications
You must be signed in to change notification settings - Fork 13
Developers World
UncomplicatedCustomRoles has a really easy to use APIs to allow developers to work with the plugin.
This interface has every information that UCR needs to handle a custom role.
You can create a class that implements this interface (like MyIncredibleClass : ICustomRole
) or you can just create a new istance of the UncomplicatedCustomRoles.Elements.CustomRole
class.
public interface ICustomRole
{
public abstract int Id { get; set; }
public abstract string Name { get; set; }
public abstract string CustomInfo { get; set; }
public abstract int MaxPlayers { get; set; }
public abstract int MinPlayers { get; set; }
public abstract int SpawnChance { get; set; }
public abstract RoleTypeId Role { get; set; }
public abstract RoleTypeId RoleAppearance { get; set; }
public abstract List<RoleTypeId> CanReplaceRoles { get; set; }
public abstract float Health { get; set; }
public abstract float MaxHealth { get; set; }
public abstract float Ahp { get; set; }
public abstract float HumeShield { get; set; }
public abstract List<UCREffect>? Effects { get; set; }
public abstract bool InfiniteStamina { get; set; }
public abstract bool CanEscape { get; set; }
public abstract string? RoleAfterEscape { get; set; }
public abstract Vector3 Scale { get; set; }
public abstract string SpawnBroadcast { get; set; }
public abstract ushort SpawnBroadcastDuration { get; set; }
public abstract string SpawnHint { get; set; }
public abstract float SpawnHintDuration { get; set; }
public abstract List<ItemType> Inventory { get; set; }
public abstract List<uint> CustomItemsInventory { get; set; }
public abstract Dictionary<AmmoType, ushort> Ammo { get; set; }
public abstract SpawnLocationType Spawn { get; set; }
public abstract List<ZoneType> SpawnZones { get; set; }
public abstract List<RoomType> SpawnRooms { get; set; }
public abstract Vector3 SpawnPosition { get; set; }
public abstract Vector3 SpawnOffset { get; set; }
public abstract float DamageMultiplier { get; set; }
public abstract string? RequiredPermission { get; set; }
public abstract bool IgnoreSpawnSystem { get; set; }
}
The UncomplicatedCustomRoles.API.Features.CustomRole
is the helper class that allow you to handle the ICustomRoles
registered inside UCR.\
Note
If you don't want to have your custom role to spawn with the built-in UCR spawn system then you don't have to register it!
To handle players with Custom Roles we've created an extension to the Exiled.API.Features.Player
class.
You can see the code and the functions here.
Check if a player has a custom role and retrive it
if (player.TryGetCustomRole(out ICustomRole role))
{
Log.Info($"Player {player.Nickname} has a custom role!\nRole: {role.Id}");
}
else
{
// Nah the player does not have the custom role :(
}
Set a custom role for a player
player.SetCustomRole(ICustomRole role);
player.SetCustomRole(int roleId);
Check if a custom role is registered and try to retrive it
// We'll try the custom role with the Id 25
if (UncomplicatedCustomRoles.API.Features.CustomRole.TryGet(25, out ICustomRole role))
{
// Yeah the role exists!
}
else
{
// Nop
}
UncomplicatedCustomRoles is a free plugin developed by FoxWorn3365 and
DrAgenda.
Please consider Donatig 1$ if you found this plugin helpful