[GUIDE] Code @mail (player) (msg.) + @Inbox & @deleteAll

Below is the code written in a format used by most of the coding language's, it is to avoid confusion and ease of read. Those who don't like it can scroll down and see the raw code.


Python:
# Player event: Join
Player event(Join) ->
    # Check if the %player%_Mail variable does not exist
    If variable NOT exists[(%player%_Mail)] ->
        Set variable(%player%_Mail = True) ->
        Send msg.("&aYou have been automatically registered for our Ingame mail service!&r @mail-help for more information.")

# Player event: Chat message
Player event(Chat msg.) ->
    Split text[Player msg.{Arr[%player%_msg]}] ->
    Get element[Index = 1, arr(%player%_msg), %player%_tempArg] ->
   
    # Check if %player%_tempArg equals @mail
    If variable equals[%player%_tempArg = @mail] ->
        Get element[Index = 2, arr(%player%_msg), %player%_tempArgReceiver-name] ->
       
        # Check if %player%_tempArgReceiver-name_Mail is 1
        If variable[(%player%_tempArgReceiver-name_Mail = 1)] ->
            Get element[Index = 3, arr(%player%_msg), %player%_tempArg-MAIL] ->
           
            # Combine Text
            Combine Text(%player%_tempArg-MAIL, "Add '&6%player% &8-> &7' at the start and then the mail '%player%_tempArg-MAIL'") ->
           
            # Array Insert element
            Arr. Insert element[%player%_tempArgReciever-name_INBOX, 1, %player%_tempArg-MAIL] ->
           
            # Send message
            Send msg.("&aMail was sent to %player%_tempArgReciever-name")
        ELSE
            Send msg.("&cThe player '%player%_tempArgReciever-name' does not exist in our database. This is likely due to the player never joining our game or having mail service disabled.")

    # Check if %player%_tempArg equals @Inbox
    If variable equals[(%player%_tempArg = @Inbox)] ->
        Get element(%player%_INBOX, %player%_Index) ->
       
        # Check if %player%_Index is not equal to 0
        If variable NOT equals(%player%_Index = 0) ->
            Call function(Iteration)
        ELSE
            Send msg.("&cYour Inbox is empty")

    # Check if %player%_tempArg equals @DeleteAll
    If variable equals[(%player%_tempArg = @DeleteAll)] ->
        Get element(%player%_INBOX, %player%_Index) ->
       
        # Check if %player%_Index is not equal to 0
        If variable NOT equals(%player%_Index = 0) ->
            Call function(Shredder)
            Send msg.("&cDeleting all mails...")
        ELSE
            Send msg.("&cYour Inbox is empty")

    # Check if %player%_tempArg equals @mail-help
    If variable equals(%player%_tempArg = @mail-help) ->
        Send msg.(
            "&6=== In-Game Mail Help ===",
            "&a@mail-help &8- Display this help message.",
            "&a/@mail send <player> <message> &8- Send a mail to another player.",
            "&a/@mail inbox &8- View your mailbox.",
            "&a/@mail deleteall &8- Delete all mails in your mailbox.",
            click the textbook in gui of send msg and set the spacing to new line.
        )

# Function: Shredder
Func.(Shredder) ->
    # Check if %player%_Index is more than 1
    If variable(%player%_Index MORE THAN 1) ->
        Delete element(%player%_INBOX, 1) ->
        Decrement(%player%_Index) ->
        Wait(1 tick) ->
        Call function(Shredder)

# Function: Iteration
Func.(Iteration) ->
    # Check if %player%_Index is more than 1
    If variable(%player%_Index MORE THAN 1) ->
        Get element(%player%_INBOX, 1, %player%_mailelement) ->
        Send msg.(%player%_mailelement) ->
        Decrement(%player%_Index) ->
        Wait(1 tick) ->
        Call function(Iteration)

You can send your own code snippet for some command you would like to add to this, I'm open for all the suggestions

TODO:
Add checks to see if a player exists
More commands like @mail-help
GUI
etc
 
Last edited:

Aalus

Big Bandar
Joined
May 20, 2023
Messages
455
Oh no @deefer ! Veddnt is going to beat our record of the most msgs. Gotta do something really cringe ASF grrr
 
Top