[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:

veddnt

Active member
Joined
Jun 2, 2023
Messages
178
RAW CODE

Player event( Join) -> If variable NOT exists[ (%player%_Mail) -> Set variable( %player%_Mail = True) -> Send msg.(&aYou have been automatically registered to our Ingame mail service!&r @mail-help for more information.)

Player event( Chat msg.) -> Split text[ Player msg.{ Arr[%player%_msg]}] -> Get element[ Index = 1, arr(%player%_msg), %player%_tempArg] ->
If variable equals[ %player%_tempArg = @mail] -> Get element[ Index = 2, arr(%player%_msg),%player%_tempArgReciever-name] -> If variable[( %player%_tempArgReciever-name_Mail = 1) -> Get element[ Index = 3, arr(%player%_msg), %player%_tempArg-MAIL] -> Combine Text( %player%_tempArg-MAIL, Add "&6%player% &8-> &7 " at the start and then the mail "%player%_tempArg-MAIL") -> Arr. Insert element[ %player%_tempArgReciever-name_INBOX, 1 ,%player%_tempArg-MAIL] -> Send msg.( &aMail was sent to %player%_tempArgReciever-name)] ELSE Send msg.( &cThe player "%player%_tempArgReciever-name" does not exists in our database. This is likely due to the player has never joined our game or has mail service disabled.)]
If variable equals
[( %player%_tempArg = @Inbox), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Iteration) ELSE Send msg.( &cYour Inbox is empty)
If variable equals[( %player%_tempArg = @DeleteAll), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Shredder) -> Send msg.( &cDeleting all mails...) ELSE Send msg.( &cYour Inbox is empty)
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.", "&a2@mail deleteall &8- Delete all mails in your mailbox.", click the textbook in gui of send msg and set the spacing to new line.)

Func.( Shredder) -> If variable( %player%_Index MORE THAN 1) -> Delete element( %player%_INBOX, 1) -> Decrement( %player%_Index) -> wait( 1 tick) -> Call function( Shredder)

Func.( Iteration) -> 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)
 
Last edited:

DJMahirNationTV

Moder⁺ | Forum Team | YouTuber | Head SMM
Staff member
Forum Team
Moderator
Joined
May 6, 2023
Messages
77
Dude started coding irl 😂😂😂
Looks cool!
 

veddnt

Active member
Joined
Jun 2, 2023
Messages
178

UPDATE 0.1

+ Check to see if a player mail exists.
 

Ophelios

New member
Joined
Sep 3, 2023
Messages
9
I was gonna write it all, but not gonna lie it would be much easier if you could give the World ad.

I am also too lazy to read it all, but basically you want to give everyone an inbox array at the start and then Append Element each mail. You can use the "Chat Message == @mail -> Set Variable(%player%Sending_Mail = 1)-> If Variable(%player%Sending_mail == 1) -> Set Variable(%player%Message = Player's Message)" and work from there, rest is easy to do where you just do the whole process again but with %player%Sending_Mail_Target (the targeted person). Way two is by doing it all inside of a "%player%Mail_Processing" array for the default player. If you're doing this, don't forget to use "Select Object" and %selected%. After any of the two ways use @mail-read and get Array length, deduct 1 in a function that'll repeat itself with each process and send the said mail to the person. When the deducted variable reaches -1, the function will stop itself; just use the "If Variable => 1" code.

But again, ad please.
RAW CODE

Player event( Join) -> If variable NOT exists[ (%player%_Mail) -> Set variable( %player%_Mail = True) -> Send msg.(&aYou have been automatically registered to our Ingame mail service!&r @mail-help for more information.)

Player event( Chat msg.) -> Split text[ Player msg.{ Arr[%player%_msg]}] -> Get element[ Index = 1, arr(%player%_msg), %player%_tempArg] ->
If variable equals[ %player%_tempArg = @mail] -> Get element[ Index = 2, arr(%player%_msg),%player%_tempArgReciever-name] -> If variable[( %player%_tempArgReciever-name_Mail = 1) -> Get element[ Index = 3, arr(%player%_msg), %player%_tempArg-MAIL] -> Combine Text( %player%_tempArg-MAIL, Add "&6%player% &8-> &7 " at the start and then the mail "%player%_tempArg-MAIL") -> Arr. Insert element[ %player%_tempArgReciever-name_INBOX, 1 ,%player%_tempArg-MAIL] -> Send msg.( &aMail was sent to %player%_tempArgReciever-name)] ELSE Send msg.( &cThe player "%player%_tempArgReciever-name" does not exists in our database. This is likely due to the player has never joined our game or has mail service disabled.)]
If variable equals
[( %player%_tempArg = @Inbox), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Iteration) ELSE Send msg.( &cYour Inbox is empty)
If variable equals[( %player%_tempArg = @DeleteAll), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Shredder) -> Send msg.( &cDeleting all mails...) ELSE Send msg.( &cYour Inbox is empty)

