Conde2 0 #1 Posted October 19, 2009 (edited) -- Name: E-mail System -- Version: 1.3.9 -- Credits: Conde2 -- Tested: TFS 0.3.4(5) Crying Damson _________________________ Sobre: Este é um simples sistema de e-mails, que te possibilita mandar mensagens para todos os players, ate os offiline. Necessário criar uma pasta chama "email" dentro da pasta DATA OBS: NECESSITA DA LIB EXHAUSTION DO TFS !! Comandos: !deleteemail --- deleta o e-mail (TODOS OS EMAILS !!!) !checkemail --- mostrar seus e-mails um por pagina !sendemail name, menssage --- manda um e-mail para o nome definido com a menssagem definida !blockemail -- bloqueia sua caixa de e-mail, impossibilitando voce de receber e-mails (Precisa relogar) !unblockemail -- desbloqueia sua caixa de e-mail, possibilitando voce de receber e-mails (Precisa relogar) Código: Agora vamos ao que interessa... Abra a pasta data/talkactions/script e adicione isso em um arquivo lua chamado email.lua. Dentro desse arquivo adicione esse Script: EMAIL_BLOCK = 6364 EMAIL_ANTI_SPAWN = 15 EMAIL_MIN_MENSSAGE = 10 EMAIL_MAX_MENSSAGE = 100 EMAIL_STORAGE_ANTI_SPAWN = 6365 function onSay(cid, words, param) if words == "!sendemail" then if(param == "") then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param. Please use: !sendemail name, menssage") return TRUE end local t = string.explode(param, ",") if(not t[2]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No menssage specified.") return TRUE end if (getPlayerGUIDByName(t[1]) == 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not exist.") return TRUE end if (string.len(t[2]) <= EMAIL_MIN_MENSSAGE) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't send this menssage, because so short.") return TRUE end if (string.len(t[2]) > EMAIL_MAX_MENSSAGE) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't send this menssage, because so long.") return TRUE end local id = getPlayerIdByName(""..t[1].."") if (getDataBaseStorage(id,EMAIL_BLOCK) == 1) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, the player: " .. t[1] .. " has been blocked yours menssages.") return TRUE end if exhaustion.check(cid, EMAIL_STORAGE_ANTI_SPAWN) == TRUE then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please wait a ".. exhaustion.get(cid, EMAIL_STORAGE_ANTI_SPAWN) .." secondes to send other email.") return TRUE end local directory = "data//email//".. t[1] ..".txt" if onFile("exist", directory) == FALSE then onFile("create", directory, "BY: ".. getCreatureName(cid) .." [" .. os.date("%d/%m/%Y %H:%M:%S") .. "] ".. t[2] .."\n") doPlayerSendTextMessage(cid, 22, "You have send to ".. t[1] .." this menssage: " .. t[2] .. ".") exhaustion.make(cid, EMAIL_STORAGE_ANTI_SPAWN, EMAIL_ANTI_SPAWN) else onFile("update", directory, "BY: ".. getCreatureName(cid) .." [" .. os.date("%d/%m/%Y %H:%M:%S") .. "] ".. t[2] .."") doPlayerSendTextMessage(cid, 22, "You have send to ".. t[1] .." this menssage: " .. t[2] .. "") exhaustion.make(cid, EMAIL_STORAGE_ANTI_SPAWN, EMAIL_ANTI_SPAWN) end local target = getPlayerByNameWildcard(""..t[1].."") if(target == 0) then target = getCreatureByName(""..t[1].."") if(target == 0) then return TRUE end end local tmp = getCreaturePosition(target) if (isOnline(""..t[1].."") == TRUE) then addEvent(doSendAnimatedText, 1, tmp, "Menssage!", TEXTCOLOR_PURPLE) addEvent(doSendAnimatedText, 1000, tmp, "Menssage!", TEXTCOLOR_PURPLE) addEvent(doSendAnimatedText, 2000, tmp, "Menssage!", TEXTCOLOR_PURPLE) doPlayerSendTextMessage(target, 19, " A new menssage arrived, look your email box. (!checkemail)!!") end elseif words == "!checkemail" then local name = getCreatureName(cid) local directory = "data//email//".. name ..".txt" if onFile("exist", directory) == FALSE or onFile("load", directory) == nil then doPlayerSendTextMessage(cid, 22, "Sorry you don't have any menssage.") else for line in io.lines(directory) do doShowTextDialog(cid,7528, "You have menssages: \n \n ".. line .." \n \n \n For look the next menssage click in the button: OK") end end elseif words == "!deleteemail" then local name = getCreatureName(cid) local directory = "data//email//".. name ..".txt" if onFile("exist", directory) == TRUE and onFile("load", directory) ~= nil then onFile("delete", directory) onFile("erase", directory) doPlayerSendTextMessage(cid, 22, "Sucessful!! You have deleted all yours menssages !!") else doPlayerSendTextMessage(cid, 22, "Sorry you don't have any menssage to delete.") end elseif words == "!blockemail" then setPlayerStorageValue(cid, EMAIL_BLOCK, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You has been bloked your e-mail. Please relog to make effect.") elseif words == "!unblockemail" then setPlayerStorageValue(cid, EMAIL_BLOCK, 0) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You has been unbloked your e-mail. Please relog to make effect.") end end Agora vá em data/global.lua Ou em data/lib/data.lua e adicione isso na última linha: function isOnline(name) -- by mock local players = getOnlinePlayers() name = string.lower(name) for i, player in ipairs(players) do player = string.lower(player) if name == player then return TRUE end end return FALSE end function getDataBaseStorage(pid,value_id) -- by Conde2 local coisa = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. pid .." AND `key` ="..value_id..";") if coisa:getID() == -1 then return -1 else return coisa:getDataInt("value") end end function onFile(type, directory, content) -- by Conde2 local master = 0 if type == "create" then local file = io.open(directory, "w") master = file:write(content) file:close() elseif type == "erase" then local file = io.open(directory, "w+") master = file:write("") file:close() elseif type == "load" then local file = io.open(directory,"r") master = file:read() file:close() elseif type == "update" then local file = io.open(directory, "a+") master = file:write(content.."\n") file:close() elseif type == "return" then local file = io.open(directory, "a+") master = file:write(" "..content) file:close() elseif type == "delete" then os.remove(directory) elseif type == "exist" then file = io.open(directory) if file == nil then master = FALSE else master = TRUE end end return master end Tags: E finalmente vá para data/talkactions/talkactions.xml Abra ele com um bloco de notas e adicione isso: <talkaction words="!sendemail" event="script" value="email.lua"/> <talkaction words="!deleteemail" event="script" value="email.lua"/> <talkaction words="!checkemail" event="script" value="email.lua"/> <talkaction words="!blockemail" event="script" value="email.lua"/> <talkaction words="!unblockemail" event="script" value="email.lua"/> Configurando: Para configurar basta ir em data/talkactions/email.lua e editar isso: EMAIL_BLOCK = 6364 EMAIL_ANTI_SPAWN = 15 EMAIL_MIN_MENSSAGE = 10 EMAIL_MAX_MENSSAGE = 100 EMAIL_STORAGE_ANTI_SPAWN = 6365 # Storage value para bloquear / desbloquear o email. # O tempo que o player terá que esperar para mandar outra mensagem (Em segundos) # Quantas letras no mínimo a mensagem tem que ter para poder ser enviada. # Quantas letras no máximo deverá ter a menssagem. # Storage para definir o exausted !! NÃO AUTORIZO A POSTAGEM DESSE SCRIPT EM QUALQUER OUTRO FÓRUM SEM MINHA AUTORIZAÇÃO Edited January 24, 2011 by Black Ice Share this post Link to post
Gpwjhlkdcf 21 #2 Posted October 19, 2009 Tópico Aprovado e Movido para Scripting > Scripts Prontos > Exclusivos. Padrão de Qualidade: OK Esse merece exclusivo! Parabéns, um ótimo script! Share this post Link to post
Raphael Carnaúba 1 #3 Posted October 20, 2009 Huuum, interessante!! Tava pensando aqui, dá pra colocar aquela caixa de dialogo que quando vc abre a carta apareçe? daí ao invês de colocar !showemails, ele abre a carta e vê seus emails. Share this post Link to post
Conde2 0 #4 Posted October 20, 2009 @Raphael Carnaúba Mais ele já abre a caixa de dialogo XD Quando você digiata !checkemail ele abre aquela caixa e cada vez que ocê clica em OK vai pra proxima menssagem =D Você só não precisa clicar na carta... Mais aquela menssage box aparece. Share this post Link to post
Gutozo 0 #5 Posted October 20, 2009 Detalhe, ta o nome do Mock ali: function isOnline(name) -- by mock @Topic Eu estava precisando disso mesmo, pois no meu OT o meu system de E-mail está estragado. Obrigado. Gutozo//~~ Share this post Link to post
Mock 32 #6 Posted October 20, 2009 @Gutozo Se ta --by Mock, By Joao, by fulano 112469 quer dizer que a função foi feita por a pessoa que está no comentario. Share this post Link to post
xinxila 0 #7 Posted November 9, 2009 Aqui nao ta dando certo... eu mando assim: !sendemail Dark Killer, test12345 Sorry you can't send this menssage, because so short. Que que eu faço ?? Share this post Link to post
Mock 32 #8 Posted November 9, 2009 @xinxila a mensagem é muito pequena, screva uma maior ._. Share this post Link to post
MatheusGrilo 0 #9 Posted November 25, 2009 Aqui no meu deu erro ou fala q o player n existe qndo ele ta off ou nao faz nada ... Share this post Link to post
[ B a l i l l o ] 0 #10 Posted November 26, 2009 Aqui nao ta dando certo... eu mando assim: !sendemail Dark Killer, test12345 Sorry you can't send this menssage, because so short. Que que eu faço ?? IUHASDIAH ISHASIUDHAS IUDHASIU HQEHFAJFAEKA KAK ROP3K 4091I41093JKR109KT asudhasd foi engraçado, brincs. tct. ... -- topic A LOKA ta mara o system IUHASDUIHASDU inté Share this post Link to post
xXHiroshiXx 0 #11 Posted December 5, 2009 gostei mais ande eu axo a lib exaustion? Share this post Link to post
Conde2 0 #12 Posted December 5, 2009 @hiroshi2008 Se você usa TFS 0.3.5 já vem com ela ta na pasta LIB !! Se não usa baixe um tfs 0.3.5 e pegue da pasta LIB dele =D Share this post Link to post
Welkin Guide 0 #13 Posted December 19, 2009 Agora temos email em Otservers.. O que mais falta??!! Ótima idéia e script. Share this post Link to post
katjas 0 #14 Posted December 20, 2009 Gostei muito mas deu esse problema [20/12/2009 18:56:10] data/talkactions/scripts/email.lua:37: attempt to call global 'getPlayerIdByName' (a nil value) [20/12/2009 18:56:10] stack traceback: [20/12/2009 18:56:10] data/talkactions/scripts/email.lua:37: in function <data/talkactions/scripts/email.lua:7> como ageita isso? Share this post Link to post
webuge 0 #15 Posted December 21, 2009 katjas Você pulou essa parte: Agora vá em data/global.lua Ou em data/lib/data.lua e adicione isso na última linha: Tente refazer ela =D E ver se da certo. Share this post Link to post
Guizim Tibiano 0 #16 Posted December 25, 2009 otimo systen ;D funfa em tfs 0.3.6? Share this post Link to post
Conde2 0 #17 Posted December 25, 2009 @Guizim Tibiano Acredito que sim... Eu ainda não testei mais provavelmente sim. Se não funcionar é por alguma função que trocou de nome.... Share this post Link to post
ChristianXxT 0 #18 Posted December 25, 2009 HêhÊ script bom em vou por no meu server também. Share this post Link to post
Keztoker 0 #19 Posted December 26, 2009 Muito legal. Irei colocar no meu futuro servidor. K~~ Share this post Link to post
Markim Bozi 0 #20 Posted December 26, 2009 @Tópico, as mensagens so funcionam quando o player estiver online? Share this post Link to post