mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-05-24 12:04:28 +02:00
introduce ban talkaction with lengths hours or days
This commit is contained in:
parent
6f375b69db
commit
9a1d328303
@ -1,17 +1,35 @@
|
||||
local banDays = 7
|
||||
|
||||
function onSay(player, words, param)
|
||||
function onSay(cid, words, param)
|
||||
local player = Player(cid)
|
||||
if not player:getGroup():getAccess() then
|
||||
return true
|
||||
end
|
||||
|
||||
local name = param
|
||||
local reason = ''
|
||||
|
||||
local separatorPos = param:find(',')
|
||||
if separatorPos ~= nil then
|
||||
name = param:sub(0, separatorPos - 1)
|
||||
reason = string.trim(param:sub(separatorPos + 1))
|
||||
local banInfo = ''
|
||||
local banTime = 0
|
||||
local banMultiplier = 0
|
||||
local params = param:split(',')
|
||||
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
|
||||
|
||||
local accountId = getAccountNumberByPlayerName(name)
|
||||
@ -26,8 +44,8 @@ function onSay(player, words, param)
|
||||
end
|
||||
|
||||
local timeNow = os.time()
|
||||
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() .. ")")
|
||||
db:query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
|
||||
accountId .. ", " .. db.escapeString(reason) .. ", " .. timeNow .. ", " .. timeNow + banTime .. ", " .. player:getGuid() .. ")")
|
||||
|
||||
local target = Player(name)
|
||||
if target ~= nil then
|
||||
|
Loading…
x
Reference in New Issue
Block a user