Critico
Sexy
- Joined
- Mar 25, 2010
- Messages
- 370
- Reaction score
- 176
Tested on server's 9.6+
OBS:
open talkaction.xml and remove these commands(if have):
/ban
/unban
/baninfo
to avoid conflicts
----------------------- installation -------------------------
execute this query in your db
--------------------------------------- Using Scripts --------------------------------------------
Data > talkactions > script
bansystem.lua
talkactions.xml
------------------------
Data > Creaturescript > script
BanLogin.lua
creaturescript.xml
--------------------------------
Data > lib
BanLib.lua
--------------------------------------- Or Using Mods --------------------------------------------
Paste Mods
BanCommand.xml
OBS:
open talkaction.xml and remove these commands(if have):
/ban
/unban
/baninfo
to avoid conflicts
----------------------- installation -------------------------
execute this query in your db
Code:
CREATE TABLE ban_table (
id INTEGER NOT NULL,
account INTEGER NOT NULL,
added INTEGER NOT NULL,
expires INTEGER NOT NULL,
admin_id INTEGER NOT NULL
DEFAULT 0,
comment TEXT NOT NULL,
PRIMARY KEY ( id )
);
--------------------------------------- Using Scripts --------------------------------------------
Data > talkactions > script
bansystem.lua
Lua:
function onSay(cid, words, param)
if words == "/unban" then
if not param or param == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "enter a valid name.") return true
end
local param = param:lower()
local player = getPlayerGUIDByName(param)
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player does not exist.") return true
elseif not isAccountBan(getAccountIdByName(param)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That player or account is not banished or deleted.") return true
end
doRemoveBanAccount(getAccountIdByName(param))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param.." has unbanned successfully.")
elseif words == "/ban" then
local t = string.explode(string.lower(param), ",")
if not t[1] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true
end
local player = getPlayerGUIDByName(t[1])
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") return true
elseif isAccountBan(getAccountIdByName(t[1])) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player is already banished.") return true
end
local hours,comment = not tonumber(t[2]) and 24 or tonumber(t[2]),not t[3] and "No Reason" or t[3]
doBroadcastMessage(t[1].." was banned by "..getCreatureName(cid)..": "..comment)
doBanirAccount(getAccountIdByName(t[1]), os.time() + hours*3600, getCreatureName(cid), comment)
if getPlayerByNameWildcard(t[1]) then
doRemoveCreature(getPlayerByNameWildcard(t[1]))
end
elseif words == "/baninfo" then
if not param or param == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "enter a valid name.") return true
end
local param = param:lower()
local player = getPlayerGUIDByName(param)
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player does not exist.") return true
elseif not isAccountBan(getAccountIdByName(param)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That player or account is not banished or deleted.") return true
end
local acc = getAccountIdByName(param)
local baninfo = getBanAccInfo(acc)
doPlayerPopupFYI(cid, "Account has been banished at:\n"..os.date("%d %b %Y",baninfo[1])..".\n\nfor the following reason:\n"..baninfo[2]..".\n\nBanned By: "..baninfo[3].."\n\nYour banishment will be lifted at:\n"..os.date("%d %b %Y %X",baninfo[1])..".")
end
return true
end
talkactions.xml
Code:
<talkaction log="yes" words="/unban;/ban;/baninfo" access="4" event="script" value="bansystem.lua"/>
------------------------
Data > Creaturescript > script
BanLogin.lua
Lua:
function onLogin(cid)
local MyAccount = getPlayerAccountId(cid)
if isAccountBan(MyAccount) then
local baninfo = getBanAccInfo(MyAccount)
doPlayerPopupFYI(cid, "You account has been banished at:\n"..os.date("%d %b %Y",baninfo[1])..".\n\nfor the following reason:\n"..baninfo[2]..".\n\nYour banishment will be lifted at:\n"..os.date("%d %b %Y %X",baninfo[1])..".")
addEvent(doRemoveCreature, 1500, cid)
end
return true
end
creaturescript.xml
Code:
<event type="login" name="BanLogin" event="script" value="BanLogin.lua"/>
--------------------------------
Data > lib
BanLib.lua
Lua:
function doBanirAccount(accid, time, admin_id, comment)
return db.executeQuery("INSERT INTO `ban_table` (`account`, `added`, `expires`, `admin_id`, `comment`) VALUES ('".. accid .."', '".. os.time() .."', '".. time .."', '".. admin_id .."', '".. comment .."');")
end
function getBanAccInfo(acc)
local info,qry = {},db.getResult("SELECT `expires`, `comment`, `admin_id` FROM `ban_table` WHERE `account` = "..acc)
if (qry:getID() ~= -1) then
info = {qry:getDataInt("expires"), qry:getDataString("comment"), qry:getDataString("admin_id")}
end
return #info > 0 and info or false
end
function isAccountBan(acc)
local qry = db.getResult("SELECT `expires` FROM `ban_table` WHERE `account` = "..acc)
if (qry:getID() ~= -1) then
if os.time() < qry:getDataInt("expires") then
return true
end
if os.time() >= qry:getDataInt("expires") then
db.executeQuery("DELETE FROM `ban_table` WHERE`account` = "..acc)
end
end
return false
end
function doRemoveBanAccount(acc)
return db.executeQuery("DELETE FROM `ban_table` WHERE `account` = "..acc)
end
--------------------------------------- Or Using Mods --------------------------------------------
Paste Mods
BanCommand.xml
Lua:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Ban Command" version="1.0" author="Vodkart" contact="none.com" enabled="yes">
<config name="ban_func"><![CDATA[
function doBanirAccount(accid, time, admin_id, comment)
return db.executeQuery("INSERT INTO `ban_table` (`account`, `added`, `expires`, `admin_id`, `comment`) VALUES ('".. accid .."', '".. os.time() .."', '".. time .."', '".. admin_id .."', '".. comment .."');")
end
function getBanAccInfo(acc)
local info,qry = {},db.getResult("SELECT `expires`, `comment`, `admin_id` FROM `ban_table` WHERE `account` = "..acc)
if (qry:getID() ~= -1) then
info = {qry:getDataInt("expires"), qry:getDataString("comment"), qry:getDataString("admin_id")}
end
return #info > 0 and info or false
end
function isAccountBan(acc)
local qry = db.getResult("SELECT `expires` FROM `ban_table` WHERE `account` = "..acc)
if (qry:getID() ~= -1) then
if os.time() < qry:getDataInt("expires") then
return true
end
if os.time() >= qry:getDataInt("expires") then
db.executeQuery("DELETE FROM `ban_table` WHERE`account` = "..acc)
end
end
return false
end
function doRemoveBanAccount(acc)
return db.executeQuery("DELETE FROM `ban_table` WHERE `account` = "..acc)
end
]]></config>
<event type="login" name="BanLogin" event="script"><![CDATA[
domodlib('ban_func')
function onLogin(cid)
local MyAccount = getPlayerAccountId(cid)
if isAccountBan(MyAccount) then
local baninfo = getBanAccInfo(MyAccount)
doPlayerPopupFYI(cid, "You account has been banished at:\n"..os.date("%d %b %Y",baninfo[1])..".\n\nfor the following reason:\n"..baninfo[2]..".\n\nYour banishment will be lifted at:\n"..os.date("%d %b %Y %X",baninfo[1])..".")
addEvent(doRemoveCreature, 1500, cid)
end
return true
end]]></event>
<talkaction words="/unban;/ban;/baninfo" access="4" event="buffer"><![CDATA[
domodlib('ban_func')
if words == "/unban" then
if not param or param == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "enter a valid name.") return true
end
local param = param:lower()
local player = getPlayerGUIDByName(param)
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player does not exist.") return true
elseif not isAccountBan(getAccountIdByName(param)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That player or account is not banished or deleted.") return true
end
doRemoveBanAccount(getAccountIdByName(param))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param.." has unbanned successfully.")
elseif words == "/ban" then
local t = string.explode(string.lower(param), ",")
if not t[1] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true
end
local player = getPlayerGUIDByName(t[1])
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") return true
elseif isAccountBan(getAccountIdByName(t[1])) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player is already banished.") return true
end
local hours,comment = not tonumber(t[2]) and 24 or tonumber(t[2]),not t[3] and "No Reason" or t[3]
doBroadcastMessage(t[1].." was banned by "..getCreatureName(cid)..": "..comment)
doBanirAccount(getAccountIdByName(t[1]), os.time() + hours*3600, getCreatureName(cid), comment)
if getPlayerByNameWildcard(t[1]) then
doRemoveCreature(getPlayerByNameWildcard(t[1]))
end
elseif words == "/baninfo" then
if not param or param == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "enter a valid name.") return true
end
local param = param:lower()
local player = getPlayerGUIDByName(param)
if not player then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "this player does not exist.") return true
elseif not isAccountBan(getAccountIdByName(param)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That player or account is not banished or deleted.") return true
end
local acc = getAccountIdByName(param)
local baninfo = getBanAccInfo(acc)
doPlayerPopupFYI(cid, "Account has been banished at:\n"..os.date("%d %b %Y",baninfo[1])..".\n\nfor the following reason:\n"..baninfo[2]..".\n\nBanned By: "..baninfo[3].."\n\nYour banishment will be lifted at:\n"..os.date("%d %b %Y %X",baninfo[1])..".")
end
return true
]]></talkaction>
</mod>