Ir para conteúdo
Entre para seguir isso  
Conde2

Email System v1.3.9

Recommended Posts

Conde2    0
Conde2

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

Editado por Black Ice

Compartilhar este post


Link para o post
Gpwjhlkdcf    21
Gpwjhlkdcf

Tópico Aprovado e Movido para Scripting > Scripts Prontos > Exclusivos.

 

Padrão de Qualidade: OK

 

Esse merece exclusivo! Parabéns, um ótimo script!

Compartilhar este post


Link para o post
Raphael Carnaúba    1
Raphael Carnaúba

Huuum, interessante!!

 

Tava pensando aqui, dá pra colocar aquela caixa de dialogo que quando vc abre a carta apareçe? :P daí ao invês de colocar !showemails, ele abre a carta e vê seus emails.

Compartilhar este post


Link para o post
Conde2    0
Conde2

@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.

Compartilhar este post


Link para o post
Gutozo    0
Gutozo

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//~~

Compartilhar este post


Link para o post
Mock    32
Mock

@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.

Compartilhar este post


Link para o post
xinxila    0
xinxila

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 ??

Compartilhar este post


Link para o post
Mock    32
Mock

@xinxila

a mensagem é muito pequena, screva uma maior ._.

Compartilhar este post


Link para o post
MatheusGrilo    0
MatheusGrilo

Aqui no meu deu erro ou fala q o player n existe qndo ele ta off ou nao faz nada ...

Compartilhar este post


Link para o post
[ B a l i l l o ]    0
[ B a l i l l o ]
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é

Compartilhar este post


Link para o post
xXHiroshiXx    0
xXHiroshiXx

gostei mais ande eu axo a lib exaustion?

Compartilhar este post


Link para o post
Conde2    0
Conde2

@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

Compartilhar este post


Link para o post
Welkin Guide    0
Welkin Guide

Agora temos email em Otservers..

O que mais falta??!!

Ótima idéia e script.

Compartilhar este post


Link para o post
katjas    0
katjas

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?

Compartilhar este post


Link para o post
webuge    0
webuge

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.

Compartilhar este post


Link para o post
Guizim Tibiano    0
Guizim Tibiano

otimo systen ;D funfa em tfs 0.3.6?

Compartilhar este post


Link para o post
Conde2    0
Conde2

@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....

Compartilhar este post


Link para o post
ChristianXxT    0
ChristianXxT

HêhÊ script bom em vou por no meu server também.

Compartilhar este post


Link para o post
Keztoker    0
Keztoker

Muito legal.

Irei colocar no meu futuro servidor.

:)

 

K~~

Compartilhar este post


Link para o post
Markim Bozi    0
Markim Bozi

@Tópico, as mensagens so funcionam quando o player estiver online?

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×