Você está desconectado.

Conecte-se e veja nossos conteúdos exclusivos!
 

  


E-mail System

Compartilhe
avatar
GOD Vitor
Administrador
Administrador

King Coin(s) King Coin(s) : 33
Reputação : 13015
Facebook : Facebook.com/Vitor.Eduardo.5567
OTServ Favorito : otPokémonImeprium
Meu Char : Zoom
Seção Favorita : Spriting
Eu sou : Scripter
Tópicos : 256
Data de Cadastro : 26/09/2015
Idade : 19
Localização : Florianópolis

E-mail System

Mensagem por GOD Vitor em 5/12/2015, 23:42

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


!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:
Spoiler:
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:
Spoiler:
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:
Spoiler:
<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:
Spoiler:
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 !!

Créditos:
KekezitoLHP - Por desenvolver o sistema.

    Data/hora atual: 24/8/2017, 07:45