код:
-- Put your Lua herGBan = GBan or {}
GBan=GBan or {}
GBan.Config = GBan.Config or {}
GBan.Config.banned_pos = Vector(-1480.577026, 2490.292236, 136.031250) -- координаты изменять тут
GBan.Config.banned_model = 'models/player/zombie_soldier.mdl'
GBan.Config.banned_maxspeed = 180
GBan.Config.max_seconds = 10000000000000000000
local META = FindMetaTable('Player')
function META:IsGBan()
return self:GetNWBool('GBan')
end
local function mf(t)
return math.floor(t)
end
if SERVER then
local times = {
mi = 1,
h = 60,
d = 1440,
w = 10080,
mo = 43200,
}
local function firtloadtable(Max)
local time = ''
local mo = mf(Max / times['mo'])
if mo ~= 0 then
time = time .. mo .. 'mo '
Max = Max - times['mo'] * mo
end
local w = mf(Max / times['w'])
if w ~= 0 then
time = time .. w .. 'w '
Max = Max - times['w'] * w
end
local d = mf(Max / times['d'])
if d ~= 0 then
time = time .. d .. 'd '
Max = Max - times['d'] * d
end
local h = mf(Max / times['h'])
if h ~= 0 then
time = time .. h .. 'h '
Max = Max - times['h'] * h
end
local mi = mf(Max / times['mi'])
if mi ~= 0 then
time = time .. mi .. 'mi '
end
return time
end
local function TimeRew(t)
local time = t
local s = 0
local h = 'None'
if t == '0' then return 0 end
for k, t in string.gmatch(time, '(%d+)(%a+)') do
if times[t] then
s = s + k * times[t:lower()]
h = 'yes'
else
continue
end
end
if h == 'None' then return false end
return s
end
local function TimeCheck(Group, Time)
if sam.ranks.get_ban_limit(Group) == 0 or sam.ranks.get_ban_limit(Group) + 1 >= Time + 1 then return true end
return false
end
-- sql.Query('INSERT INTO gban( SteamID, Time, Date, Reason, Judge,IDEALAdmin ) VALUES ' .. values)
local msg = [[
Вы на всегда забанены на %s
-------------------------------------
Дата бана: %s
Админ: %s
Причина: %s
-------------------------------------
]]
local function PermaBan(ply, adm, Reason)
local nick_admin = adm and adm:Name() or 'CONSOLE'
local steamid_admin = adm and adm:SteamID() or 'CONSOLE'
local Ideal = adm and string.format('%s(%s)', adm:Name(), adm:SteamID()) or 'CONSOLE'
if IsValid(ply) then
ply:Kick(string.format(msg, GetHostName(), os.time(), adm, Reason))
local values = Format('(%s, %i, %i, %s, %s,%s', sql.SQLStr(ply:SteamID()), 0, os.time(), sql.SQLStr(Reason), sql.SQLStr(nick_admin), sql.SQLStr(Ideal))
print(values)
sql.Query('INSERT INTO gban( SteamID, Time, Date, Reason, Judge,IDEALAdmin ) VALUES ' .. values)
else
local values = Format('(%s, %i, %i, %s, %s,%s', sql.SQLStr(ply), 0, os.time(), sql.SQLStr(Reason), sql.SQLStr(nick_admin), sql.SQLStr(Ideal))
print(values)
sql.Query('INSERT INTO gban( SteamID, Time, Date, Reason, Judge,IDEALAdmin ) VALUES ' .. values)
end
end
util.AddNetworkString('gban_send_ply')
sql.Query('CREATE TABLE IF NOT EXISTS gban( SteamID TEXT PRIMARY KEY, Time NUMBER, Date NUMBER, Reason TEXT, Judge TEXT,IDEALAdmin TEXT )')
hook.Add("CheckPassword", "PermaCheck", function(steamID64)
local steam = util.SteamIDFrom64(steamID64)
local data
sql.QueryValue('SELECT * FROM gban WHERE SteamID=' .. steam)
if not data then return end
if data.Time ~= 0 then return end
local admin = data.IDEALAdmin
local date = data.Date
local reason = data.Reason
return false, string.format(msg, GetHostName(), date, admin, reason)
end)
function GBan.GiveBanPlayer(ePly, eAdmin, sReason, nSeconds)
if not IsValid(ePly) or not ePly:IsPlayer() then
print('[GBan] GiveBanPlayer ERROR #01')
return
end
local is_gban = ePly:IsGBan()
if is_gban then
print('[GBan] GiveBanPlayer ERROR #02')
return
end
nSeconds = TimeRew(nSeconds)
if not nSeconds then return eAdmin:ChatPrint('Некорректное время!') end
if not sReason or not isstring(sReason) then
print('[GBan] GiveBanPlayer WARNING #01')
sReason = 'Причина не указана'
end
if IsValid(eAdmin) then
if not TimeCheck(eAdmin:sam_getrank(), nSeconds) then
eAdmin:ChatPrint('Вы указали: ' .. firtloadtable(nSeconds))
eAdmin:ChatPrint('Ваше максимальное время: ' .. firtloadtable(sam.ranks.get_ban_limit(eAdmin:sam_getrank())))
return
end
end
if nSeconds == 0 then
if IsValid(eAdmin) then
if sam.ranks.get_ban_limit(eAdmin:sam_getrank()) == 0 and sam.ranks.get_immunity(ePly:sam_getrank()) < sam.ranks.get_immunity(eAdmin:sam_getrank()) then
PermaBan(sSteamID, eAdmin, sReason)
return
end
else
PermaBan(sSteamID, "Server(CONSOLE)", sReason)
return
end
print('[GBan] GiveBanPlayer WARNING #04')
eAdmin:ChatPrint('У вас нет доступа к перме!')
-- nSeconds = 1
return
end
-- nSeconds = math.floor(nSeconds)
-- print(nSeconds)
-- Action
if IsValid(eAdmin) then
if sam.ranks.get_immunity(ePly:sam_getrank()) > sam.ranks.get_immunity(eAdmin:sam_getrank()) then
local T = string.format("Вы не можете забанить Администратора рангом выше.")
eAdmin:ChatPrint(T)
local T = string.format("Администратор %s хотел выдать Вам бан по причине: %s на %s .", nick_admin, sReason, firtloadtable(nSeconds))
ePly:ChatPrint(T)
return
end
end
local min = nSeconds * 60
ePly:changeTeam(TEAM_BANNED, true)
ePly:SetNWBool('GBan', true)
ePly:SetNWInt('GBanTime', nSeconds)
if ePly:InVehicle() then
ply:ExitVehicle()
end
ePly:Spawn()
ePly:StripWeapons()
ePly:StripAmmo()
local nick_admin = eAdmin and eAdmin:Nick() or 'CONSOLE'
local steamid_admin = eAdmin and "(" ..eAdmin:SteamID().. ")" or 'CONSOLE'
for _, player in ipairs(player.GetAll()) do
player:ChatPrint(Color(0, 225, 255) .. nick_admin .. steamid_admin .. ' забанил ' .. ePly:Nick() .. '(' .. ePly:SteamID() .. ')' .. ' на ' .. firtloadtable(nSeconds) .. 'по причине: ' .. sReason)
end
timer.Create('GBanPlayer' .. ePly:SteamID(), min, 1, function()
GBan.RemoveBanPlayerOffline(ePly:SteamID())
end)
local txt = string.format("%s(%s)", eAdmin:Name(), eAdmin:SteamID())
net.Start('gban_send_ply')
net.WriteBool(true)
net.WriteUInt(min, 31)
net.WriteString(IsValid(eAdmin) and txt or "CONSOLE(Server)")
net.WriteString(sReason)
net.Send(ePly)
local Ideal = eAdmin and string.format('%s(%s)', eAdmin:Name(), eAdmin:SteamID()) or 'CONSOLE'
local values = Format('(%s, %i, %i, %s, %s,%s)', sql.SQLStr(ePly:SteamID()), min, os.time(), sql.SQLStr(sReason), sql.SQLStr(nick_admin), sql.SQLStr(Ideal))
print(values)
sql.Query('INSERT INTO gban( SteamID, Time, Date, Reason, Judge, IDEALAdmin) VALUES ' .. values)
print('[GBan] Player ' .. ePly:SteamID() .. ' has banned on ' .. firtloadtable(nSeconds))
end
function GBan.GiveBanPlayerOffline(sSteamID, eAdmin, nSeconds, sReason)
if not sSteamID then
print('[GBan] GiveBanPlayerOffline ERROR #03')
return
end
local ply = player.GetBySteamID(sSteamID)
if ply and IsValid(ply) then
GBan.GiveBanPlayer(ply, eAdmin, sReason, nSeconds)
return
end
nSeconds = TimeRew(nSeconds)
if not nSeconds then return eAdmin:ChatPrint('Некорректное время!') end
if IsValid(eAdmin) then
if not TimeCheck(eAdmin:sam_getrank(), nSeconds) then
eAdmin:ChatPrint('Ваше максимальное время: ' .. firtloadtable(sam.ranks.get_ban_limit(eAdmin:sam_getrank())))
return
end
end
if nSeconds == 0 then
if IsValid(eAdmin) then
if sam.ranks.get_ban_limit(eAdmin:sam_getrank()) == 0 and sam.ranks.get_immunity(ePly:sam_getrank()) < sam.ranks.get_immunity(eAdmin:sam_getrank()) then
PermaBan(sSteamID, eAdmin, sReason)
return
end
else
PermaBan(sSteamID, "Server(CONSOLE)", sReason)
return
end
print('[GBan] GiveBanPlayer WARNING #04')
eAdmin:ChatPrint('У вас нет доступа к перме!')
-- nSeconds = 1
return
end
-- nSeconds = math.floor(nSeconds)
if IsValid(eAdmin) then
local T = sql.SQLStr(sSteamID)
local T2 = sql.SQLStr(sReason)
print(T)
print(T2)
local data = sql.Query("SELECT * FROM sam_players WHERE steamid = '" .. T .. "';")
if not data then return end
if sam.ranks.get_immunity(data.rank) > sam.ranks.get_immunity(eAdmin:sam_getrank()) then return end
end
local judge = eAdmin and eAdmin:Nick() or 'CONSOLE'
local Ideal = eAdmin and string.format('%s(%s)', eAdmin:Name(), eAdmin:SteamID()) or 'CONSOLE'
local values = Format('(%s, %i, %i, %s, %s, %s)', sql.SQLStr(sSteamID), nSeconds * 60, os.time(), sql.SQLStr(sReason), sql.SQLStr(judge), sql.SQLStr(Ideal))
sql.Query('INSERT INTO gban( SteamID, Time, Date, Reason, Judge,IDEALAdmin ) VALUES ' .. values)
print('[GBan] Player ' .. sSteamID .. ' has banned on ' .. nSeconds .. ' sec!')
end
function GBan.RemoveBanPlayer(ePly, eAdmin)
local is_gban = ePly:IsGBan()
if not is_gban then
print('[GBan] RemoveBanPlayer ERROR #04')
return
end
ePly:SetNWBool('GBan', false)
ePly:SetNWInt('GBanTime', 0)
ePly:changeTeam(TEAM_CITIZEN, true)
ePly:Kill()
net.Start('gban_send_ply')
net.WriteBool(false)
net.WriteUInt(0, 16)
net.WriteString('')
net.Send(ePly)
if timer.Exists('GBanPlayer' .. ePly:SteamID()) then
timer.Remove('GBanPlayer' .. ePly:SteamID())
end
sql.Query('DELETE FROM gban WHERE SteamID = ' .. sql.SQLStr(ePly:SteamID()))
if eAdmin then
ePly:ChatPrint('Вам снял бан администратор ' .. eAdmin:Nick())
eAdmin:ChatPrint('Вы сняли бан игроку ' .. ePly:Nick())
end
print('[GBan] Player ' .. ePly:SteamID() .. ' has removed gban!')
end
function GBan.RemoveBanPlayerOffline(sSteamID, eAdmin)
if not sSteamID then
print('[GBan] ERROR #03')
return
end
local ply = player.GetBySteamID(sSteamID)
if ply and IsValid(ply) then
GBan.RemoveBanPlayer(ply, eAdmin)
return
end
sql.Query('DELETE FROM gban WHERE SteamID = ' .. sql.SQLStr(sSteamID))
print('[GBan] Player ' .. sSteamID .. ' has removed gban!')
end
hook.Add('PlayerInitialSpawn', 'GBan.JailerTheFirstSpawn', function(ePly)
timer.Simple(2, function()
local steamid = sql.SQLStr(ePly:SteamID())
local time = sql.QueryValue('SELECT Time FROM gban WHERE SteamID=' .. steamid)
local Admin = sql.QueryValue('SELECT IDEALAdmin FROM gban WHERE SteamID=' .. steamid)
local sReason =sql.QueryValue('SELECT Reason FROM gban WHERE SteamID=' .. steamid)
if not time then return end
if not Admin then
Admin = ""
end
time = tonumber(time) -- only seconds!
local date = sql.QueryValue('SELECT Date FROM gban WHERE SteamID=' .. steamid)
local finish_time = time + tonumber(date)
local current_time = os.time()
if finish_time <= current_time then
sql.Query('DELETE FROM gban WHERE SteamID = ' .. steamid)
return
end
time= finish_time-current_time
ePly:changeTeam(TEAM_BANNED, true)
ePly:SetNWBool('GBan', true)
ePly:SetNWInt('GBanTime', time)
ePly:Spawn()
net.Start('gban_send_ply')
net.WriteBool(true)
net.WriteUInt(time, 31)
net.WriteString(Admin)
net.WriteString(sReason)
net.Send(ePly)
timer.Create('GBanPlayer' .. ePly:SteamID(), time, 1, function()
GBan.RemoveBanPlayerOffline(ePly:SteamID())
end)
end)
end)
hook.Add('PlayerSpawn', 'GBan.JailerSpawn', function(ePly)
if not ePly:IsGBan() then return end
timer.Simple(0.1, function()
ePly:SetPos(GBan.Config.banned_pos)
ePly:SetModel(GBan.Config.banned_model)
ePly:SetCrouchedWalkSpeed(GBan.Config.banned_maxspeed)
ePly:SetRunSpeed(GBan.Config.banned_maxspeed)
ePly:SetWalkSpeed(GBan.Config.banned_maxspeed)
ePly:StripWeapons()
end)
end)
hook.Add('PlayerDisconnected', 'GBan.UpdateTimeForJailer', function(ePly)
if not ePly:IsGBan() then return end
local steamid, time = sql.SQLStr(ePly:SteamID()), math.floor(timer.TimeLeft('GBanPlayer' .. ePly:SteamID()))
sql.Query('UPDATE gban SET Time=' .. time .. ' WHERE SteamID=' .. steamid)
timer.Remove('GBanPlayer' .. ePly:SteamID())
end)
-- Restrict
hook.Add('CanPlayerSuicide', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerLoadout', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSpawnObject', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSpawnSENT', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSpawnNPC', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSpawnSWEP', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSpawnVehicle', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerGiveSWEP', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerCanPickupWeapon', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerCanPickupItem', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('playerCanChangeTeam', "GhostBan_CantChangeJob", function(ePly)
if ePly:IsGBan() then return false end
end)
-- hook.Add( 'PlayerCanJoinTeam', 'GBan.RestrictHook', function( ePly )
--
-- if ePly:IsGBan() then return false end
--
-- end )
hook.Add('CanPlayerEnterVehicle', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerNoClip', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('PlayerSay', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return "" end
end)
hook.Add('PlayerCanHearPlayersVoice', 'GBan.RestrictHook', function(pl, ePly)
if ePly:IsGBan() then return false end
end)
hook.Add('canChatCommand', 'GBan.RestrictHook', function(ePly)
if ePly:IsGBan() then return false end
end)
elseif CLIENT then
local function FormatTime(time)
local d = mf(time / 86400)
local h = mf(time / 3600)
local m = mf(time / 60)
local s = time
if d >= 1 then
return Format('%sд:%sч:%sм:%sс', d, mf(h - (d * 24)), mf(m - h * 60), mf(s - m * 60))
elseif h >= 1 then
return Format('%sч:%sм:%sс', h, mf(m - h * 60), mf(s - m * 60))
else
return Format('%sм:%sс', m, mf(s - m * 60))
end
end
local w = ScrW()
local h = ScrH()
surface.CreateFont('TheShitFont', {
font = "Trebuchet24",
size = (h + w) * .011,
weight = 300,
blursize = 0,
scanlines = 0,
antialias = false,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = true,
additive = false,
outline = false,
})
local COLOR_WHITE = Color(255, 255, 255)
local COLOR_BLACK = Color(0, 0, 0)
net.Receive('gban_send_ply', function()
local to_ban = net.ReadBool()
local time = net.ReadUInt(31)
local admin = net.ReadString()
local Reason=net.ReadString()
if not to_ban then
hook.Remove('HUDPaint', 'GBan.DrawInfoPanel')
return
end
timer.Create('GBanTime', time, 1, function() end)
hook.Add('HUDPaint', 'GBan.DrawInfoPanel', function()
if not LocalPlayer():IsGBan() then return end
local time = timer.Exists('GBanTime') and math.floor(timer.TimeLeft('GBanTime')) or 0
draw.SimpleTextOutlined('До снятия бана осталось: ' .. FormatTime(time), 'TheShitFont', w / 2, 0, COLOR_WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, COLOR_BLACK)
draw.SimpleTextOutlined('Вас забанил: ' .. admin, 'TheShitFont', w / 2, 30, COLOR_WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, COLOR_BLACK)
draw.SimpleTextOutlined('Причина: '.. Reason,'TheShitFont', w / 2, 60, COLOR_WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, COLOR_BLACK)
end)
end)
end
if SAM_LOADED then return end
local sam, cmd, lang = sam, sam.command, sam.language
local cat = 'gBan'
cmd.set_category(cat)
cmd.new('gban'):Help('Банит игрока'):SetPermission('gban', 'admin'):AddArg('player'):AddArg('text', {
hint = '10mi,1h10mi (м=mi ч=h д=d н=w м=mo)',
min = 1,
max = GBan.Config.max_seconds,
round = true,
optional = true,
default = 250
}):AddArg('text', {
hint = 'Причина'
}):OnExecute(function(eAdmin, tTargets, nMinute, sReason)
if #tTargets > 1 then return end
for i = 1, #tTargets do
local ply = tTargets[i]
GBan.GiveBanPlayer(ply, eAdmin, sReason, nMinute)
end
end):End()
cmd.new('ungban'):Help('Убирает у игрока gban'):SetPermission('ungban', 'admin'):AddArg('player'):OnExecute(function(eAdmin, target)
if #target > 1 then return end
for i = 1, #target do
local ply = target[i]
GBan.RemoveBanPlayer(ply, eAdmin)
end
end):End()
219 строка не работает color() помогите пожалуйста