Emojis in chat, chat pings and stuff - i wanna make my code more efficient / shorter

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

JamiePlaysMinecraft

New Member
Apr 5, 2024
8
0
1
15
I have this code and i want to make it more efficient / shorter
yeah-

Code:
function extraCheck(p: player):
    {@Emojis} = true:
        {_p} has permission "{@Perm}.admin":
            replace all ":skull:" with "☠" in {m}
            replace all "<3" with "{@NoPermColor}❤&f" in {m}
            replace all ":sob:" with "☹" in {m}
            replace all ":sad:" with "☹" in {m}
            replace all ":(" with "☹" in {m}
            replace all "D:" with "☹" in {m}
            replace all ":happy:" with "☺" in {m}
            replace all ":D" with "☺" in {m}
    {@Pings} = true:
        clear {pinged::%{_p}%'s uuid::*}
        {_p} has permission "{@Perm}.pinggroups":
            {m} contains "@dead" or "@dead kids" or "@deadkids":
                add "Dead Players" to {pinged::%{_p}%'s uuid::*}
                replace all "@dead" with "&b@dead&f" in {m}
                replace all "&b@dead&fkids" with "&b@deadkids&f" in {m}
                replace all "&b@dead&f kids" with "&b@dead kids&f" in {m}
                play sound "{@Sound1}" to {dead::*}
                send actionbar "&bYou were pinged by %{_p}%" to {dead::*}
            {m} contains "@alive" or "@alive kids" or "@alivekids":
                add "Alive Players" to {pinged::%{_p}%'s uuid::*}
                replace all "@alive" with "&b@alive&f" in {m}
                replace all "&b@alive&fkids" with "&b@alivekids&f" in {m}
                replace all "&b@alive&f kids" with "&b@alive kids&f" in {m}
                play sound "{@Sound1}" to {alive::*}
                send actionbar "&bYou were pinged by %{_p}%" to {alive::*}
            {m} contains "@all" or "@everyone" or "@kids":
                clear {pinged::%{_p}%'s uuid::*}
                add "Everyone" to {pinged::%{_p}%'s uuid::*}
                replace all "@all" with "&b@all&f" in {m}
                replace all "@everyone" with "&b@everyone&f" in {m}
                replace all "@kids" with "&b@kids&f" in {m}
                play sound "{@Sound1}" to all players
                send actionbar "&bYou were pinged by %{_p}%" to all players
        {_p} has permission "{@Perm}.pingplayer":
            loop all players:
                if loop-player does not have permission "{@Perm}.pingbypass":
                    {m} contains loop-player's display name:
                        replace all loop-player's display name with "&b@%loop-player's display name%&f" in {m}
                        add loop-player to {pinged::%{_p}%'s uuid::*}
                    replace all "@&b@%loop-player's display name%" with "&b@%loop-player's display name%" in {m}
            size of {pinged::%{_p}%'s uuid::*} > 0:
                send actionbar "&bPinged %{pinged::%{_p}%'s uuid::*}%!" to {_p}
 
I mean you can make the emoji section shorter by doing like
Code:
replace all ":(", "D:", and ":sad:" with "☹" in {m}
Also I feel like {m} should be a local variable and then your function returns {_m} at the end