#ScpProximityChat Dev

28 messages · Page 1 of 1 (latest)

tropic stump
#
public class ScpChatHintPlugin : Plugin<Config>
{
    private CoroutineHandle _coroutineHandle;

    public override void OnEnabled()
    {
        Exiled.Events.Handlers.Player.Verified += OnPlayerVerified;
        Exiled.Events.Handlers.Player.Destroying += OnPlayerDestroying;

        _coroutineHandle = Timing.RunCoroutine(UpdateHintDisplay().CancelWith(this));
        base.OnEnabled();
    }

    public override void OnDisabled()
    {
        Exiled.Events.Handlers.Player.Verified -= OnPlayerVerified;
        Exiled.Events.Handlers.Player.Destroying -= OnPlayerDestroying;

        Timing.KillCoroutines(_coroutineHandle);
        base.OnDisabled();
    }

    private void OnPlayerVerified(VerifiedEventArgs ev)
    {
        if (ScpProximityChatAPI.IsScp(ev.Player))
        {
            ShowChatHint(ev.Player);
        }
    }

    private void OnPlayerDestroying(DestroyingEventArgs ev)
    {
        if (ScpProximityChatAPI.IsScp(ev.Player))
        {
            ev.Player.ClearBroadcasts();
        }
    }

    private IEnumerator<float> UpdateHintDisplay()
    {
        while (true)
        {
            foreach (Player player in Player.List)
            {
                if (ScpProximityChatAPI.IsScp(player))
                {
                    ShowChatHint(player);
                }
            }
            yield return Timing.WaitForSeconds(1f); 
        }
    }

    private void ShowChatHint(Player player)
    {
        string chatType = ScpProximityChatAPI.IsPlayerUsingProximityChat(player) ? "Proximity Chat" : "SCP Chat";
        player.ShowHint($"<b><color=#42f57b>{chatType}</color></b>", 1f); 
    }
}
west hatch
#

@tropic stump this is useless

#

player.Role.Team == Team.SCPs

tropic stump
west hatch
#

theres also RoleTypeId.GetTeam() == Team.SCPs

tropic stump
#

wait

west hatch
#

wait

#

nvm

#

player.IsScp

tropic stump
west hatch
#

dont have IsScp() at all

#

it is not needed

tropic stump
grizzled hound
#

making a way for scps not to appear on global chat and sound like actual people

#

maybe it was done through nwapi but i'm learning how to make plugins too.

#

Anyway. I'm not sure of any servers that use this, but do with this what you may will

#

:]

tropic stump
compact sun
#

is it working

tropic stump
compact sun