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
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
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
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 , is better!
For any question, i'm here!