[RELEASE]Mail on Metin2!

10/17/2011 19:22 gabss#1
Today i relese one of my favorites scripts.
It's a mail system (like all the other mmorpg) written in lua.

Script for writing
Code:
divisore = "New Message"
directory = "shared_data/locale/english/quest/object/"
function invia_lettera ( nick, nome, corpo )
    fp,err = io.open( directory.."mail/"..nome..".txt" )
    if err then
        io.output ( directory.."mail/"..nome..".txt" )
        io.write ( "*******Sender*******\n")
        io.write ( "****** "..nick.." ******")
        io.write ( corpo )
        io.write ( "\n************************")
        io.close()
    else
        io.close(fp)
        fhs = io.open ( directory.."mail/"..nome..".txt" , "a" )
        fhs:write( "\n"..divisore.."\n" )
        fhs:write ( "*******Sender*******\n")
        fhs:write( "****** "..nick.." ******" )
        fhs:write( corpo )
        fhs:write ( "\n************************")
        io.close(fhs)
    end
end --function

    local nome
    local corpo_lettera = ""
    say_title ( "Postino" )
    say ( "Vuoi inviare una lettera?" )
    local scelta = select ( "Si" , "No" )
    if scelta == 2 then
    else
        say_title ( "Postman" )
        say ( "Enter the recipient's nickname!" )
        say ( "Remember to pay attention to upper and lower case" )
        nome = tostring(input ())
        if nome == "" then
            say ( "......." )
        else
            local contatore = 0
            say_title ( "Postman" )
            say ( "Write the letter's body" )
            while ( true ) do
                contatore = contatore + 1
                corpo_lettera = corpo_lettera.."\n"..tostring(input())
                say ( "Need other space?" )
                local scelta1 = select ( "Yes!" , "No, thanks!" )
                if scelta1 == 2 then
                    break
                end
                if contatore == 11 then
                    say_title ( "Postman" )
                    say_reward ( "Last available line!" )
                elseif contatore >= 12 then
                    break
                end
            end
                local oink = pc.get_name()
                invia_lettera ( oink, nome, corpo_lettera )
                say_title ( "Postman" )
                say ( "Your email has been sent successfully!" )
                say ( "Thanks!" )
                say ( "" )
        end
    end
Script for reading

Code:
divisore = "New Message"
directory = "shared_data/locale/english/quest/object/"
fp,err=io.open(directory.."mail/"..pc.get_name()..".txt")
if not err then
    a=0  --linee del messaggio
    for line in io.lines(directory.."mail/"..pc.get_name()..".txt") do
        a = a+ 1
        if line == divisore then
            a = a - 1
            break
            end
    end
    say ( "You received a messages" )
    say ( "want you read?" )
    say ( "I remember you that once read, the messge will be deleted" )
    local scelta = select ( "Read!" , "No!" )
    if scelta == 2 then return
    else
    for b=0, a-1 do
            say ( fp:read() )
    end
    end
    stringa = ""
    local contatorey = 0
    while true do
        local ci = fp:read()
            if ci == nil then
                break
            elseif (ci == divisore) and contatorey == 0 then
            else
                contatorey = contatorey+1
                stringa = stringa..ci.."\n"
            end
    end
    if stringa == "" then
        os.remove(directory.."mail/"..pc.get_name()..".txt")
    else
    io.close(fp)
    fhs = io.open (directory.."mail/"..pc.get_name()..".txt" , "w" )
    fhs:write(stringa)
    fhs:close()
    end
else
    say_title ( "Postman" )
    say ( "At the moment there are no mails for you!" )
end
Script letter with message count

Code:
divisore = "New Message"
directory="shared_data/locale/english/quest/object/"
fp,err=io.open(directory.."mail/"..pc.get_name()..".txt")
if not err then
    local a=1  --linee del messaggio
    for line in io.lines(directory.."mail/"..pc.get_name()..".txt") do
        if line == divisore then
            a = a + 1
        end
    end
    if a == 1 then
    send_letter ( "Do you have a mail!" )
    else
    send_letter ( "Do you have "..tostring(a).." mails!" )
    end
    io.close(fp)
