function ulx.warn( calling_ply, target_ply, reason )
local t = target_ply
numberofwarns = tonumber(t:GetPData("WarnData")) or 0
if numberofwarns == 0 then
time = 0
t:SetPData("WarnData", numberofwarns+1)
t:PrintMessage( HUD_PRINTTALK, "You have been warned for the first time, becareful "..t:Nick())
t:SetPData("WarnsHadData", (tonumber(t:GetPData("WarnsHadData")) or 0)+1)
elseif numberofwarns == 1 then
t:SetPData("WarnData", numberofwarns+1)
time = 60
--t:Ban(time, "You have been warned two times! Therefor are banned for 60 minutes!")
ULib.kickban( target_ply, time, "You have been warned two times! Therefor are banned for 60 minutes!", calling_ply )
t:SetPData("WarnsHadData", (tonumber(t:GetPData("WarnsHadData")) or 0)+1)
elseif numberofwarns == 2 then
t:SetPData("WarnData", numberofwarns+1)
time = 1440
ULib.kickban( target_ply, time, "You have been warned two times! Therefor are banned for 1 day!", calling_ply )
t:SetPData("WarnsHadData", (tonumber(t:GetPData("WarnsHadData")) or 0)+1)
elseif numberofwarns == 3 then
t:SetPData("WarnData", numberofwarns+1)
time = 10080
ULib.kickban( target_ply, time, "You have been warned two times! Therefor are banned for 1 week!", calling_ply )
t:SetPData("WarnsHadData", (tonumber(t:GetPData("WarnsHadData")) or 0)+1)
elseif numberofwarns > 3 then
time = 0
t:SetPData("WarnData", numberofwarns+1)
ULib.kickban( target_ply, time, "You have been warned two times! Therefor are banned for Permanently!", calling_ply )
t:SetPData("WarnsHadData", (tonumber(t:GetPData("WarnsHadData")) or 0)+1)
end
time = tostring(time).." minutes ("..reason..")"
ulx.fancyLogAdmin( calling_ply, "#A has warned #T, and has been banned for #s", t, time)
end
local warn = ulx.command( CATEGORY_NAME, "ulx warn", ulx.warn, {"!warn", "!w"})
warn:addParam{ type=ULib.cmds.PlayerArg }
warn:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
warn:defaultAccess( ULib.ACCESS_ADMIN )
warn:help("Adds a warn to the target")
function ulx.unwarn( calling_ply, target_ply )
local t = target_ply
numberofwarns = tonumber(t:GetPData("WarnData")) or 0
if numberofwarns == 0 then
calling_ply:PrintMessage( HUD_PRINTTALK, target_ply:Nick().."'s warns are 0, unable to remove a warn!")
return
else
t:RemovePData("WarnData")
t:SetPData("WarnData", numberofwarns-1)
ulx.fancyLogAdmin( calling_ply, "#A has removed one warn from #T", target_ply)
end
end
local unwarn = ulx.command( CATEGORY_NAME, "ulx unwarn", ulx.unwarn, {"!unwarn", "!uw"})
unwarn:addParam{ type=ULib.cmds.PlayerArg }
unwarn:defaultAccess( ULib.ACCESS_ADMIN )
unwarn:help("Removeds a warn from the target")
function ulx.resetwarndata( calling_ply, target_ply )
local t = target_ply
numberofwarns = tonumber(t:GetPData("WarnData")) or 0
WarnsHadData = tonumber(t:GetPData("WarnsHadData")) or 0
if numberofwarns == 0 and WarnsHadData == 0 then
calling_ply:PrintMessage( HUD_PRINTTALK, target_ply:Nick().." Has had or has no warns.")
return
else
t:RemovePData("WarnData")
t:RemovePData("WarnsHadData")
ulx.fancyLogAdmin( calling_ply, "#A has removed all WARNDATA from #T", target_ply)
end
end
local resetwarn = ulx.command( CATEGORY_NAME, "ulx rswd", ulx.resetwarndata, {"!rswd", "!resetwarndata"})
resetwarn:addParam{ type=ULib.cmds.PlayerArg }
resetwarn:defaultAccess( ULib.ACCESS_ADMIN )
resetwarn:help("Removes all WarnData from the target - owner use only.")
function ulx.viewwarns( calling_ply, target_ply )
local t = target_ply
numberofwarns = tonumber(t:GetPData("WarnData")) or "0"
WarnsHadData = t:GetPData("WarnsHadData") or "0"
calling_ply:PrintMessage( HUD_PRINTTALK, "WARNDATA: "..target_ply:Nick().." has ("..tostring(numberofwarns)..") warns active and has had ("..WarnsHadData..") Warns")
end
local vwarn = ulx.command( CATEGORY_NAME, "ulx viewwarns", ulx.viewwarns, {"!viewwarns", "!vw"})
vwarn:addParam{ type=ULib.cmds.PlayerArg }
vwarn:defaultAccess( ULib.ACCESS_ADMIN )
vwarn:help("Views a target's WarnData.")