introduce ban talkaction with lengths hours or days

This commit is contained in:
ErikasKontenis 2020-12-12 14:10:21 +02:00
parent 6f375b69db
commit 9a1d328303

View File

@ -1,17 +1,35 @@
local banDays = 7 local banDays = 7
function onSay(player, words, param) function onSay(cid, words, param)
local player = Player(cid)
if not player:getGroup():getAccess() then if not player:getGroup():getAccess() then
return true return true
end end
local name = param local name = param
local reason = '' local reason = ''
local banInfo = ''
local separatorPos = param:find(',') local banTime = 0
if separatorPos ~= nil then local banMultiplier = 0
name = param:sub(0, separatorPos - 1) local params = param:split(',')
reason = string.trim(param:sub(separatorPos + 1)) if params ~= nil then
name = params[1]
reason = string.trim(params[2])
banInfo = string.trim(params[3])
print(banInfo)
end
if banInfo then
if banInfo:find('h') then
banTime = banInfo:sub(0, banInfo:find('h') - 1)
banMultiplier = 3600
elseif banInfo:find('d') then
banTime = banInfo:sub(0, banInfo:find('d') - 1)
banMultiplier = 86400
else
banTime = banDays
banMultiplier = 86400
end
banTime = banTime * banMultiplier
end end
local accountId = getAccountNumberByPlayerName(name) local accountId = getAccountNumberByPlayerName(name)
@ -26,8 +44,8 @@ function onSay(player, words, param)
end end
local timeNow = os.time() local timeNow = os.time()
db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" .. db:query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
accountId .. ", " .. db.escapeString(reason) .. ", " .. timeNow .. ", " .. timeNow + (banDays * 86400) .. ", " .. player:getGuid() .. ")") accountId .. ", " .. db.escapeString(reason) .. ", " .. timeNow .. ", " .. timeNow + banTime .. ", " .. player:getGuid() .. ")")
local target = Player(name) local target = Player(name)
if target ~= nil then if target ~= nil then