• awarn2 Slay Command help
    0 replies, posted
[CODE]AWarn = {} AWarn.DefaultValues = { awarn_kick = 1, awarn_kick_threshold = 4, awarn_ban = 1, awarn_ban_threshold = 6, awarn_ban_time = 30, awarn_decay = 1, awarn_decay_rate = 30, awarn_reasonrequired = 1 } function awarn_loadscript() awarn_tbl_exist() util.AddNetworkString("SendPlayerWarns") util.AddNetworkString("SendOwnWarns") util.AddNetworkString("AWarnMenu") util.AddNetworkString("AWarnClientMenu") util.AddNetworkString("AWarnOptionsMenu") util.AddNetworkString("AWarnNotification") util.AddNetworkString("AWarnNotification2") util.AddNetworkString("AWarnChatMessage") end hook.Add( "Initialize", "Awarn_Initialize", awarn_loadscript ) function awarn_checkkickban( ply ) local kt = tonumber(GetGlobalInt( "awarn_kick_threshold", 4 )) local bt = tonumber(GetGlobalInt( "awarn_ban_threshold", 6 )) local btime = tonumber(GetGlobalInt( "awarn_ban_time", 30 )) local kickon = tobool(GetGlobalInt( "awarn_kick", 1 )) local banon = tobool(GetGlobalInt( "awarn_ban", 1 )) if banon then if tonumber(awarn_getwarnings( ply )) >= tonumber(bt) then ServerLog("AWarn: BANNING " .. ply:Nick() .. " FOR " .. btime .. " minutes!\n") for k, v in pairs(player.GetAll()) do AWSendMessage( v, "AWarn: " .. ply:Nick() .. " was banned for reaching the warning threshold" ) end timer.Simple(1, function() awarn_ban( ply, btime ) end ) return end end if kickon then if awarn_getwarnings( ply ) >= tonumber(kt) then ServerLog("AWarn: KICKING " .. ply:Nick().. "\n") for k, v in pairs(player.GetAll()) do AWSendMessage( v, "AWarn: " .. ply:Nick() .. " was kicked for reaching the warning threshold" ) end timer.Simple(1, function() awarn_kick( ply ) end ) return end end --print("DEBUG: " .. awarn_getwarnings( ply )) end function awarn_kick( ply ) if ulx then ULib.kick( ply, "AWarn: Warning Threshold Met" ) else ply:Kick( "AWarn: Warning Threshold Met" ) end end function awarn_ban( ply, time ) if ulx then ULib.kickban( ply, time, "AWarn: Ban Threshold Met" ) else ply:Ban( time, "AWarn: Ban Threshold Met" ) end end function awarn_decaywarns( ply ) if tobool(GetGlobalInt( "awarn_decay", 1 )) then local dr = GetGlobalInt( "awarn_decay_rate", 30 ) if awarn_getlastwarn( ply ) == "NONE" then --print("DEBUG: HAS NO WARNINGS") else --print("DEBUG: Has warnings on connect..") if tonumber(os.time()) >= tonumber(awarn_getlastwarn( ply )) + (dr*60) then --print("DEBUG: connection warning should be decayed") awarn_decwarnings(ply) end --print("DEBUG: " .. awarn_getwarnings( ply ) .. " warnings remaining.") if awarn_getwarnings( ply ) > 0 then --print("DEBUG: Creating timer.") timer.Create( ply:SteamID64() .. "_awarn_decay", dr*60, 1, function() if IsValid(ply) then awarn_decaywarns(ply) end end ) end end end end hook.Add( "PlayerInitialSpawn", "awarn_decaywarns", awarn_decaywarns ) function awarn_welcomebackannounce( ply ) if awarn_getwarnings( ply ) > 0 then local t1 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "Welcome back to the server, " .. ply:Nick() .. "." } net.Start("AWarnChatMessage") net.WriteTable(t1) net.Send( ply ) local t2 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "Current Active Warnings: ", Color(255,0,0), tostring(awarn_getwarnings( ply )) } net.Start("AWarnChatMessage") net.WriteTable(t2) net.Send( ply ) if tobool( GetGlobalInt("awarn_kick", 1) ) then local t3 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "You will be kicked after: ", Color(255,0,0), GetGlobalInt("awarn_kick_threshold", 3), Color(255,255,255), " total active warnings." } net.Start("AWarnChatMessage") net.WriteTable(t3) net.Send( ply ) end if tobool( GetGlobalInt("awarn_ban", 1) ) then local t4 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "You will be banned after: ", Color(255,0,0), GetGlobalInt("awarn_ban_threshold", 7), Color(255,255,255), " total active warnings." } net.Start("AWarnChatMessage") net.WriteTable(t4) net.Send( ply ) end local t5 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "Type !warn to see a list of your warnings." } net.Start("AWarnChatMessage") net.WriteTable(t5) net.Send( ply ) end end hook.Add( "PlayerInitialSpawn", "awarn_welcomebackannounce", awarn_welcomebackannounce ) function awarn_notifyadmins( ply ) if awarn_gettotalwarnings( ply ) > 0 then local total_warnings = awarn_gettotalwarnings( ply ) local total_active_warnings = awarn_getwarnings( ply ) timer.Simple(1, function() local t1 = { Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), ply, " joins the server with (", Color(255,0,0), tostring(total_warnings), Color(255,255,255), ") total warnings and (", Color(255,0,0), tostring(total_active_warnings), Color(255,255,255), ") active warnings." } for k, v in pairs(player.GetAll()) do if awarn_checkadmin_view( v ) then net.Start("AWarnChatMessage") net.WriteTable(t1) net.Send( v ) end end end ) end end hook.Add( "PlayerInitialSpawn", "awarn_notifyadmins", awarn_notifyadmins ) function awarn_playerdisconnected( ply ) timer.Remove( ply:SteamID64() .. "_awarn_decay" ) end hook.Add( "PlayerDisconnected", "awarn_playerdisconnected", awarn_playerdisconnected ) function awarn_con_fetchwarns( ply, _, args ) if not IsValid( ply ) then AWSendMessage( ply, "AWarn: This command can not be run from the server's console!") return end if not awarn_checkadmin_view( ply ) then AWSendMessage( ply, "AWarn: You do not have access to this command.") return end local target_ply = awarn_getUser( args[1] ) if target_ply then awarn_sendwarnings( ply, target_ply ) else AWSendMessage( ply, "AWarn: Player not found!") end end concommand.Add( "awarn_fetchwarnings", awarn_con_fetchwarns ) function awarn_con_fetchownwarns( ply, _, args ) if not IsValid( ply ) then AWSendMessage( ply, "AWarn: This command can not be run from the server's console!") return end awarn_sendownwarnings( ply ) end concommand.Add( "awarn_fetchownwarnings", awarn_con_fetchownwarns ) function awarn_con_changeconvarbool( ply, _, args ) local allowed = { "awarn_kick", "awarn_ban", "awarn_decay", "awarn_reasonrequired" } if not awarn_checkadmin_options( ply ) then AWSendMessage( ply, "AWarn: You do not have access to this command.") return end if not table.HasValue( allowed, args[1] ) then AWSendMessage( ply, "AWarn: You can not set this CVar with this command.") return end if #args ~= 2 then return end if args[2] == "true" then awarn_saveservervalue( args[1], 0 ) return end awarn_saveservervalue( args[1], 1 ) end concommand.Add( "awarn_changeconvarbool", awarn_con_changeconvarbool ) function awarn_con_changeconvar( ply, _, args ) local allowed = { "awarn_kick_threshold", "awarn_ban_threshold", "awarn_ban_time", "awarn_decay_rate" } if not awarn_checkadmin_options( ply ) then AWSendMessage( ply, "AWarn: You do not have access to this command.") return end if not table.HasValue( allowed, args[1] ) then AWSendMessage( ply, "AWarn: You can not set this CVar with this command.") return end if #args ~= 2 then return end if not tonumber(args[2]) then AWSendMessage( ply, "AWarn: You must pass this ConVar a number value.") return end if tonumber(args[2]) < 0 then AWSendMessage( ply, "AWarn: You must pass this ConVar a positive value.") return end awarn_saveservervalue( args[1], args[2] ) end concommand.Add( "awarn_changeconvar", awarn_con_changeconvar ) function AWSendMessage( ply, message ) if IsValid(ply) then ply:PrintMessage( HUD_PRINTTALK, message ) e
Sorry, you need to Log In to post a reply to this thread.