end
Configuration

At the beginning of the three scripts, there are two variables to configure:

-directory: Is your directory of "object", start from the shared folder of the games

-divisore: Is a magic word that is used to split multiple messages. Invent a phrase or a word enough imaginative, that users do not ever write in their mail.

You also need to create a folder called "mail", in object.

How Work

The script writes and reads the txt file named with the nickname of the recipient, the text file will be placed in the folder "mail" that you have created. These files contain all the messages that receives precisely the user (the script, thanks to "divisore", enables the reception of multiple messages).
If there are more messages, the script read a message at a time, once you read a message it is deleted from the txt ... if it does not contain more message, the file is deleted automaticity.
Of course, thanks to the files saved on the server...we can send messages to anyone even if offline or from another kingdom.
The writer has available up to 12 lines.
In this script the sending is free and requires no object or limitation of any kind, it is not difficult to add a check and I know that you know it.

This time I had to write much more than other guides, so I apologize for my bad english (helped by google <. <).
I hope you are able to understand something.
If someone can translate into german, i add the translation there. (thank you).
If someone know the italian and would translate from [Only registered and activated users can see links. Click Here To Register...], is better!

For any question, i'm here!
10/17/2011 19:24 .Fail´#2
N1!
10/17/2011 19:26 plechito#3
Good! Thanks :)
10/17/2011 19:31 xCPx#4
:D was sagt man dazu :D

Tja RealFreak,jetzt musst du ja keine Angst mehr haben,dass ich dein Offline Pn System release :D
10/17/2011 19:39 .Nagato#5
Fucking nice!
10/17/2011 20:17 xCPx#6
Quote:
Originally Posted by DaRealFreak View Post
Hab netmal eines xD
Weißte ist mir ansich sowieso scheiß egal, wird sowieso bald public wie man alle Clienten entpackt, hasts wohl ein paar zu viele gegeben, wird gerade sowieso überall weitergegeben xD
Kenn inzwischen 20-30 Leute damit.

Trotzdem ist es mir sowas von waynetrain

Aber probier mal an Dateien wie soundarranger.exe zu kommen, deine Methode wird da nicht klappen^^

Dazu weiß es Ymir inzwischen auch und wird wahrscheinlich was dagegen unternehmen^^

B2T:
Nais xD
ijemand hat mal zu mir gesagt,dass du das celestia offline pn system geschrieben hast :D
das hab ich mit nem araber zsm nachgecoded :D

ich hab die soundarranger.exe :D

Und das alles entpack ding weiß ich wie man fixxt ^^
Danke dafür an Dre4m^^
10/17/2011 20:51 IgorGlock#7
That's like a FlyFF :)

Es ist ja wie bei FlyFF :)
10/17/2011 21:53 Dr. Dorian#8
kann vll mal jemand ein screen reinstellen wie das IG aussieht
wär echt nett
10/17/2011 22:35 Lord Elinoy#9
Nice...
Thx given...

#Edit: 400 Post :D
10/18/2011 11:37 .Restince#10
Sowas ist nice wenigtest gibt es nich ein paar Leute die was gutes Releasen und nicht son müll der seit 1nem Jahr public ist :D

#Thx given
10/18/2011 11:50 BackBlack1#11
Wo fügt man diese Scripts denn ein?
10/18/2011 13:04 ƬheGame#12
Das hat er unten geschrieben :)
10/18/2011 14:25 gabss#13
This is an example of how-to install: [Only registered and activated users can see links. Click Here To Register...]

here i've changed the directory. I have not tested because it is just an example (but should work), for any problem let me know but in english please because i don't understand german ç_ç
10/18/2011 14:37 ƬheGame#14
I can translate it for u :) just send me a pm
10/18/2011 18:30 Tofus#15
I made it much more easier without .txt-files. ;)