CA
sistema

Banimento System 1.0

Por caotic, 12 de fev. de 2013 em Mods, funções e outros

banimento system
sistema de banimento
ban para 9.0
banimento
ban
otserv
tibia
script
5.0 (1)
3
1.6k
caoticC
12 de fevereiro de 2013 às 13:29

Venho trazer a versão do 1.0 do banimento system

Segue o link:

http://www.xtibia.co...to-system-beta/

O script foi todo reformulado.

 

O player fala /ban(nome do player,dias de ban,porque ele foi banido,["true" para banir o ip])

E o player e kikado e depois quando ele tentar logar aparece a mensagem de banimento.

O player também podera ver a lista de banidos dizendo /bans.

 

 

Vá na sua database e execute os seguintes comandos:

 

CREATE TABLE "ban"
(
"player" INT NOT NULL,
"ip" INT NOT NULL,
"time" INT NOT NULL,
`coment` text
)

 

Vá em lib e crie um arquivo lua chamado de ban e coloque isto:

 

function setBanTime(cid, time, coment, ip)
db.executeQuery("INSERT INTO `ban` VALUES (".. getPlayerGUID(cid) ..", ".. ip ..", ".. os.time() + time*36000 ..", '".. coment .."')")
end
function getPlayerBans(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` = ".. getPlayerGUID(cid) ..";")
if ban:getID() == -1 then
return false
end
local time = ban:getDataInt("time") > os.time() and ban:getDataInt("time") < 100+os.time()
return time and false or true
end
function getPlayerComent(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` = ".. getPlayerGUID(cid) ..";")
return ban:getDataString("coment")
end
function getPlayerTimeBan(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` = ".. getPlayerGUID(cid) ..";")
return ban:getDataInt("time")  - os.time()
end
function getPlayerIpBan(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` ORDER BY `time`")
if ban:getID() == -1 then
return false
end
while true do
local ips = ban:getDataInt("ip")
if getPlayerIp(cid) == ips then
return true
end
if not ban:next() then
return false
end
end
end
function doShowTextBans(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` ORDER BY `time`")
str = "Players Banidos:\n\n"
if ban:getID() == -1 then
doShowTextDialog(cid, 1387, "Não existe nenhum player Banido")
return true
end
while true do
local name = ban:getDataInt("player")
local player = getPlayerNameByGUID(name)
local time = ban:getDataInt("time")  - os.time()
str = str .. player .. " - Banido por "..math.floor((time/36000)).." \n\n"
if not ban:next() then
doShowTextDialog(cid, 1397, str)
break
end
end
end

 

Vá em talkactions e crie um arquivo lua chamado de ban e coloque isto:

 

 

function onSay(cid, words, param, channel)
local t = string.explode(param, ",")
if param == " " or param == "" or not param or isNumeric(param) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Coloque o nome do player dizendo /ban(nome do player,dias de ban,por que ele foi banido)")
end
if t[2] == " " or t[2] == "" or not t[2] then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Coloque os dias do player dizendo /ban(nome do player,dias de ban,por que ele foi banido)")
end
if t[3] == " " or t[3] == "" or not t[3] then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Coloque o comentario do banimento dizendo /ban(nome do player,dias de ban,comentario)")
end
local player =  getPlayerByNameWildcard(t[1], false)
if not player then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player "..t[1].." não existe")
end
setBanTime(player,  t[2], t[3], t[4] == "true" and getPlayerIp(player) or 0)
doRemoveCreature(player)
return true
end

 

Continuando em talkactions crie um arquivo lua chamado de bans e coloque isto:

 

function onSay(cid, words, param, channel)
doShowTextBans(cid)
return true
end

 

Agora vá em talkactions.xml e coloque estas tags:

 

 

 

<talkaction words="/ban" event="script" value="ban.lua"/>
<talkaction words="/bans" event="script" value="bans.lua"/>

 

 

 

Agora vá em creaturescripts e crie um arquivo lua chamado de ban e coloque isto:

 

function onLogin(cid)
if getPlayerBans(cid) then
local time = math.floor(getPlayerTimeBan(cid)/36000)
doPlayerPopupFYI(cid, "Você esta banido por "..getPlayerComent(cid).." durante "..time.." dias")
return addEvent(doRemoveCreature, 180, cid)
end
if getPlayerIpBan(cid) then
doPlayerPopupFYI(cid, "Seu ip esta banido")
return addEvent(doRemoveCreature, 180, cid)
end
return true
end

 

Agora vá em login.lua e registre o evento colocando isto antes do ultimo return:

 registerCreatureEvent(cid, "ban")

 

Coloque esta tag em talkactions.xml

 

 

<event type="login" name="ban" register = "1" event="script" value="ban.lua"/>

 

 

Editado Fevereiro 12 por caotic

guidark21G
12 de fevereiro de 2013 às 13:38

Muito bom caotic, otimo sistema ^^

3 meses depois...
Victor8V
12 de maio de 2013 às 16:00

Olá, só não entendi uma coisa. Ban por ip? Como faz?

 

Eu li o script, só achei o get ip ban...

 

Mas a função pra dar ban ip não vi.

 

Na talkactions tem o true.

Mas não chama na função.

 

 

 

function getPlayerIpBan(cid)
local ban = db.getResult("SELECT * FROM `ban` WHERE `player` ORDER BY `time`")
if ban:getID() == -1 then
return false
end

 

 

 

 

Ah, e a query, se vc quiser, pode substituir por essa:

 

CREATE TABLE `ban`
(
    `player` INT NOT NULL,
    `ip` INT NOT NULL,
    `time` INT NOT NULL,
    `coment` text
)

Acho que dara menos problemas.

Editado Maio 12 por Victor8