Func.( Shredder) -> If variable( %player%_Index MORE THAN 1) -> Delete element( %player%_INBOX, 1) -> Decrement( %player%_Index) -> wait( 1 tick) -> Call function( Shredder)

Func.( Iteration) -> 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)
 

veddnt

Active member
Joined
Jun 2, 2023
Messages
178
I was gonna write it all, but not gonna lie it would be much easier if you could give the World ad.

I am also too lazy to read it all, but basically you want to give everyone an inbox array at the start and then Append Element each mail. You can use the "Chat Message == @mail -> Set Variable(%player%Sending_Mail = 1)-> If Variable(%player%Sending_mail == 1) -> Set Variable(%player%Message = Player's Message)" and work from there, rest is easy to do where you just do the whole process again but with %player%Sending_Mail_Target (the targeted person). Way two is by doing it all inside of a "%player%Mail_Processing" array for the default player. If you're doing this, don't forget to use "Select Object" and %selected%. After any of the two ways use @mail-read and get Array length, deduct 1 in a function that'll repeat itself with each process and send the said mail to the person. When the deducted variable reaches -1, the function will stop itself; just use the "If Variable => 1" code.

But again, ad please.
this was supposed to be a guide... Meh anyways use split text
 

Sky_kspop

New member
Joined
May 20, 2023
Messages
24
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 for the reader. 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%_tempArgReciever-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")



# 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
bro this is really useless, why we have to code /mail in game
 

mugheera1122

Member
Joined
May 21, 2023
Messages
85
RAW CODE

Player event( Join) -> If variable NOT exists[ (%player%_Mail) -> Set variable( %player%_Mail = True) -> Send msg.(&aYou have been automatically registered to our Ingame mail service!&r @mail-help for more information.)

Player event( Chat msg.) -> Split text[ Player msg.{ Arr[%player%_msg]}] -> Get element[ Index = 1, arr(%player%_msg), %player%_tempArg] ->
If variable equals[ %player%_tempArg = @mail] -> Get element[ Index = 2, arr(%player%_msg),%player%_tempArgReciever-name] -> If variable[( %player%_tempArgReciever-name_Mail = 1) -> Get element[ Index = 3, arr(%player%_msg), %player%_tempArg-MAIL] -> Combine Text( %player%_tempArg-MAIL, Add "&6%player% &8-> &7 " at the start and then the mail "%player%_tempArg-MAIL") -> Arr. Insert element[ %player%_tempArgReciever-name_INBOX, 1 ,%player%_tempArg-MAIL] -> Send msg.( &aMail was sent to %player%_tempArgReciever-name)] ELSE Send msg.( &cThe player "%player%_tempArgReciever-name" does not exists in our database. This is likely due to the player has never joined our game or has mail service disabled.)]
If variable equals
[( %player%_tempArg = @Inbox), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Iteration) ELSE Send msg.( &cYour Inbox is empty)
If variable equals[( %player%_tempArg = @DeleteAll), Get element( %player%_INBOX, %player%_Index) -> If variable NOT equals( %player%_Index = 0) -> Call function( Shredder) -> Send msg.( &cDeleting all mails...) ELSE Send msg.( &cYour Inbox is empty)

Func.( Shredder) -> If variable( %player%_Index MORE THAN 1) -> Delete element( %player%_INBOX, 1) -> Decrement( %player%_Index) -> wait( 1 tick) -> Call function( Shredder)

Func.( Iteration) -> 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)
can you please upload youtube tutorials of your coding
 

veddnt

Active member
Joined
Jun 2, 2023
Messages
178

UPDATE 0.2

+ @mail-help

I am planning to add a gui based mail system just like "/mailgui"
 
Top