diff --git a/.gitmodules b/.gitmodules index c8f4e61..f237e79 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lua/includes/ev_vON"] path = lua/includes/ev_von - url = git@github.com:vercas/vON.git + url = https://github.com/vercas/vON.git diff --git a/README.md b/README.md index 5ce1ded..a104de8 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ If you later want to update it, you can use `git pull` to update evolve and `git To install evolve with a zip file, first download the [evolve zip file](https://github.com/Xandaros/evolve/archive/master.zip) and unzip it into your addons folder. Make sure the folder in your addons directory contains a file called "README.md". Then, download the [vON zip file](https://github.com/vercas/vON/archive/master.zip) and unzip the "von.lua" it into addons/evolve/includes/ev_von. Make sure that the ev_von folder contains a file called "von.lua". +How do I upgrade from a previous evolve install? +======================== +Check if you have ev_* files in your data or data/evolve_motd folder and move them into data/evolve folder, remove the ev_ prefix from the filenames. If data/evolve folder does not exist, create it. + How do I become owner? ====================== diff --git a/lua/ev_cl_init.lua b/lua/ev_cl_init.lua index 920ff43..1c151d8 100644 --- a/lua/ev_cl_init.lua +++ b/lua/ev_cl_init.lua @@ -9,5 +9,6 @@ print( "=====================================================\n" ) net.Receive( "EV_Init", function( length ) evolve.installed = true + evolve:GetSettings() evolve:LoadPlugins() end ) \ No newline at end of file diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 060eca6..f047c5e 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -26,6 +26,25 @@ evolve.category.punishment = 3 evolve.category.teleportation = 4 evolve.stagedPlugins = {} evolve.plugins = {} +evolve.settingsStructure = { + category_general = { + label = 'General', + desc = 'This is for general evolve settings.', + stype = 'category', + icon = 'home', + value = { + } + }, + category_plugins = { + label = 'Plugins', + desc = 'Your plugin settings! For You!', + stype = 'category', + icon = 'plugin', + value = {} + } +} +evolve.settings = {} +evolve.settingsdelta = {} evolve.version = 179 _R = debug.getregistry() @@ -44,6 +63,7 @@ if SERVER then util.AddNetworkString("EV_PluginFile") util.AddNetworkString("EV_Privilege") util.AddNetworkString("EV_Rank") + util.AddNetworkString("EV_Settings") util.AddNetworkString("EV_RankPrivileges") util.AddNetworkString("EV_RenameRank") util.AddNetworkString("EV_RankPrivilege") @@ -104,16 +124,23 @@ if ( SERVER ) then end local str = "" + local dontlog = false for _, v in ipairs( arg ) do - if ( type( v ) == "string" ) then str = str .. v end + if ( type( v ) == "string" ) then + str = str .. v + elseif ( type( v ) == "bool" && v == true) then + dontlog = true + end end - - if ( ply ) then - print( "[EV] " .. ply:Nick() .. " -> " .. str ) - evolve:Log( evolve:PlayerLogStr( ply ) .. " -> " .. str ) - else - print( "[EV] " .. str ) - evolve:Log( str ) + + if( !dontlog ) then + if ( ply ) then + print( "[EV] " .. ply:Nick() .. " -> " .. str ) + evolve:Log( evolve:PlayerLogStr( ply ) .. " -> " .. str ) + else + print( "[EV] " .. str ) + evolve:Log( str ) + end end end else @@ -172,7 +199,7 @@ function evolve:FormatTime( t ) elseif ( t < 24 * 3600 * 30 ) then if ( math.ceil( t / ( 24 * 3600 * 7 ) ) == 1 ) then return "one week" else return math.ceil( t / ( 24 * 3600 * 7 ) ) .. " weeks" end else - if ( math.ceil( t / ( 24 * 3600 * 30 ) ) == 1 ) then return "one month" else return math.ceil( t / ( 24 * 3600 * 30 ) ) .. " months" end + if ( math.ceil( t / ( 24 * 3600 * 30 ) ) == 1 ) then return "one month" else return math.ceil( t / ( 24 * 3600 * 30 ) ) .. " months" end end end @@ -210,14 +237,23 @@ end function evolve:LoadPlugins() evolve.plugins = {} + local _blacklist = string.Split(evolve:GetSetting('settings_plugin_blacklist', ''), ' ') + local blacklist = {} + for _,name in pairs(_blacklist) do + if(#string.Trim(name)>0) then + blacklist[name] = true + end + end + local plugins,_ = file.Find( "ev_plugins/*.lua", "LUA" ) for _, plugin in ipairs( plugins ) do local prefix = string.Left( plugin, string.find( plugin, "_" ) - 1 ) + local filename = string.sub( plugin, 4, -5 ) evolve.pluginFile = plugin - - if ( CLIENT and ( prefix == "sh" or prefix == "cl" ) ) then + + if ( !blacklist[filename] and CLIENT and ( prefix == "sh" or prefix == "cl" ) ) then include( "ev_plugins/" .. plugin ) - elseif ( SERVER ) then + elseif ( !blacklist[filename] and SERVER ) then include( "ev_plugins/" .. plugin ) if ( prefix == "sh" or prefix == "cl" ) then AddCSLuaFile( "ev_plugins/" .. plugin ) end end @@ -255,6 +291,7 @@ function evolve:RegisterPlugin( plugin ) table.insert( evolve.stagedPlugins, plugin ) plugin.File = pluginFile if ( plugin.Privileges and SERVER ) then table.Add( evolve.privileges, plugin.Privileges ) table.sort( evolve.privileges ) end + if ( plugin.Settings ) then evolve:RegisterPluginSettings( plugin ) end else table.insert( evolve.plugins, { Title = plugin.Title, File = pluginFile } ) end @@ -471,10 +508,6 @@ function evolve:SetProperty( uniqueid, id, value ) end function evolve:CommitProperties() - /*------------------------------------------------------------------------------------------------------------------------- - Check if a cleanup would be convenient - -------------------------------------------------------------------------------------------------------------------------*/ - local count = table.Count( evolve.PlayerInfo ) if ( count > 800 ) then @@ -510,6 +543,14 @@ hook.Add( "PlayerSpawnedVehicle", "EV_SpawnHook", function( ply, ent ) ent.EV_Ow hook.Add( "PlayerSpawnedEffect", "EV_SpawnHook", function( ply, model, ent ) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " spawned effect '" .. model .. "'." ) end ) hook.Add( "PlayerSpawnedRagdoll", "EV_SpawnHook", function( ply, model, ent ) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " spawned ragdoll '" .. model .. "'." ) end ) +-- darkrp hooking abound +--[[hook.Add( "playerboughtcustomvehicle", "EV_SpawnHook", function( ply, entityTable, ent, price) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " bought custom vehicle '" .. entityTable.entity .. "'." ) end ) +hook.Add( "playerboughtvehicle", "EV_SpawnHook", function( ply, ent, cost) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " bought vehicle '" .. ent:GetModel() .. "'." ) end ) +hook.Add( "playerboughtshipment", "EV_SpawnHook", function( ply, entityTable, ent, price) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " bought shipment '" .. entityTable.entity .. "'." ) end ) +hook.Add( "playerboughtdoor", "EV_SpawnHook", function( ply, ent, cost ) return true end ) +hook.Add( "playerboughtcustomentity", "EV_SpawnHook", function( ply, entityTable, ent, price) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " custom entity '" .. entityTable.entity .. "'." ) end ) +hook.Add( "playerboughtpistol", "EV_SpawnHook", function( ply, entityTable, ent, price) ent.EV_Owner = ply:UniqueID() evolve:Log( evolve:PlayerLogStr( ply ) .. " bought pistol '" .. entityTable.entity .. "'." ) end )]] + evolve.AddCount = _R.Player.AddCount function _R.Player:AddCount( type, ent ) ent.EV_Owner = self:UniqueID() @@ -901,6 +942,8 @@ if ( SERVER ) then evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," granted access of ",evolve.colors.red,"tool ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," to ",evolve.colors.red,rank,evolve.colors.white,".") elseif (string.sub(privilege,1,1)=="@") then evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," granted access of ",evolve.colors.red,"swep ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," to ",evolve.colors.red,rank,evolve.colors.white,".") + elseif (string.sub(privilege,1,1)=="&") then + evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," granted access of ",evolve.colors.red,"player model ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," to ",evolve.colors.red,rank,evolve.colors.white,".") else evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," granted access of ",evolve.colors.red,"privilege ",evolve.colors.blue,privilege,evolve.colors.white," to ",evolve.colors.red,rank,evolve.colors.white,".") end @@ -914,6 +957,8 @@ if ( SERVER ) then evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," revoked access of ",evolve.colors.red,"tool ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," from ",evolve.colors.red,rank,evolve.colors.white,".") elseif (string.sub(privilege,1,1)=="@") then evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," revoked access of ",evolve.colors.red,"swep ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," from ",evolve.colors.red,rank,evolve.colors.white,".") + elseif (string.sub(privilege,1,1)=="&") then + evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," revoked access of ",evolve.colors.red,"player model ",evolve.colors.blue,string.sub(privilege,2),evolve.colors.white," from ",evolve.colors.red,rank,evolve.colors.white,".") else evolve:Notify(evolve.colors.blue,ply:Nick(),evolve.colors.white," revoked access of ",evolve.colors.red,"privilege ",evolve.colors.blue,privilege,evolve.colors.white," from ",evolve.colors.red,rank,evolve.colors.white,".") end @@ -1102,7 +1147,12 @@ if ( SERVER ) then pl:Kick( "Banned for " .. length / 60 .. " minutes! (" .. reason .. ")" ) end else - game.ConsoleCommand( "addip " .. length / 60 .. " \"" .. string.match( evolve:GetProperty( uid, "IPAddress" ), "(%d+%.%d+%.%d+%.%d+)" ) .. "\"\n" ) + local steamid = evolve:GetProperty( uid, "SteamID" ) + if(steamid) then + game.ConsoleCommand( "banid " .. length / 60 .. " " .. steamid .. "\n" ) + else + game.ConsoleCommand( "addip " .. length / 60 .. " \"" .. string.match( evolve:GetProperty( uid, "IPAddress" ), "(%d+%.%d+%.%d+%.%d+)" ) .. "\"\n" ) + end end end end @@ -1169,6 +1219,207 @@ else end ) end + +/*------------------------------------------------------------------------------------------------------------------------- + Settings system +-------------------------------------------------------------------------------------------------------------------------*/ + +--[[ + todo: + declare setting types, + add some junk in PLUGIN and TAB loading for settings + allow for user-specific settings + LOCK THIS WAY DOWN +]] +function evolve:GetSetting( name, default ) + if evolve.settings[name] == nil then + return default + elseif evolve.settings[name].value == nil then + -- in the incredibly unlikely chance that we access and the value is nil + return evolve.settings[name].default + else + return evolve.settings[name].value + end +end + +function evolve:SendSettings( ply ) + if CLIENT and !LocalPlayer():EV_HasPrivilege( "Settings: Send To Server" ) then + return false + end + net.Start("EV_Settings") + net.WriteString("save") + local loaded = {} + for k,v in pairs(evolve.settingsdelta) do + loaded[k] = v + end + net.WriteTable(loaded) + if CLIENT then + net.SendToServer() + elseif SERVER and ply then + net.Send(ply) + elseif SERVER then + net.Broadcast() + end + evolve.settingsdelta={} + return true +end + +if SERVER then + function evolve:ClearSettings() + if ( file.Exists( "evolve/settings.txt", "DATA" ) ) then + file.Delete( "evolve/settings.txt", "DATA" ) + end + --@TODO: Maybe make this rebuild evolve.settings? Not sure if we'd need that. + end + + function evolve:LoadSettings() + if ( file.Exists( "evolve/settings.txt", "DATA" ) ) then + local loaded = evolve.von.deserialize( file.Read( "evolve/settings.txt", "DATA" ) ) + for k,v in pairs(loaded) do + --x@TODO: do some validaiton here I guess, we would use SetSetting but you know + if evolve.settings[k]==nil then evolve.settings[k]={} end + evolve.settings[k].value = v + if ConVarExists(k) and GetConVarString(k)~=tostring(v) then + RunConsoleCommand("ev", "convar", k, v) + end + end + end + end + function evolve:SaveSettings() + -- will probably have a client version at some point + local loaded = {} + for k,v in pairs(evolve.settings) do + loaded[k] = v.value + end + file.Write( "evolve/settings.txt", evolve.von.serialize(loaded) ) + end + + net.Receive( "EV_Settings", function( length, ply ) + -- on = sending, off = requesting + local doit = net.ReadString() + print("GOT NETWORK MESSAGE: "..doit.." len="..length.."bits") + if ( IsValid( ply ) and ply:IsPlayer() ) then + if doit == "save" then + if ply:EV_HasPrivilege( "Settings: Send To Server" ) then + table.Merge(evolve.settingsdelta, net.ReadTable()) + for k,v in pairs(evolve.settingsdelta) do + evolve.settings[k].value = v + end + --x@TODO: do a step-by-step validation of the settings instead of global overwrite + evolve:SaveSettings() + -- tell our clients that our settings changed + evolve:SendSettings() + else + -- we don't care what the player has to say, dump the rest of their message + -- this should normally never happen but in the case of hacks, anything is possible + net.ReadUInt(length-(8+string.len(doit)*8)) --8bits for every ASCII char. + end + elseif doit == "send" then + evolve:SendSettings(ply) + end + end + end ) +elseif CLIENT then + function evolve:GetSettings() + net.Start("EV_Settings") + net.WriteString("send") -- request from server + net.SendToServer() + end + + function evolve:SetSetting( name, value ) + -- elm, name, item, value + local ply = LocalPlayer() + local item = evolve.settings[name] + if ply:EV_HasPrivilege( "Settings: Modify" ) then + --allowed to modify the control + + -- convar check + if item.isconvar then + if ply:EV_HasPrivilege( "Convar changing" ) then + -- special bool->number converting + local pass = value + if type(value)=="boolean" then + pass = evolve:BoolToInt(value)*(item.multiplier or 1) + end + RunConsoleCommand("ev", "convar", name, pass) + else + evolve:Notify( ply, evolve.colors.red, "You can't change convars." ) + end + end + + evolve.settings[name].value = value + evolve.settingsdelta[name] = value + --x@TODO: make auto-send-on-set an option of its own + evolve:SendSettings() + else + evolve:Notify( ply, evolve.colors.red, "You can't modify these settings." ) + end + end + + net.Receive( "EV_Settings", function( length ) + -- on = sending, off = requesting + local doit = net.ReadString() + if doit == "save" then + local loaded = net.ReadTable() + for k,v in pairs(loaded) do + if evolve.settings[k]==nil then evolve.settings[k]={} end + evolve.settings[k].value = v + end + elseif doit == "send" then + evolve:SendSettings() + end + end ) +end +function evolve:RecurseRegister( mergepoint, settings ) + for k,v in pairs(settings) do + if v.stype == "category" then + evolve:RecurseRegister( evolve.settings, v.value ) + else + for k2,v2 in pairs(v) do + local prevalue = v.value + mergepoint[k] = v + if prevalue~=nil then + mergepoint[k].value = prevalue + else + mergepoint[k].value = mergepoint[k].default + end + end + end + end +end +function evolve:RegisterSettings( sets ) + table.Merge(evolve.settingsStructure, sets) + evolve:RecurseRegister(evolve.settings, sets) + return evolve.settings +end +function evolve:RegisterPluginSettings( plugin ) + local desc = plugin.Description or 'Mysterious Plugin, No Description Set!' + local icon = plugin.Icon or 'help' + local label = plugin.Title or 'Unknown' + local value = table.Copy(plugin.Settings) or {} --@DEV: in an ideal world maybe we could keep the settings here + local del = evolve.settingsStructure.category_plugins.value + del['category_'..string.lower(label)] = { + desc = desc, + icon = icon, + label = label, + stype = 'category', + value = value + } + for k,v in pairs( del['category_'..string.lower(label)].value ) do + local prevalue = nil + if evolve.settings[k]~=nil then + prevalue = evolve.settings[k].value + end + evolve.settings[k] = v + if prevalue~=nil then + evolve.settings[k].value = prevalue + else + evolve.settings[k].value = evolve.settings[k].default + end + end +end + + /*------------------------------------------------------------------------------------------------------------------------- Global data system -------------------------------------------------------------------------------------------------------------------------*/ @@ -1239,6 +1490,10 @@ end hook.Add( "InitPostEntity", "EV_LogInit", function() evolve:Log( "== Started in map '" .. game.GetMap() .. "' and gamemode '" .. GAMEMODE.Name .. "' ==" ) + --@DEV: we gotta do this here to overwrite server.cfg items + if SERVER and evolve:GetSetting('settings_overload_servercfg', false) then + evolve:LoadSettings() + end end ) hook.Add( "PlayerDisconnected", "EV_LogDisconnect", function( ply ) diff --git a/lua/ev_menu/cl_menu.lua b/lua/ev_menu/cl_menu.lua index 1022cfc..a1cf01e 100644 --- a/lua/ev_menu/cl_menu.lua +++ b/lua/ev_menu/cl_menu.lua @@ -6,6 +6,7 @@ evolve.MENU = {} local MENU = evolve.MENU MENU.Tabs = {} MENU.Privileges = {} +MENU.IsVisible = false function evolve:RegisterTab( tab ) if ( tab.IsAllowed and !tab:IsAllowed() ) then return false end @@ -101,6 +102,7 @@ hook.Add( "EV_RankPrivilegeChange", "EV_MenuPrivUpdate", function( rank, privile end ) function MENU:Show() + self.IsVisible = !self.IsVisible if ( !LocalPlayer():EV_HasPrivilege( "Menu" ) ) then return end if ( !self.Panel ) then MENU:Initialize() end @@ -124,6 +126,7 @@ function MENU:Show() end function MENU:Hide() + self.IsVisible = !self.IsVisible if ( !self.Panel ) then return end self.Panel:SetKeyboardInputEnabled( false ) @@ -139,5 +142,14 @@ function MENU:Hide() end ) end +function MENU:Toggle() + if self.IsVisible then + self:Hide() + else + self:Show() + end +end + concommand.Add( "+ev_menu", function() MENU:Show() end ) -concommand.Add( "-ev_menu", function() MENU:Hide() end ) \ No newline at end of file +concommand.Add( "-ev_menu", function() MENU:Hide() end ) +concommand.Add( "ev_menu_toggle", function() MENU:Toggle() end ) \ No newline at end of file diff --git a/lua/ev_menu/tab_adverts3.lua b/lua/ev_menu/tab_adverts3.lua new file mode 100644 index 0000000..c02b0c7 --- /dev/null +++ b/lua/ev_menu/tab_adverts3.lua @@ -0,0 +1,335 @@ +--[[ +Requires that sh_advert.lua be installed. +Usage of the menu requires both "Advert 3" and "Advert 3 Menu" privileges be set to your rank. +ReSync button allows for variations from the server's advert list and the client's advert list. + +Any problems, let me know! thatcutekiwi@gmail.com . Thanks! Saria Parkar <3]] + +local TAB = {} +TAB.Title = "Adverts" +TAB.Description = "Add, remove, modify adverts." +TAB.Icon = "feed_edit" +TAB.Author = "SariaFace & EntranceJew" +TAB.Width = 520 +TAB.Privileges = { "Advert 3 Menu" } + +function SendAdverts(ply) + local tosend = nil + if ( SERVER ) and (adverts and #adverts.Stored) then + tosend = adverts.Stored + elseif ( CLIENT ) and (adverts) then + tosend = adverts + else + -- well this isn't right + return false + end + + net.Start("EV_Adverts3") + net.WriteString("send") + net.WriteTable(tosend) + + if ( SERVER ) and ( IsValid( ply ) and ply:IsPlayer() ) then + net.Send(ply) + else + net.SendToServer() + end +end + +net.Receive( "EV_Adverts3", function( length, ply ) + local mtype = net.ReadString() + + if mtype == "get" then + SendAdverts(ply) + elseif mtype == "send" then + local inbound = net.ReadTable() + if ( SERVER ) then + adverts.Stored = inbound + else + adverts = inbound + end + end +end ) + +if (SERVER) then + util.AddNetworkString("EV_Adverts3") +else + local NewAdPanelReg = {} + function NewAdPanelReg:Setup() + --Attention: EditAdPanelReg extends this function. + --If you want to add/change something specific to NewAdPanelReg, do it in NewAdPanelReg:Init() below + + self:SetPos( 40, (ScrH()/3)*2) + self:SetSize(560, 62) + self:SetTitle("Add new advert") + self:SetZPos(32767) + self:DoModal(true) + + self.IDLabel = vgui.Create("DLabel", self) + self.IDLabel:SetText("ID") + self.IDLabel:SetPos(37, 20) + self.IDInput = vgui.Create("DTextEntry", self) + self.IDInput:SetPos(2, (self:GetTall()-24)) + self.IDInput:SetSize(70, 20) + self.IDInput.OnLoseFocus = function() self.IDInput:SetValue(self.IDInput:GetValue():lower()) end + + self.ColourRLabel = vgui.Create("DLabel", self) + self.ColourRLabel:SetText("R") + self.ColourRLabel:SetPos(85, 20) + self.ColourR = vgui.Create("DTextEntry", self) + self.ColourR:SetSize(24, 20) + self.ColourR:SetPos(74, (self:GetTall()-24)) + self.ColourR:SetValue("255") + self.ColourR:SetTextColor(Color(255,0,0,255)) + self.ColourR.OnGetFocus = function() self.ColourR:SelectAll() end + self.ColourR.OnLoseFocus = function() if (string.len(self.ColourR:GetValue()) == 0) then self.ColourR:SetValue("0") end end + self.ColourR.OnTextChanged = function() + if ((string.len(self.ColourR:GetValue()) > 0 and !tonumber(self.ColourR:GetValue())) or string.len(self.ColourR:GetValue()) > 3) then + self.ColourR:SetValue("255") + end + end + self.ColourGLabel = vgui.Create("DLabel", self) + self.ColourGLabel:SetText("G") + self.ColourGLabel:SetPos(109, 20) + self.ColourG = vgui.Create("DTextEntry", self) + self.ColourG:SetSize(24, 20) + self.ColourG:SetPos(100, (self:GetTall()-24)) + self.ColourG:SetValue("255") + self.ColourG:SetTextColor(Color(0,155,0,255)) + self.ColourG.OnGetFocus = function() self.ColourG:SelectAll() end + self.ColourG.OnLoseFocus = function() if (string.len(self.ColourG:GetValue()) == 0) then self.ColourG:SetValue("0") end end + self.ColourG.OnTextChanged = function() + if ((string.len(self.ColourG:GetValue()) > 0 and !tonumber(self.ColourG:GetValue())) or string.len(self.ColourG:GetValue()) > 3) then + self.ColourG:SetValue("255") + end + end + self.ColourBLabel = vgui.Create("DLabel", self) + self.ColourBLabel:SetText("B") + self.ColourBLabel:SetPos(136, 20) + self.ColourB = vgui.Create("DTextEntry", self) + self.ColourB:SetSize(24, 20) + self.ColourB:SetPos(126, (self:GetTall()-24)) + self.ColourB:SetValue("255") + self.ColourB:SetTextColor(Color(0,0,255,255)) + self.ColourB.OnGetFocus = function() self.ColourB:SelectAll() end + self.ColourB.OnLoseFocus = function() if (string.len(self.ColourB:GetValue()) == 0) then self.ColourB:SetValue("0") end end + self.ColourB.OnTextChanged = function() + if ((string.len(self.ColourB:GetValue()) > 0 and !tonumber(self.ColourB:GetValue())) or string.len(self.ColourB:GetValue()) > 3) then + self.ColourB:SetValue("255") + end + end + + self.ColourIntLabel = vgui.Create("DLabel", self) + self.ColourIntLabel:SetText("Time(s)") + self.ColourIntLabel:SetPos(155, 20) + self.Interval = vgui.Create("DTextEntry", self) + self.Interval:SetPos(152, (self:GetTall()-24)) + self.Interval:SetSize(40, 20) + self.Interval:SetValue("60") + self.Interval.OnGetFocus = function() self.Interval:SelectAll() end + self.ColourB.OnLoseFocus = function() if (string.len(self.Interval:GetValue()) == 0) then self.Interval:SetValue("60") end end + self.Interval.OnTextChanged = function() + if (string.len(self.Interval:GetValue()) > 0 and !tonumber(self.Interval:GetValue())) then + self.Interval:SetValue("60") + end + end + + self.ColourMsgLabel = vgui.Create("DLabel", self) + self.ColourMsgLabel:SetText("Message") + self.ColourMsgLabel:SetPos(310, 20) + self.Msg = vgui.Create("DTextEntry", self) + self.Msg:SetPos(194, (self:GetTall()-24)) + self.Msg:SetSize(260, 20) + + self.OnStateCheckbox = vgui.Create("DCheckBox", self) + self.OnStateCheckbox:SetPos( 456, (self:GetTall()-22)) + self.OnStateCheckbox:SetValue(1) + + self.AddBut = vgui.Create( "DButton", self ) + self.AddBut:SetSize( 60, 22 ) + self.AddBut:SetPos( self:GetWide() - 68, (self:GetTall()-26) ) + self.AddBut:SetText( "Add" ) + self.AddBut.DoClick = function() + if (!tonumber(self.Interval:GetValue()) || tonumber(self.Interval:GetValue())<60) then + evolve:Notify(LocalPlayer(), evolve.colors.red, "Incorrect Time input, value must be equal or greater than 60!") + return + end + if (#string.Trim(self.Msg:GetValue())==0) then + evolve:Notify(LocalPlayer(), evolve.colors.red, "A message is required!") + return + end + local newAd = {} + newAd.Colour = {["r"] = self.ColourR:GetValue(), ["g"] = self.ColourG:GetValue(), ["b"] = self.ColourB:GetValue(), ["a"] = "255"} + newAd.Time = self.Interval:GetValue() + newAd.Msg = self.Msg:GetValue() + newAd.OnState = tostring(self.OnStateCheckbox:GetChecked()) + RunConsoleCommand("ev", "advert3", "add", self.IDInput:GetValue(), newAd.Colour["r"], newAd.Colour["g"], newAd.Colour["b"], tostring(newAd.Time), newAd.OnState, newAd.Msg) + adverts[self.IDInput:GetValue()] = newAd + timer.Simple(1.0, function() TAB:Update() end) + self:Remove() + return true + end + end + + function NewAdPanelReg:Init() + self:Setup() + self:MakePopup() + end + vgui.Register("NewAdPanel", NewAdPanelReg, "DFrame") + + --EditAdPanelReg extends NewAdPanelReg + local EditAdPanelReg = table.Copy(NewAdPanelReg) + function EditAdPanelReg:Init() + self:Setup() + self:SetTitle("Edit advert") + self.AddBut:SetText( "Update" ) + self.IDInput:SetEditable( false ) + self.IDInput:SetDisabled( true ) + if TAB.AdList:GetSelected() && #TAB.AdList:GetSelected() > 0 then + local id = TAB.AdList:GetSelected()[1]:GetValue(1) + self.IDInput:SetValue(id) + self.ColourR:SetValue(adverts[id].Colour["r"]) + self.ColourG:SetValue(adverts[id].Colour["g"]) + self.ColourB:SetValue(adverts[id].Colour["b"]) + self.Interval:SetValue(adverts[id].Time) + self.Msg:SetValue(adverts[id].Msg) + self.OnStateCheckbox:SetValue(adverts[id].OnState) + + local DoClick = self.AddBut.DoClick + self.AddBut.DoClick = function() + local result = DoClick() + if(result) then + TAB.AdList:GetSelected()[1]:SetValue(2, adverts[id].Colour["r"]..","..adverts[id].Colour["g"]..","..adverts[id].Colour["b"]) + TAB.AdList:GetSelected()[1]:SetValue(3, adverts[id].Time) + TAB.AdList:GetSelected()[1]:SetValue(4, adverts[id].Msg) + TAB.AdList:GetSelected()[1]:SetValue(5, adverts[id].OnState) + end + end + else + evolve:Notify(LocalPlayer(), evolve.colors.red, "Nothing selected!") + end + self:MakePopup() + end + vgui.Register("EditAdPanel", EditAdPanelReg, "DFrame") +end + +function TAB:GetAdverts(ply) + net.Start("EV_Adverts3") + net.WriteString("get") + if ( SERVER ) and ( IsValid( ply ) and ply:IsPlayer() ) then + net.Send(ply) + else + net.SendToServer() + end +end + +--===================================================================================-- + +if(CLIENT) then + function TAB:Initialize( pnl ) + adverts = {} + + self.AdList = vgui.Create( "DListView", pnl ) + self.AdList:SetSize( self.Width, pnl:GetParent():GetTall() - 58 ) + self.AdList:SetMultiSelect( false ) + self.AdList:AddColumn( "ID" ):SetFixedWidth( 70 ) + self.AdList:AddColumn( "Colour" ):SetFixedWidth( 70 ) + self.AdList:AddColumn( "Time(s)" ):SetFixedWidth( 40 ) + self.AdList:AddColumn( "Message" ):SetFixedWidth( 302 ) + self.AdList:AddColumn( "Active" ):SetFixedWidth( 32 ) + + self.ResyncButton = vgui.Create( "DButton", pnl ) + self.ResyncButton:SetSize( 60, 22 ) + self.ResyncButton:SetPos( self.Width - 340, pnl:GetParent():GetTall() - 53 ) + self.ResyncButton:SetText( "ReSync" ) + self.ResyncButton.DoClick = function() + self:Request() + end + + self.NewButton = vgui.Create( "DButton", pnl ) + self.NewButton:SetSize( 60, 22 ) + self.NewButton:SetPos( self.Width - 275, pnl:GetParent():GetTall() - 53 ) + self.NewButton:SetText( "New" ) + self.NewButton.DoClick = function() + newAdInput = vgui.Create("NewAdPanel", pnl) + end + + self.EditButton = vgui.Create( "DButton", pnl ) + self.EditButton:SetSize( 60, 22 ) + self.EditButton:SetPos( self.Width - 210, pnl:GetParent():GetTall() - 53 ) + self.EditButton:SetText( "Edit" ) + self.EditButton:SetDisabled( true ) + self.EditButton.DoClick = function() + editAdInput = vgui.Create("EditAdPanel", pnl) + end + + self.ToggleButton = vgui.Create( "DButton", pnl ) + self.ToggleButton:SetSize( 60, 22 ) + self.ToggleButton:SetPos( self.Width - 145, pnl:GetParent():GetTall() - 53 ) + self.ToggleButton:SetText( "Toggle" ) + self.ToggleButton:SetDisabled( true ) + self.ToggleButton.DoClick = function() + if self.AdList:GetLines() && #self.AdList:GetSelected() > 0 then + local id = self.AdList:GetSelected()[1]:GetValue(1) + RunConsoleCommand("ev", "advert3", "toggle", id) + adverts[id]["OnState"] = !adverts[id]["OnState"] + self.AdList:GetSelected()[1]:SetValue(5, adverts[id]["OnState"]) + else + evolve:Notify(LocalPlayer(), evolve.colors.red, "Nothing selected!") + end + end + + self.RemoveButton = vgui.Create( "DButton", pnl ) + self.RemoveButton:SetSize( 60, 22 ) + self.RemoveButton:SetPos( self.Width - 80, pnl:GetParent():GetTall() - 53 ) + self.RemoveButton:SetText( "Remove" ) + self.RemoveButton:SetDisabled( true ) + self.RemoveButton.DoClick = function() + if self.AdList:GetSelected() && #self.AdList:GetSelected() > 0 then + local id = self.AdList:GetSelected()[1]:GetValue(1) + RunConsoleCommand("ev", "advert3", "remove", id) + adverts[id] = nil + end + self:Update() + end + timer.Simple(1.5, function() TAB:Request() end) + end + + function TAB:Update() + local oldSelectedId = 0 + local selectLine + if self.AdList:GetSelected() && #self.AdList:GetSelected() > 0 then + oldSelectedId = self.AdList:GetSelected()[1]:GetValue(1) + end + self.AdList:Clear() + for id,data in pairs(adverts) do + local line = self.AdList:AddLine( id, data.Colour["r"]..","..data.Colour["g"]..","..data.Colour["b"], data.Time, data.Msg, tostring(data.OnState)); + if(id == oldSelectedId ) then + selectLine = line + end + end + if(#self.AdList:GetLines() > 0) then + self.EditButton:SetDisabled( false ) + self.ToggleButton:SetDisabled( false ) + self.RemoveButton:SetDisabled( false ) + if(selectLine) then + self.AdList:SelectItem(selectLine) + else + self.AdList:SelectFirstItem() + end + else + self.EditButton:SetDisabled( true ) + self.ToggleButton:SetDisabled( true ) + self.RemoveButton:SetDisabled( true ) + end + end + + function TAB:Request() + self:GetAdverts() + timer.Simple(2, function() TAB:Update() end) + end + + function TAB:IsAllowed() + return LocalPlayer():EV_HasPrivilege( "Advert 3 Menu" ) + end +end +evolve:RegisterTab( TAB ) \ No newline at end of file diff --git a/lua/ev_menu/tab_maps.lua b/lua/ev_menu/tab_maps.lua new file mode 100644 index 0000000..486c9a0 --- /dev/null +++ b/lua/ev_menu/tab_maps.lua @@ -0,0 +1,94 @@ +local TAB = {} +TAB.Title = "Maps" +TAB.Description = "Change Map." +TAB.Author = "Divran" +TAB.Width = 520 +TAB.Icon = "map" + +function TAB:Update() end + +function TAB:ChangeLevel( what ) + local map = self.MapList:GetLine(self.MapList:GetSelectedLine()):GetValue(1) + local gamemode = self.GamemodeList:GetLine(self.GamemodeList:GetSelectedLine()):GetValue(1) + if (map != "" and gamemode != "") then + if (what == "both") then + RunConsoleCommand( "ev_changemapandgamemode", map, gamemode ) + elseif (what == "map") then + RunConsoleCommand( "ev_changemapandgamemode", map, GAMEMODE.Name) + elseif (what == "gamemode") then + RunConsoleCommand( "ev_changemapandgamemode", game.GetMap(), gamemode ) + end + end +end + +function TAB:Initialize( pnl ) + + local w,h = self.Width, pnl:GetParent():GetTall() + + self.MapList = vgui.Create( "DListView", pnl ) + self.MapList:SetPos( 0, 2 ) + self.MapList:SetSize( w / 2 - 2, h - 58 ) + self.MapList:SetMultiSelect( false ) + self.MapList:AddColumn("Maps") + local maps, _ = evolve:MapPlugin_GetMaps() + for _, filename in pairs(maps) do + self.MapList:AddLine( filename ) + end + self.MapList:SelectFirstItem() + + self.GamemodeList = vgui.Create("DListView", pnl) + self.GamemodeList:SetPos( w / 2 + 2, 2 ) + self.GamemodeList:SetSize( w / 2 - 4, h - 58 ) + self.GamemodeList:SetMultiSelect( false ) + self.GamemodeList:AddColumn("Gamemodes") + local gamemodes, _ = evolve:MapPlugin_GetGamemodes() + for _, foldername in pairs(gamemodes) do + self.GamemodeList:AddLine( foldername ) + end + self.GamemodeList:SelectFirstItem() + + self.BothButton = vgui.Create("DButton", pnl ) + self.BothButton:SetWide( w / 3 - 2 ) + self.BothButton:SetTall( 20 ) + self.BothButton:SetPos( w * (1/3) , h - 52 ) + self.BothButton:SetText( "Change Map And Gamemode" ) + function self.BothButton:DoClick() + TAB:ChangeLevel( "both" ) + end + + self.MapButton = vgui.Create("DButton", pnl ) + self.MapButton:SetWide( w / 3 - 2 ) + self.MapButton:SetTall( 20 ) + self.MapButton:SetPos( 0 , h - 52 ) + self.MapButton:SetText( "Change Map" ) + function self.MapButton:DoClick() + TAB:ChangeLevel( "map" ) + end + + self.GamemodeButton = vgui.Create("DButton", pnl ) + self.GamemodeButton:SetWide( w / 3 - 2 ) + self.GamemodeButton:SetTall( 20 ) + self.GamemodeButton:SetPos( w * (2/3) , h - 52 ) + self.GamemodeButton:SetText( "Change Gamemode" ) + function self.GamemodeButton:DoClick() + TAB:ChangeLevel( "gamemode" ) + end + + + self.Block = vgui.Create( "DFrame", pnl ) + self.Block:SetDraggable( false ) + self.Block:SetTitle( "" ) + self.Block:ShowCloseButton( false ) + self.Block:SetPos( 0, 0 ) + self.Block:SetSize( w, h ) + self.Block.Paint = function() + surface.SetDrawColor( 46, 46, 46, 255 ) + surface.DrawRect( 0, 0, self.Block:GetWide(), self.Block:GetTall() ) + + draw.SimpleText( "You need the Maps List Plugin ('sh_mapslist.lua') for this tab to work.", "ScoreboardText", self.Block:GetWide() / 2, self.Block:GetTall() / 2 - 20, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) + end + + if ( table.Count(maps) ) then self.Block:SetPos( self.Block:GetWide(), 0 ) end +end + +evolve:RegisterTab( TAB ) diff --git a/lua/ev_menu/tab_ranks.lua b/lua/ev_menu/tab_ranks.lua index 93700f3..9288337 100644 --- a/lua/ev_menu/tab_ranks.lua +++ b/lua/ev_menu/tab_ranks.lua @@ -1,6 +1,7 @@ /*------------------------------------------------------------------------------------------------------------------------- Tab with rank management -------------------------------------------------------------------------------------------------------------------------*/ +require ("player_manager") local TAB = {} TAB.Title = "Ranks" TAB.Description = "Manage ranks." @@ -50,7 +51,6 @@ function TAB:Initialize( pnl ) self.Usergroup:SetText( evolve.ranks[ self.LastRank ].UserGroup or "unknown" ) self.Usergroup.Selected = evolve.ranks[ self.LastRank ].UserGroup or "unknown" end - // Create the privilege filter self.PrivFilter = vgui.Create( "DComboBox", pnl ) self.PrivFilter:SetPos( 0, self.RankList:GetTall() + 84 ) @@ -59,6 +59,7 @@ function TAB:Initialize( pnl ) self.PrivFilter:AddChoice( "Weapons" ) self.PrivFilter:AddChoice( "Entities" ) self.PrivFilter:AddChoice( "Tools" ) + self.PrivFilter:AddChoice( "Player Models" ) self.PrivFilter:ChooseOptionID( 1 ) self.PrivFilter.OnSelect = function( id, value, data ) self.AllToggle = true @@ -81,6 +82,7 @@ function TAB:Initialize( pnl ) if ( self.PrivFilter.Selected == "Weapons" ) then filter = "@" elseif ( self.PrivFilter.Selected == "Entities" ) then filter = ":" elseif ( self.PrivFilter.Selected == "Tools" ) then filter = "#" + elseif ( self.PrivFilter.Selected == "Player Models" ) then filter = "&" end RunConsoleCommand( "ev_setrank", self.RankList:GetSelected()[1].Rank, self.AllToggle and 1 or 0, filter ) @@ -234,7 +236,11 @@ function TAB:PrintNameByClass( class ) return wep.PrintName or class end end - + for mn, pathv in pairs( player_manager.AllValidModels() ) do + if ( class == mn ) then + return mn + end + end for c, ent in pairs( scripted_ents.GetList() ) do if ( c == class ) then return ent.t.PrintName or class @@ -264,10 +270,9 @@ function TAB:UpdatePrivileges() for _, privilege in ipairs( evolve.privileges ) do // Get first character to determine what kind of privilege this is. local prefix = string.Left( privilege, 1 ) - - if ( ( prefix == "@" and self.PrivFilter.Selected == "Weapons" ) or ( prefix == ":" and self.PrivFilter.Selected == "Entities" ) or ( prefix == "#" and self.PrivFilter.Selected == "Tools" ) or ( !string.match( prefix, "[@:#]" ) and ( self.PrivFilter.Selected or "Privileges" ) == "Privileges" ) ) then + if ( ( prefix == "@" and self.PrivFilter.Selected == "Weapons" ) or ( prefix == ":" and self.PrivFilter.Selected == "Entities" ) or ( prefix == "#" and self.PrivFilter.Selected == "Tools" ) or ( prefix == "&" and self.PrivFilter.Selected == "Player Models" ) or ( !string.match( prefix, "[@:&#]" ) and ( self.PrivFilter.Selected or "Privileges" ) == "Privileges" ) ) then local line - if ( string.match( prefix, "[@:]" ) ) then + if ( string.match( prefix, "[@:&]" ) ) then line = self.PrivList:AddLine( self:PrintNameByClass( string.sub( privilege, 2 ) ), "" ) else line = self.PrivList:AddLine( privilege, "" ) @@ -278,16 +283,16 @@ function TAB:UpdatePrivileges() line.State:SetImage( "icon16/tick.png" ) line.State:SetSize( 16, 16 ) line.State:SetPos( self.Width/2 * 0.875 - 12, 1 ) - + line.Think = function() - if ( line.LastRank != self.RankList:GetSelected()[1].Rank ) then line.LastRank = self.RankList:GetSelected()[1].Rank else return end - - line.State:SetVisible( line.LastRank == "owner" or table.HasValue( evolve.ranks[ line.LastRank ].Privileges, privilege ) ) + if ( line.LastRank != self.RankList:GetSelected()[1].Rank ) then line.LastRank = self.RankList:GetSelected()[1].Rank else return end + + line.State:SetVisible( line.LastRank == "owner" or table.HasValue( evolve.ranks[ line.LastRank ].Privileges, privilege ) ) end - + line.OnPress = line.OnMousePressed line.LastPress = os.clock() - + line.OnMousePressed = function() if ( line.LastPress + 0.3 > os.clock() and LocalPlayer():EV_HasPrivilege( "Rank modification" ) ) then if ( line.State:IsVisible() ) then @@ -295,10 +300,10 @@ function TAB:UpdatePrivileges() else RunConsoleCommand( "ev_setrank", line.LastRank, privilege, 1 ) end - - line.State:SetVisible( !line.State:IsVisible() ) + + line.State:SetVisible( !line.State:IsVisible() ) end - + line.LastPress = os.clock() line:OnPress() end diff --git a/lua/ev_menu/tab_sandbox.lua b/lua/ev_menu/tab_sandbox.lua deleted file mode 100644 index a2e76ad..0000000 --- a/lua/ev_menu/tab_sandbox.lua +++ /dev/null @@ -1,139 +0,0 @@ -/*------------------------------------------------------------------------------------------------------------------------- - Tab with sandbox settings --------------------------------------------------------------------------------------------------------------------------*/ - -local TAB = {} -TAB.Title = "Sandbox" -TAB.Description = "Manage sandbox settings." -TAB.Icon = "world" -TAB.Author = "Overv" -TAB.Width = 520 -TAB.Privileges = { "Sandbox menu" } - -TAB.Limits = { - { "sbox_maxprops", "Props" }, - { "sbox_maxragdolls", "Ragdolls" }, - { "sbox_maxvehicles", "Vehicles" }, - { "sbox_maxeffects", "Effects" }, - { "sbox_maxballoons", "Balloons" }, - { "sbox_maxnpcs", "NPCs" }, - { "sbox_maxdynamite", "Dynamite" }, - { "sbox_maxlamps", "Lamps" }, - { "sbox_maxlights", "Lights" }, - { "sbox_maxwheels", "Wheels" }, - { "sbox_maxthrusters", "Thrusters" }, - { "sbox_maxhoverballs", "Hoverballs" }, - { "sbox_maxbuttons", "Buttons" }, - { "sbox_maxemitters", "Emitters" }, - { "sbox_maxspawners", "Spawners" }, - { "sbox_maxturrets", "Turrets" } -} -TAB.ConVars = { - { "sbox_godmode", "Godmode" }, - { "sbox_noclip", "Noclip" }, - { "sbox_playershurtplayers", "PvP" }, - { "sbox_weapons", "Weapons" }, - { "g_ragdoll_maxcount", "Keep NPC bodies", 8 } -} -TAB.ConVarSliders = {} -TAB.ConVarCheckboxes = {} - -local function round(n) - if n % 1 < 0.5 then - return math.floor(n) - else - return math.ceil(n) - end -end - -function TAB:IsAllowed() - return LocalPlayer():EV_HasPrivilege( "Sandbox menu" ) -end - -function TAB:Initialize( pnl ) - self.LimitsContainer = vgui.Create( "DPanelList", pnl ) - self.LimitsContainer:SetPos( 2, 2 ) - self.LimitsContainer:SetSize( self.Width - 164, pnl:GetParent():GetTall() - 32 ) - self.LimitsContainer:SetSpacing( -5 ) - self.LimitsContainer:SetPadding( 10 ) - self.LimitsContainer:EnableHorizontal( true ) - self.LimitsContainer:EnableVerticalScrollbar( true ) - self.LimitsContainer.Paint = function( self ) - draw.RoundedBox( 4, 2, 2, self:GetWide() - 6, self:GetTall() - 12, Color( 230, 230, 230, 255 ) ) - end - - for i, cv in pairs( self.Limits ) do - if ( ConVarExists( cv[1] ) ) then - local cvSlider = vgui.Create( "DNumSlider", pnl ) - cvSlider:SetText( cv[2] ) - cvSlider:SetWide( self.LimitsContainer:GetWide() - 7 ) - cvSlider:SetMin( 0 ) - cvSlider:SetMax( 200 ) - cvSlider:SetDecimals( 0 ) - cvSlider:SetValue( GetConVar( cv[1] ):GetInt() ) - cvSlider.ConVar = cv[1] - - local scratch_released = cvSlider.Scratch.OnMouseReleased - local slider_released = cvSlider.Slider.OnMouseReleased - local knob_released = cvSlider.Slider.Knob.OnMouseReleased - - local function mousereleased(mousecode) - RunConsoleCommand("ev", "convar", cv[1], round(cvSlider:GetValue())) - end - - function cvSlider.Scratch:OnMouseReleased(mousecode) - mousereleased(mousecode) - scratch_released(cvSlider.Scratch, mousecode) - end - - function cvSlider.Slider:OnMouseReleased(mousecode) - mousereleased(mousecode) - slider_released(cvSlider.Slider, mousecode) - end - - function cvSlider.Slider.Knob:OnMouseReleased(mousecode) - mousereleased(mousecode) - knob_released(cvSlider.Slider.Knob, mousecode) - end - - cvSlider.Label:SetDark(true) - self.LimitsContainer:AddItem( cvSlider ) - - table.insert( self.ConVarSliders, cvSlider ) - end - end - - self.Settings = vgui.Create( "DPanelList", pnl ) - self.Settings:SetPos( self.Width - 165, 2 ) - self.Settings:SetSize( 166, pnl:GetParent():GetTall() - 32 ) - self.Settings:SetSpacing( 9 ) - self.Settings:SetPadding( 10 ) - self.Settings:EnableHorizontal( true ) - self.Settings:EnableVerticalScrollbar( true ) - self.Settings.Paint = function( self ) - draw.RoundedBox( 4, 4, 2, self:GetWide() - 16, self:GetTall() - 12, Color( 230, 230, 230, 255 ) ) - end - - for i, cv in pairs( self.ConVars ) do - if ( ConVarExists( cv[1] ) ) then - local cvCheckbox = vgui.Create( "DCheckBoxLabel", self.Settings ) - cvCheckbox:SetText( cv[2] ) - cvCheckbox:SetWide( self.Settings:GetWide() - 15 ) - cvCheckbox:SetValue( GetConVar( cv[1] ):GetInt() > 0 ) - cvCheckbox.ConVar = cv[1] - cvCheckbox.OnChange = function( self, val ) - RunConsoleCommand( "ev", "convar", cv[1], evolve:BoolToInt( val ) * ( cv[3] or 1 ) ) - end - cvCheckbox.Label:SetDark(true) - self.Settings:AddItem( cvCheckbox ) - - table.insert( self.ConVarCheckboxes, cvCheckbox ) - end - end -end - -if ( CLIENT and GAMEMODE.IsSandboxDerived ) then - evolve:RegisterTab( TAB ) -elseif ( SERVER ) then - evolve:RegisterTab( TAB ) -end diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua new file mode 100644 index 0000000..c3a85f1 --- /dev/null +++ b/lua/ev_menu/tab_settings.lua @@ -0,0 +1,618 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Tab with settings +-------------------------------------------------------------------------------------------------------------------------*/ + +--[[ + @TODO: settings in general + x Implement setting domains (server/client/shared -- do domain checks so that one user can't overwrite the settings of another with higher privs) + x Bind settings to permissions. + x Implement string validators. + x Search feature by building a list of "searchable" text that references the tree node, will require buildcategories to make each setting and put it in the grave. + x Better behavior for handling pre-existing settings when registering plugins. Delay the initial request for settings? + x Either make evolve:SaveSettings() only available to the server or let the client have access to von so they can save a copy as well. + x Make a server version of evolve:SetSetting() + x Provide a TAB:Update() method that can rebuild the current view + @TODO: framework overhaul + * make autocomplete wrap spaces around a name with spaces in it + * make FindPlayers match registered users that are offline +]] + +local TAB = {} +TAB.Title = "Settings" +TAB.Description = "Manage evolution settings and preferences." +TAB.Icon = "page_edit" +TAB.Author = "EntranceJew" +TAB.Width = 520 +TAB.Privileges = { "Settings", "Settings: Modify", "Settings: Send To Server" } + +TAB.CatWidth = 166 + +TAB.Frame = nil +TAB.SearchBox = nil +TAB.SearchButton = nil +TAB.SettingsTree = nil +--[[ + this is mapped: + global.nodes['category1'].nodes['category2'] + which references settings items by key: + global.nodes['category1'].items['sbox_maxvehicles'] +]] +TAB.Scroll = nil +TAB.Layout = nil +TAB.GraveYard = nil + +TAB.CurrentTree = {"General", "Misc"} + + +TAB.Controls = {} +--[[ + this is mapped: + global['num_corns'] +]] + +local testsettings = { + category_general = { + label = 'General', + desc = 'This is for general evolve settings.', + stype = 'category', + icon = 'page_edit', + value = { + category_misc = { + label = 'Misc', + desc = 'Miscelaneous is hard to spell.', + stype = 'category', + icon = 'rainbow', + value = { + a_color = { + label = 'A Color', + desc = '5/8ths of my friends have a form of color blindness.', + stype = 'color', + alpha = false, + default = Color( 0, 110, 160, 255 ), + }, + num_corns = { + label = 'No. Corns', + desc = 'How many corns? This many.', + stype = 'limit', + min = 25, + max = 75, + default = 50, + }, + num_horns = { + label = 'No. Horns', + desc = 'Remember, we are on a budget.', + stype = 'limit', + min = -3, + max = 30, + default = 1, + }, + resync_name = { + label = 'Sync Again Label', + desc = 'Can you not decide what to call it?', + stype = 'string', + default = 'reSync', + }, + best_name = { + label = 'Best Name', + desc = 'Who is the best?', + stype = 'string', + default = 'Bungalo', + }, + is_great = { + label = 'Is Great', + desc = 'Are you having trouble finding out?', + stype = 'bool', + default = true, + }, + }, + }, + category_settings = { + label = 'Settings', + desc = "Control how your settings control other things.\nThis is going to get confusing fast.", + stype = 'category', + icon = 'wrench', + value = { + settings_overload_servercfg = { + label = 'Overload server.cfg', + desc = 'If enabled, this will the LoadSettings to execute after server.cfg -- overwriting any values defined there.', + stype = 'bool', + default = true, + }, + settings_plugin_blacklist = { + label = 'Blacklist plugins (seperated by comma)', + desc = 'These plugins will skip loading on next map change. Use only the part of filename between cl_, sh_, sv_ and .lua', + stype = 'string', + default = '', + }, + }, + }, + }, + }, +} +--[[for i=1,16 do + local set = { + label = 'Test Setting #'..i, + desc = 'Testing out item '..i..', huh?', + stype = 'bool', + value = true, + default = false + } + + testsettings.category_general.value.category_misc.value["test_set"..i]=set +end]] + +evolve:RegisterSettings( testsettings ) + +function TAB:IsAllowed() + return LocalPlayer():EV_HasPrivilege( "Settings" ) +end + +function TAB:CreateColor( pnl, name, item ) + if item.isconvar and !ConVarExists( name ) then + return false + end + + -- this control is special because we need a method to collapse it back to its original state + local helm = vgui.Create( "DButton", pnl ) + helm:SetText( item.label ) + helm:SetTooltip( item.desc ) + helm:SetSize( 135, 32 ) + helm:SetDark(true) + helm:Dock( LEFT ) + pnl.Label = helm + + local parent = self + function pnl:makeColorMixer() + self.expandStatus = true + if self.ColorButton ~= nil then + self.ColorButton:Remove() + self.ColorButton = nil + end + self.Label.DoClick = function() pnl:makeColorButton(self) end + local elm = vgui.Create( "DColorMixer", self ) + local size = 92 + if !item.alpha then + size = 68 + end + self:SetTall( size ) + elm:SetSize( 193, size ) + -- 68 tall = just enough for RGB wangs + -- 92 tall = big enough for RGBA wangs + + elm:Dock( RIGHT ) --Make Mixer fill place of Frame + elm:SetPalette( false ) --Show/hide the palette DEF:true + elm:SetAlphaBar( item.alpha ) --Show/hide the alpha bar DEF:true + elm:SetWangs( true ) --Show/hide the R G B A indicators DEF:true + elm:SetColor( evolve:GetSetting(name) ) --Set the default color]] + -- we're gonna need some way of telling when the player is done with this + elm.ValueChanged = function(self, color) + evolve:SetSetting(name, color) + end + + self.ColorMixer = elm + parent.Layout:SetSize(parent.Scroll:GetSize()) + end + + function pnl:makeColorButton() + self.expandStatus = false + if self.ColorMixer ~= nil then + self.ColorMixer:Remove() + self.ColorMixer = nil + end + self.Label.DoClick = function() pnl:makeColorMixer(self) end + local elm = vgui.Create( "DColorButton", self ) + self:SetTall( 32 ) + elm:SetSize( 193, 32 ) + local clr = evolve:GetSetting(name) + elm:SetText("Color( "..clr.r..", "..clr.g..", "..clr.b..", "..clr.a.." )") + -- we can't set the tooltip because the button auto-updates the tooltip \o/ + --elm:SetTooltip( item.desc ) + elm:SetColor( clr ) + elm:Dock( LEFT ) + elm.DoClick = function() pnl:makeColorMixer(self) end + self.ColorButton = elm + parent.Layout:SetSize(parent.Scroll:GetSize()) + end + + -- this is so we have the ability to re-open to either state, although this won't work at present + if pnl.expandStatus then + pnl:makeColorMixer() + else + pnl:makeColorButton() + end + + return pnl +end + +-- functions used by buildsettings +function TAB:CreateLimit( pnl, name, item ) + --@WARNING: This won't update properly if the element + if item.isconvar then + if ConVarExists( name ) then + --@TODO: Make it so that the server auto-executes these + --item.value = GetConVarNumber( name ) + --evolve:GetSetting(name, 0) + else + -- no fake convars allowed + return false + end + end + local elm = vgui.Create( "DNumSlider", pnl ) + pnl:SetTall(32) + elm:SetTall(32) + elm:SetText( item.label ) + elm:SetWide( pnl:GetWide() ) + elm:SetTooltip( item.desc ) + elm:SetMin( item.min ) + elm:SetMax( item.max ) + elm:SetDecimals( 0 ) + elm:SetValue( item.value ) + elm.Label:SetDark(true) + self:SetFocusCallbacks( elm.TextArea ) + elm.TextArea.OnEnter = mousereleased + pnl.NumSlider = elm.TextArea + + -- boring handler overloading + local function mousereleased(mousecode) + evolve:SetSetting(name, math.Round(elm:GetValue())) + end + + local scratch_released = elm.Scratch.OnMouseReleased + local slider_released = elm.Slider.OnMouseReleased + local knob_released = elm.Slider.Knob.OnMouseReleased + + function elm.Scratch:OnMouseReleased(mousecode) + mousereleased(mousecode) + scratch_released(elm.Scratch, mousecode) + end + + function elm.Slider:OnMouseReleased(mousecode) + mousereleased(mousecode) + slider_released(elm.Slider, mousecode) + end + + function elm.Slider.Knob:OnMouseReleased(mousecode) + mousereleased(mousecode) + knob_released(elm.Slider.Knob, mousecode) + end + + return pnl +end + +function TAB:CreateString( pnl, name, item ) + if item.isconvar then + if ConVarExists( name ) then + --item.value = GetConVarString( name ) + --item already has value given from server + else + -- no fake convars allowed + return false + end + end + local helm = vgui.Create( "DLabel", pnl ) + helm:SetWide(135) + helm:SetText( item.label ) + helm:SetTooltip( item.label ) + helm:SetDark(true) + helm:Dock( LEFT ) + + local elm = vgui.Create( "DTextEntry", pnl ) + --elm:SetSize( 227, 32 ) + elm:SetWide(193) + elm:SetTooltip( item.desc ) + elm:SetValue( item.value ) + elm:Dock( RIGHT ) + self:SetFocusCallbacks( elm ) + pnl.Label = helm + pnl.TextEntry = elm + + -- boring handler overloading + local parent = self + elm.OnEnter = function(self) + evolve:SetSetting(name, self:GetValue()) + end + + return pnl +end + +function TAB:CreateBool( pnl, name, item ) + --[[ + g_ragdoll_maxcount = { + label = "Keep NPC bodies", + desc = "Toggle.", + stype = "bool", + default = 0, + multiplier = 8, + isconvar = true, + }, + ]] + if item.isconvar then + if ConVarExists( name ) then + --item.value = GetConVarNumber( name ) + else + -- no fake convars allowed + return false + end + end + local helm = vgui.Create( "DLabel", pnl ) + helm:SetWide(135) + helm:SetText( item.label ) + --helm:SetSize( 135, 32 ) + helm:SetTooltip( item.desc ) + helm:SetDark(true) + helm:Dock( LEFT ) + + elm = vgui.Create( "DCheckBox", pnl ) + elm:SetTall(16) + --elm:SetSize( 32, 32 ) + elm:SetTooltip( item.desc ) + elm:SetValue( item.value ) + elm:Dock( LEFT ) + pnl.Label = helm + pnl.CheckBox = elm + + -- boring handler overloading + local parent = self + elm.OnChange = function(self) + evolve:SetSetting(name, self:GetChecked()) + end + + return pnl +end + +--[[TAB:Update()]] + +function TAB:BuildCategories( atree, aset, adepth ) + --[[ Mission: + 1) Create all the "self.SettingsTree" nodes. + 2) Set an event so that when the node is clicked it calls OpenToPath( tblPath ) + 3) Expand "Categories" lookup table. + ]] + --self:BuildCategories2( self.SettingsTree, evolve.settings, self.Categories ) + --self:BuildCategories( self.SettingsTree, evolve.settings, self.Categories ) + --print("DEBUG: BuildCategories2 -- entering") + + local tree = atree + local set = aset + local path = {} + --[[if type(apath)=="string" then + path = string.Explode("\\", apath) + if table.maxn(path) == 1 and path[1]==apath then + print("DEBUG: BuildCategories2 -- 'apath' was a string but couldn't be exploded: '"..apath.."'") + end + elseif apath==nil then + print("DEBUG: BuildCategories2 -- 'apath' was nil, leaving 'path' as empty table.") + end]] + local depth = adepth or 1 + if adepth~= nil then + --print("DEBUG: BuildCategories2 -- 'adepth' wasn't nil, incrementing.") + depth = adepth+1 + else + --print("DEBUG: BuildCategories2 -- 'adepth' was nil, at entrypoint depth.") + end + + + assert(tree~=nil, "GOT NIL IN PLACE OF TREE NODE") + --print("DEBUG: BuildCategories2 -- Investigating tree.") + --PrintTable(tree) + if tree.nodes==nil then + --print("DEBUG: BuildCategories2 -- 1: Tree @ depth has no nodes, adding node stub.") + tree.nodes={} + else + --print("DEBUG: BuildCategories2 -- 2: Tree @ depth has nodes, we must be in an item with multiple children.") + end + + if tree.items==nil then + tree.items={} + else + --same as above. + end + + assert(istable(set), "GOT NON-TABLE SETTINGS") + --print("DEBUG: BuildCategories2 -- Beginning settings iteration in table shaped like:") + --PrintTable(set) + for k,v in pairs(set) do + if v.stype==nil then + --print("DEBUG: BuildCategories2 -- Ignoring malformed element '"..k.."' ...") + else + --print("DEBUG: BuildCategories2 -- Inside setting '"..v.label.."' of type '"..v.stype.."'...") + if v.stype == 'category' then + local node = tree:AddNode( v.label ) + node:SetIcon( "icon16/"..v.icon..".png" ) + node:SetTooltip( v.desc ) + node.ej_parent = v.label + + local parent = self + node.DoClick = function(self) + --print("doclick: "..v.label.." got clicked on @ depth # "..depth) + local dpath = {} + local brk = true + local work = self + while brk do + if work.ej_parent~= nil then + --print("doclick: added '"..work.ej_parent.."' to stack") + table.insert(dpath, 1, work.ej_parent) + else + --print("doclick: couldn't find attribute ej_parent, assumed done") + brk = false + end + work = work:GetParentNode() + end + parent.CurrentTree = dpath + parent:BuildSettings( dpath ) + end + + -- add tree child + tree.nodes[v.label] = node + + --print("DEBUG: BuildCategories2 -- Recursing!!!") + self:BuildCategories( tree.nodes[v.label], v.value, depth ) + --print("DEBUG: BuildCategories2 -- Returned from recursion!!!") + else + table.insert(tree.items, k) + --print("DEBUG: BuildCategories2 -- Ignoring non-category '"..v.label.."' of type '"..v.stype.."'.") + end + end + end + --print("DEBUG: BuildCategories2 -- Iterated over all items at current depth of '"..depth.."'") +end + + +function TAB:BuildSettings( tblPath ) + --print("DEBUG: BuildSettings -- entering...") + for k,v in pairs(self.Controls) do + if v:IsValid() then + if v:GetParent() == self.Layout then + --print("DEBUG: BuildSettings -- existing control '"..k.."' moved to grave.") + v:SetParent(self.GraveYard) + v:Remove() + v=nil + elseif v:GetParent() == self.GraveYard then + --print("DEBUG: BuildSettings -- control '"..k.."' was already in the grave.") + else + assert(false, "RENEGADE CONTROL: "..k) + end + else + --assert(false, "UNDEAD CONTROL ESCAPED GRAVEYARD: "..k) + v=nil + --print("DEBUG: BuildSettings -- invalid control '"..k.."' erased.") + end + end + -- since we graved all the children, we should refresh the shape of our scrollbar + self.Layout:SetSize(self.Scroll:GetSize()) + + local settings = self.SettingsTree + for _,v in pairs(tblPath) do + if settings.nodes[v]==nil then + --print("DEBUG: BuildSettings -- "..v.." NON-BREAK ("..table.concat(tblPath, "\\")..")") + elseif v~='nodes' then + -- we do not want to step into the 'sets' category by itself + settings = settings.nodes[v] + elseif v=='nodes' then + assert(false, "UH OH, SOMEONE TOLD US TO STEP INTO THE 'nodes' CATEGORY, THEY'RE A BAD MAN.") + end + --print("DEBUG: BuildSettings -- settings=self.Categories."..v.."==nil; BREAK ("..table.concat(tblPath, "\\")..")") + end + --print("DEBUG: Dumping contents of 'settings'.") + --PrintTable(settings) + + for k,v in pairs(settings.items) do + --x@TODO: We might want to make sure that this isn't infinitely orphaning children elsewhere. + local item = evolve.settings[v] + --print("DEBUG: BuildSettings -- created new element stub: '"..k.."'") + local step = vgui.Create( "DPanel", self.Layout ) + step:SetWide( self.Layout:GetWide()-20 ) + step:SetTall(32) + + local temp = {} + if item.stype == 'limit' then + temp = self:CreateLimit( step, v, item ) + elseif item.stype == 'string' then + temp = self:CreateString( step, v, item ) + elseif item.stype == 'bool' then + temp = self:CreateBool( step, v, item ) + elseif item.stype == 'color' then + temp = self:CreateColor( step, v, item ) + else + -- the element wasn't what we wanted, so trash it + step:Remove() + end + + if !temp then + -- Create* returned nothing so we should trash this + step:Remove() + else + -- everything was fine so let's keep at it + self.Controls[v] = temp + end + --print("DEBUG: BuildSettings -- finalized element: '"..k.."'") + end +end + +function TAB:SetFocusCallbacks( elm ) + elm.OnGetFocus = function() + self.Panel:GetParent():GetParent():SetKeyboardInputEnabled(true) + end + elm.OnLoseFocus = function() + self.Panel:GetParent():GetParent():SetKeyboardInputEnabled(false) + end +end + +function TAB:OpenToPath( tblPath ) + local depth = self.SettingsTree.nodes + for _,v in pairs(tblPath) do + self.SettingsTree:SetSelectedItem(depth[v]) + if depth[v]==nil then + break + end + depth[v]:SetExpanded(true, true) + depth = depth[v].nodes + end + self:BuildSettings( tblPath ) +end + + +function TAB:Initialize( pnl ) + glb = self + -- [[ for shorthand reaching for sets via category { "General", "Misc" } + + self.SearchPanel = vgui.Create("DPanel", pnl) + self.SearchPanel:SetSize( self.CatWidth, pnl:GetParent():GetTall() - 58 ) --@MAGIC + self.SearchPanel:Dock(LEFT) + --SetSize( 520, 490 ) + + self.SearchBox = vgui.Create( "DTextEntry", self.SearchPanel ) -- create the form as a child of frame + self.SearchBox:Dock(TOP) + self.SearchBox:DockMargin( 4, 2, 4, 2 ) + self.SearchBox:SetTooltip( "Press enter to search settings." ) + self.SearchBox.OnEnter = function( self ) + --print( 'SETTINGS SEARCH: '..self:GetValue() ) -- print the form's text as server text + end + self:SetFocusCallbacks( self.SearchBox ) + + self.SearchButton = self.SearchBox:Add( "DImageButton" ) + self.SearchButton:Dock( RIGHT ) + self.SearchButton:DockMargin( 0, 2, 0, 2 ) + --TAB.SearchButton:SetPos( 2+TAB.SearchBox:GetWide()-16, glob.constantHeight+2 ) + self.SearchButton:SetSize( 16, 16 ) + self.SearchButton:SetImage( "icon16/find.png" ) + self.SearchButton:SetText( "" ) + self.SearchButton:SetTooltip( "Press to search settings." ) + self.SearchButton.DoClick = function() + self.SearchBox:OnEnter() + end + + self.SettingsTree = vgui.Create( "DTree", self.SearchPanel ) + --self.SettingsTree:SetPos( 0, self.SearchBox:GetTall()+2 ) + self.SettingsTree:Dock(TOP) + self.SearchButton:DockMargin( 4, 2, 4, 2 ) + self.SettingsTree:SetPadding( 4 ) + --self.SettingsTree:SetTall(430) + self.SettingsTree:SetSize( self.CatWidth, self.SearchPanel:GetTall()-4) + --self.SettingsTree:SetSize( self.CatWidth, self.SearchPanel:GetTall()-self.SearchBox:GetTall()-4) + + self.Scroll = vgui.Create( "DScrollPanel", self.Panel ) + self.Scroll:Dock(RIGHT) + self.Scroll:SetSize( self.Width-self.CatWidth-8, self.Panel:GetParent():GetTall()-3) --@MAGIC 3 + + self.Layout = vgui.Create( "DIconLayout", self.Scroll ) + --self.Layout:SetSize( self.Scroll:GetSize() ) + self.Layout:SetTall(self.Scroll:GetTall()) + self.Layout:SetWide(self.Scroll:GetWide()-20) + --self.Layout:SetPos(0, 0) + self.Layout:SetSpaceX(0) + self.Layout:SetSpaceY(5) + + -- WORKAROUND BECAUSE DERMA DOESN'T ALWAYS DELETE ITS CHILDREN + self.GraveYard = vgui.Create( "DPanel" ) + self.GraveYard:SetSize( 0, 0 ) + self.GraveYard:SetPos(-1000, -1000) + + self:BuildCategories( self.SettingsTree, evolve.settingsStructure ) +end + +function TAB:Update() + self:OpenToPath( self.CurrentTree ) +end + +evolve:RegisterTab( TAB ) \ No newline at end of file diff --git a/lua/ev_menu/tab_v_maps.lua b/lua/ev_menu/tab_v_maps.lua new file mode 100644 index 0000000..57f38a5 --- /dev/null +++ b/lua/ev_menu/tab_v_maps.lua @@ -0,0 +1,203 @@ + +local TAB = {} +TAB.Title = "Maps" +TAB.Description = "Used to change maps." +TAB.Icon = "arrow_refresh" +TAB.Author = "MDave" --Edited by MadDog, GeneralWrex and X-Coder +TAB.Width = 500 +TAB.Privileges = { "Maps Menu" } +TAB.ToUpdate = nil + +if ( SERVER ) then + TAB.Maplist = file.Find( "maps/*.bsp", "GAME" ) + + local function StreamMaps( ply , command , args ) + for _,v in ipairs( TAB.Maplist ) do + umsg.Start( "EV_AvalibleMap" , ply ) + umsg.String( v ) + umsg.End() + end + end + concommand.Add( "ea_streammaps" , StreamMaps) + +else + TAB.Maplist = {} + + local function GetMaps( um ) + local map = um:ReadString() + if ( !table.HasValue( TAB.Maplist , map) ) then + table.insert( TAB.Maplist , map ) + TAB.ToUpdate = map + TAB:Update() + end + end + usermessage.Hook( "EV_AvalibleMap" , GetMaps ) + +end + + +function TAB:SetCurrentMapicon( map ) + if ( map == nil ) then + map = game.GetMap() + end + + + self.MapIcon:SetImage("maps/"..map..".png") + self.MapIcon:SizeToContents() + self.MapIcon.mappath = map + + self.MapLabel:SetText( map ) + self.MapLabel:SizeToContents() + + local i_x , i_y = self.MapIcon:GetSize() + self.MapIconBckg:SetSize( i_x +4 , i_y ) + self.MapIconBckg:Center() + self.MapIcon:SetSize( i_x , i_y -25 ) + + local l_x , l_y = self.MapLabel:GetSize() + self.MapLabel:SetPos( i_x/2 - l_x/2 , i_y -20 ) + +end + +function TAB:AddMapCategory( name ) + for _,v in ipairs( self.Maps.CatPanels ) do + if ( v.name == name )then return v.Container end + end + + --Copy paste from player controls :) + i = #self.Maps.CatPanels +1 + + self.Maps.CatPanels[i] = vgui.Create( "DCollapsibleCategory", self.Maps ) + self.Maps.CatPanels[i]:SetTall( 22 ) + self.Maps.CatPanels[i]:SetExpanded( 0 ) + self.Maps.CatPanels[i]:SetLabel( name ) + + self.Maps.CatPanels[i].Container = vgui.Create( "DPanelList", self.Maps.CatPanels[i] ) + self.Maps.CatPanels[i].Container:SetAutoSize( true ) + self.Maps.CatPanels[i].Container:SetSpacing( 5 ) + self.Maps.CatPanels[i].Container:SetPadding( 5 ) + self.Maps.CatPanels[i].Container:EnableHorizontal( true ) + self.Maps.CatPanels[i].Container:EnableVerticalScrollbar( true ) + self.Maps.CatPanels[i]:SetContents( self.Maps.CatPanels[i].Container ) + + self.Maps.CatPanels[i].name = name + self.Maps:AddItem( self.Maps.CatPanels[i] ) + return self.Maps.CatPanels[i].Container +end + + +function TAB:Initialize( pnl ) + RunConsoleCommand( "ea_streammaps" ) + + self.IconPanel = vgui.Create( "DPanel" , pnl ) + self.IconPanel:SetPos( 2 , 2 ) + self.IconPanel:SetSize( self.Width -10 , pnl:GetParent():GetTall()*.23 -20 ) + self.IconPanel.m_bgColor = Color(80 , 80 , 80 , 255) + + self.MapIconBckg = vgui.Create( "DPanel" , self.IconPanel ) + self.MapIconBckg.m_bgColor = Color( 255 , 155 , 20 , 255 ) + + self.MapIcon = vgui.Create( "DImageButton", self.MapIconBckg ) + self.MapIcon:SetPos( 2, 2 ) + self.MapIcon:SetKeepAspect( true ) + self.MapIcon.DoClick = function() + if ( LocalPlayer():EV_HasPrivilege( "Map changing" ) ) then + RunConsoleCommand( "ev" , "map" , self.MapIcon.mappath ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end + end + + self.MapLabel = vgui.Create( "DLabel" , self.MapIconBckg ) + self.MapLabel.m_colText = Color( 255 , 255, 255 , 255) + + self:SetCurrentMapicon( nil ) + + self.Maps = vgui.Create( "DPanelList", pnl ) + self.Maps:SetPos(2, pnl:GetParent():GetTall()*.3 ) + self.Maps:SetSize( self.Width -10 , pnl:GetParent():GetTall()*.7 - 10 ) + + self.Maps:EnableVerticalScrollbar(true) + self.Maps:EnableHorizontal(false) + self.Maps:SetPadding( 1 ) + self.Maps:SetSpacing( 1 ) + self.Maps.CatPanels = {} + + --Map categorysing: + self.Hidden = { "credits" } + + self.Cats = { + { name = "hidden" , patterns = { "background", "^test_", "^styleguide", "^devtest" , "intro" } }, + { name = "Garrysmod" , patterns = {"^gm_"} }, + { name = "Portal" , patterns = {"^escape_" , "^testchmb_"} }, + { name = "Portal 2" , patterns = {"^mp_coop_" , "^sp_"} }, + { name = "Half life 2" , patterns = {"^d1_","^d2_","^d3_"} }, + { name = "Half life 2 Epsiode 1" , patterns = {"^ep1_"} }, + { name = "Half life 2 Epsiode 2" , patterns = {"^ep2_"} }, + { name = "Counter Strike Source" , patterns = {"^de_" , "^cs_" , "^es_" } }, + { name = "Team Fortress 2" , patterns = {"^arena_" , "^cp_" , "ctf_" , "pl_" , "plr_" , "tc_" , "koth_" , "tr_"} }, + { name = "Half life 2 Deatmatch" , patterns = {"^dm_"}}, + { name = "Spacebuild" , patterns = {"^sb_","^gm_space"}}, + { name = "Stargate" , patterns = {"^sg_","^sg1_"}} + } + + + +-- Make the buttons-- +function MakeMapButton(text) + local noadd = false + local btn = vgui.Create( "DButton" ) + btn:SetSize( self.Maps:GetWide()/2-20, 20 ) + btn:SetText( text ) + + btn.mappath = string.sub( text , 1 , string.len(text)-4 ) + btn.category = nil + + btn.DoClick = function() + TAB:SetCurrentMapicon( btn.mappath ) + end + + --Categorize the button. + for _,v in ipairs( self.Cats ) do + local exploded = string.Explode( "_" , btn.mappath ) + if ( !table.HasValue( self.Hidden , btn.mappath ) ) then + if ( v.patterns != nil )then + for _,patt in ipairs( v.patterns ) do + if ( string.find( btn.mappath, patt ) ) then + btn.category = v.name + noadd = ( v.name == "invalid" ) or ( v.name == "hidden" ) + break + end + end + end + else + noadd = true + end + end + + if ( !noadd ) then + if ( btn.category == nil ) + then btn.category = "Misc" + end + local container = self:AddMapCategory( btn.category ) + btn:SetParent( container ) + container:AddItem( btn ) + else + btn:Remove() + end +end + +end + +function TAB:Update() + if ( self.ToUpdate != nil ) then + MakeMapButton( self.ToUpdate ) + self.ToUpdate = nil + end +end + +function TAB:IsAllowed() + return LocalPlayer():EV_HasPrivilege( "Map changing" ) +end + +evolve:RegisterTab( TAB ) diff --git a/lua/ev_plugins/sh_advert3.lua b/lua/ev_plugins/sh_advert3.lua new file mode 100644 index 0000000..5d2cb0e --- /dev/null +++ b/lua/ev_plugins/sh_advert3.lua @@ -0,0 +1,129 @@ +local PLUGIN = {} +PLUGIN.Title = "Advert3" +PLUGIN.Description = "Add, remove, modify adverts." +PLUGIN.Author = "SariaFace" +PLUGIN.ChatCommand = "advert3" +PLUGIN.Usage = "[add;remove;list;toggle][advert id][r][g][b][interval][state][message]" +PLUGIN.Privileges = { "Advert 3" } + +if (SERVER) then + local adFileName= "evolve/adverts.txt" + local function writeToFile(data) + file.Write(adFileName, evolve.von.serialize(data)) + end + + adverts = {} + adverts.Stored = {} + if (#file.Find(adFileName,"DATA") > 0) then + adverts.Stored = evolve.von.deserialize(file.Read(adFileName,"DATA")) + for k,v in pairs(adverts.Stored) do + timer.Create("Advert_"..k, v.Time, 0, function() + if (#player.GetAll() > 0) then + evolve:Notify(v.Colour, v.Msg, true) + end + end) + if (v.OnState == false) then + timer.Pause("Advert_"..k) + end + end + end + + + ------------------------------------------------------------------------------------ + function adverts.add(info) + info[1] = info[1]:lower() + if #info > 7 then + info[7] = table.concat(info, " ", 7, #info) + elseif #info < 7 then + return "Advert: Incorrect arguements for Add" + end + local ow + if (!tonumber(info[5]) || tonumber(info[5])<60) then + return "Advert: Incorrect Time input, value must be equal or greater than 60!" + end + if (#string.Trim(info[7])==0) then + return "Advert: A message is required!" + end + if adverts.Stored[info[1]] then + ow = "Overwriting advert \""..info[1].."\"." + end + + adverts.Stored[info[1]] = { + ["Colour"] = Color(tonumber(info[2]),tonumber(info[3]),tonumber(info[4])), + ["Time"] = info[5], + ["Msg"] = info[7], + ["OnState"] = tobool(info[6]) + } + timer.Create("Advert_"..info[1], adverts.Stored[info[1]].Time, 0, function() + if (#player.GetAll() > 0) then + evolve:Notify(adverts.Stored[info[1]].Colour, adverts.Stored[info[1]].Msg) + end + end) + writeToFile(adverts.Stored) + return ow or "Advert created." + end + ---------------------------------------------------------------------------------------- + function adverts.remove(info) + if adverts.Stored[info[1]] then + adverts.Stored[info[1]] = nil + timer.Remove("Advert_"..info[1]) + else + return "Advert: ID not found." + end + writeToFile(adverts.Stored) + return "Advert: "..info[1].." has been removed." + end + ------------------------------------------------------------------------------------------- + function adverts.list() + local str = "Registered adverts: " + for k,v in pairs(adverts.Stored) do + str = str..k.." On-"..tostring(v.OnState)..". " + end + return str or "No adverts loaded." + end + -------------------------------------------------------------------------------------------- + function adverts.toggle(args) + if #args > 2 then return "Advert: Incorrect arguements for toggling" end + if adverts.Stored[args[1]:lower()] then + if !args[2] then + adverts.Stored[args[1]].OnState= !adverts.Stored[args[1]].OnState + timer.Toggle("Advert_"..args[1]) + elseif (args[2]=="1") then + adverts.Stored[args[1]].OnState = true + timer.UnPause("Advert_"..args[1]) + else + adverts.Stored[args[1]].OnState = false + timer.Pause("Advert_"..args[1]) + end + writeToFile(adverts.Stored) + return "Advert "..args[1].."'s On-State has been set to "..tostring(adverts.Stored[args[1]].OnState) + else + return "Advert: ID not found." + end + end +end + +--===================================================================================-- +function PLUGIN:Call( ply, args ) + if (SERVER) then + if (ply:EV_HasPrivilege( "Advert 3" )) then + local retStr + if #args == 0 then + evolve:Notify(ply, evolve.colors.red, "Advert Error: No arguements") + return + end + local command = args[1]:lower() + table.remove(args, 1) + if adverts[command] then + retStr = adverts[command](args) + else + retStr = "Advert: Incorrect command specified" + end + + evolve:Notify(ply, evolve.colors.red, "Advert: "..retStr) + else + evolve:Notify(ply, evolve.colors.red, "You don't not have access to this command") + end + end +end +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_aidisable.lua b/lua/ev_plugins/sh_aidisable.lua new file mode 100644 index 0000000..a78f48c --- /dev/null +++ b/lua/ev_plugins/sh_aidisable.lua @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Disable or enable AI with a chat command. +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "AI Disable/Enable" +PLUGIN.Description = "Enable or disable AI." +PLUGIN.Author = "Mattocaster 6" +PLUGIN.ChatCommand = "ai" +PLUGIN.Usage = "<1=enabled 0=disabled>" +PLUGIN.Privileges = { "AI Control" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "AI Control" ) ) then + if ( tonumber(args[1])==1 ) then + RunConsoleCommand( "ai_disable","1" ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has enabled the ai. " ) + else + RunConsoleCommand( "ai_disabled","0") + evolve:Notify( evolve.colors.red, ply:Nick(), evolve.colors.white, " has disabled the ai. " ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_armor.lua b/lua/ev_plugins/sh_armor.lua index 1d03139..ce907d0 100644 --- a/lua/ev_plugins/sh_armor.lua +++ b/lua/ev_plugins/sh_armor.lua @@ -9,11 +9,22 @@ PLUGIN.Author = "Overv" PLUGIN.ChatCommand = "armor" PLUGIN.Usage = "[players] [armor]" PLUGIN.Privileges = { "Armor" } +PLUGIN.Icon = 'shield' +PLUGIN.Settings = { + max_armor = { + label = 'Max Armor', + desc = 'Source Engine overflow Prevention', + stype = 'limit', + min = 100, + max = 255, + default = 100 + }, +} function PLUGIN:Call( ply, args ) if ( ply:EV_HasPrivilege( "Armor" ) ) then local players = evolve:FindPlayer( args, ply, true ) - local armor = tonumber( args[ #args ] ) or 100 + local armor = tonumber( args[ #args ] ) or evolve:GetSetting('max_armor', 100) for _, pl in ipairs( players ) do pl:SetArmor( armor ) diff --git a/lua/ev_plugins/sh_atmos.lua b/lua/ev_plugins/sh_atmos.lua new file mode 100644 index 0000000..87adcf6 --- /dev/null +++ b/lua/ev_plugins/sh_atmos.lua @@ -0,0 +1,122 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Atmos settings. +-------------------------------------------------------------------------------------------------------------------------*/ +if !ConVarExists("atmos_enabled") then return true end --Don't provide for what doesn't exist. +local PLUGIN = {} +PLUGIN.Title = "Atmos" +PLUGIN.Description = "Easy frontend for atmos ConVars." +PLUGIN.Author = "EntranceJew" +PLUGIN.ChatCommand = nil +PLUGIN.Usage = nil +PLUGIN.Privileges = { "Atmos Settings" } +PLUGIN.Icon = "weather_cloudy" +PLUGIN.Dependencies = { "Cconvar" } +PLUGIN.Settings = { + atmos_enabled = { + label = "Enable", + desc = "Toggle whether there's weather.", + stype = "bool", + value = 1, + default = 1, + isconvar = true, + }, + atmos_log = { + label = "Logging", + desc = "Toggle console logging of atmos events.", + stype = "bool", + value = 0, + default = 0, + isconvar = true, + }, + atmos_dnc_length = { + label = "Day/Night Length", + desc = "Change the length of the day/night cycle, in seconds.", + stype = "limit", + value = 3600, + min = 1, + max = 3600, + default = 3600, + isconvar = true, + }, + atmos_weather_length = { + label = "Weather Length", + desc = "Change the duration of a storm, in seconds.", + stype = "limit", + value = 480, + min = 1, + max = 3600, + default = 480, + isconvar = true, + }, + atmos_weather_chance = { + label = "Weather Chance", + desc = "Change the liklihood of weather.", + stype = "limit", + value = 30, + min = 1, + max = 100, + default = 30, + isconvar = true, + }, + atmos_weather_lighting = { + label = "Impact Lighting", + desc = "Toggles the ability for to weather affect lighting.", + stype = "bool", + value = 0, + default = 0, + isconvar = true, + }, + -- atmos_dnc_gettime + -- atmos_dnc_settime + -- atmos_dnc_pause (toggles time) + -- atmos_startstorm (begins a storm) + -- atmos_stopstorm + atmos_cl_hudeffects = { + label = "CL: Hud Effects", + desc = "Toggles rain droplets and the like on your HUD.", + stype = "bool", + value = 1, + default = 1, + isconvar = true, + }, + atmos_cl_weather = { + label = "CL: Weather", + desc = "Toggles whether you perceive weather.", + stype = "bool", + value = 1, + default = 1, + isconvar = true, + }, + atmos_cl_rainsplash = { + label = "CL: Rain Splash", + desc = "Toggles rain slash effects.", + stype = "bool", + value = 1, + default = 1, + isconvar = true, + }, + atmos_cl_rainperparticle = { + label = "CL: Rain per Particle", + desc = "The amount of rain per particle.", + stype = "limit", + value = 16, + min = 16, + max = 64, + default = 16, + isconvar = true, + }, + atmos_cl_rainradius = { + label = "CL: Rain Radius", + desc = "Tautological", + stype = "limit", + value = 16, + min = 16, + max = 32, + default = 16, + isconvar = true, + }, +} + +--table.insert(evolve:FindPlugin("Cconvar").AllowedCommands, "atmos_") + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_commands.lua b/lua/ev_plugins/sh_commands.lua index b04901c..8cc65c7 100644 --- a/lua/ev_plugins/sh_commands.lua +++ b/lua/ev_plugins/sh_commands.lua @@ -14,35 +14,35 @@ end function PLUGIN:Call( ply, args ) local commands = {} - if ( ply:IsValid() ) then - for _, plug in ipairs( evolve.plugins ) do - if ( plug.ChatCommand ) then - if type(plug.ChatCommand) == "string" then - table.insert(commands, {plug.ChatCommand, plug.Usage, plug.Description}) - else - for k, ChatCommand in ipairs( plug.ChatCommand ) do - local usage, description - - if (type(plug.Usage) == "table") then - usage = plug.Usage[k] - else - usage = plug.Usage - end - - if (type(plug.Description) == "table") then - description = plug.Description[k] - else - description = plug.Description - end - - table.insert(commands, {ChatCommand, tostring(usage), description}) + for _, plug in ipairs( evolve.plugins ) do + if ( plug.ChatCommand ) then + if type(plug.ChatCommand) == "string" then + table.insert(commands, { ["ChatCommand"] = plug.ChatCommand, ["Description"] = plug.Description, ["Usage"] = plug.Usage }) + else + for k, ChatCommand in ipairs( plug.ChatCommand ) do + local usage, description + + if (type(plug.Usage) == "table") then + usage = plug.Usage[k] + else + usage = plug.Usage + end + + if (type(plug.Description) == "table") then + description = plug.Description[k] + else + description = plug.Description end + + table.insert(commands, { ["ChatCommand"] = ChatCommand, ["Description"] = description, ["Usage"] = usage }) end end end - - table.SortByMember(commands, 1, function(a,b) return a > b end) - + end + + table.SortByMember( commands, "ChatCommand", function( a, b ) return a > b end ) + + if ( ply:IsValid() ) then net.Start( "EV_Command" ) net.WriteBit( false ) net.WriteString( "\n============ Available chat commands for Evolve ============\n" ) @@ -51,9 +51,9 @@ function PLUGIN:Call( ply, args ) for k,cmd in pairs(commands) do net.Start( "EV_Command" ) net.WriteBit( true ) - net.WriteString( cmd[1] or "" ) - net.WriteString( cmd[2] or "" ) - net.WriteString( cmd[3] or "" ) + net.WriteString( cmd.ChatCommand or "" ) + net.WriteString( cmd.Description or "" ) + net.WriteString( cmd.Usage or "" ) net.Send( ply ) end @@ -65,12 +65,10 @@ function PLUGIN:Call( ply, args ) evolve:Notify( ply, evolve.colors.white, "All chat commands have been printed to your console." ) else for _, plugin in ipairs( commands ) do - if ( plugin.ChatCommand ) then - if ( plugin.Usage ) then - print( "!" .. plugin.ChatCommand .. " " .. plugin.Usage .. " - " .. plugin.Description ) - else - print( "!" .. plugin.ChatCommand .. " - " .. plugin.Description ) - end + if ( plugin.Usage ) then + print( "!" .. plugin.ChatCommand .. " " .. plugin.Usage .. " - " .. plugin.Description ) + else + print( "!" .. plugin.ChatCommand .. " - " .. plugin.Description ) end end end diff --git a/lua/ev_plugins/sh_convar.lua b/lua/ev_plugins/sh_convar.lua index e297f64..7e530a2 100644 --- a/lua/ev_plugins/sh_convar.lua +++ b/lua/ev_plugins/sh_convar.lua @@ -11,7 +11,8 @@ PLUGIN.Usage = " " PLUGIN.AllowedCommands = { "sbox_", "g_", - "mp_" + "mp_", + "atmos_" -- temporary fix until I can inject from sh_atmos.lua } PLUGIN.Privileges = { "Convar changing" } diff --git a/lua/ev_plugins/sh_detective.lua b/lua/ev_plugins/sh_detective.lua new file mode 100644 index 0000000..ba478ee --- /dev/null +++ b/lua/ev_plugins/sh_detective.lua @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------------------------------------------------------- + detective +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "detective" +PLUGIN.Description = "Makes a player detective" +PLUGIN.Author = "-[LCG]- Marvincmarvin | mostly Overv" +PLUGIN.ChatCommand = "detective" +PLUGIN.Usage = "[players]" +PLUGIN.Privileges = { "TTT Detective" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "TTT Detective" ) ) then + local players = evolve:FindPlayer( args, ply ) + + for _, pl in ipairs( players ) do + pl:SetRole(ROLE_DETECTIVE) + SendFullStateUpdate() + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " a detective." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_drug.lua b/lua/ev_plugins/sh_drug.lua new file mode 100644 index 0000000..00b193d --- /dev/null +++ b/lua/ev_plugins/sh_drug.lua @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Drug a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Drug" +PLUGIN.Description = "Drug a player." +PLUGIN.Author = "Overv" +PLUGIN.ChatCommand = "drug" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "Drug" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Drug" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + pl:SetNWBool( "EV_Druged", enabled ) + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has druged ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has undruged ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:HUDPaint() + if ( LocalPlayer():GetNWBool( "EV_Druged", false ) ) then + local tmpcolor = HSVToColor(math.random(0,255), 1, 1) + surface.SetDrawColor( tmpcolor.r, tmpcolor.g, tmpcolor.b, 200 ) + surface.DrawRect( 0, 0, ScrW(), ScrH() ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "drug", unpack( players ) ) + else + return "Drug", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_earbleed.lua b/lua/ev_plugins/sh_earbleed.lua new file mode 100644 index 0000000..24b01b5 --- /dev/null +++ b/lua/ev_plugins/sh_earbleed.lua @@ -0,0 +1,49 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Bleed a Players Ear +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "EarBleed" +PLUGIN.Description = "Bleed People's Ears" +PLUGIN.Author = "Vendetta" +PLUGIN.ChatCommand = "earbleed" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "EarBleed" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "EarBleed" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + if ( enabled ) then + pl:ConCommand( "play synth/square_880.wav" ) + else + pl:ConCommand( "play nothing.wav" ) + end + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " is making ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " ears bleed!" ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " stopped ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " ears from bleeding!" ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "earbleed", unpack( players ) ) + else + return "EarBleed", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_esp.lua b/lua/ev_plugins/sh_esp.lua new file mode 100644 index 0000000..075605b --- /dev/null +++ b/lua/ev_plugins/sh_esp.lua @@ -0,0 +1,140 @@ +/*------------------------------------------------------------------------------------------------------------------------- + ESP a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "ESP" +PLUGIN.Description = "Give a player ESP." +PLUGIN.Author = "Grey" +PLUGIN.ChatCommand = "esp" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "ESP" } +function PLUGIN:ESP_RandomString( len, numbers, special ) + local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"..(numbers == true && "1234567890" or "")..(special == true && "!?@#$%^&*[](),.-+={}:;'\"<>|\\" or ""); --You can change the list if you like + local result = ""; + + if (len < 1) then + len = math.random( 10, 20 ); + end + + for i = 1, len do + result = result..string.char( string.byte( chars, math.random( 1, string.len( chars ) ) ) ); + end + + return tostring( result ); +end +function Func_ESP_RandomString( len, numbers, special ) + local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"..(numbers == true && "1234567890" or "")..(special == true && "!?@#$%^&*[](),.-+={}:;'\"<>|\\" or ""); --You can change the list if you like + local result = ""; + + if (len < 1) then + len = math.random( 10, 20 ); + end + + for i = 1, len do + result = result..string.char( string.byte( chars, math.random( 1, string.len( chars ) ) ) ); + end + + return tostring( result ); +end +if !ESP_Mat then + if !SERVER then + ESP_Mat = CreateMaterial( string.lower( Func_ESP_RandomString( math.random( 5, 8 ), false, false ) ), "VertexLitGeneric", { ["$basetexture"] = "models/debug/debugwhite", ["$model"] = 1, ["$ignorez"] = 1 } ); --Last minute change + end +end +if !ESP_Font then + if !SERVER then + ESP_Font = "MyEspFont" + surface.CreateFont( ESP_Font, { font = "Arial", size = 18, weight = 750, antialias = false, outline = true } ); + end +end +function PLUGIN:AddToColor( color, add ) + return color + add <= 255 and color + add or color + add - 255 +end +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "ESP" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + pl:SetNWBool( "EV_ESPed", enabled ) + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has given ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " ESP." ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has taken ESP from ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end +function PLUGIN:HUDPaint() + if ( LocalPlayer():GetNWBool( "EV_ESPed", false ) ) then + for _, ply in pairs( player.GetAll() ) do + if (ply != LocalPlayer() && IsValid( ply ) && ply:Alive() && ply:Health() > 0 && ply:Team() != TEAM_SPECTATOR) then + local min2, max2 = ply:GetRenderBounds(); + local pos = ply:GetPos() + Vector( 0, 0, ( min2.z + max2.z ) ); + local color = Color( 50, 255, 50, 255 ); + + if ( ply:Health() <= 10 ) then color = Color( 255, 0, 0, 255 ); + elseif ( ply:Health() <= 20 ) then color = Color( 255, 50, 50, 255 ); + elseif ( ply:Health() <= 40 ) then color = Color( 250, 250, 50, 255 ); + elseif ( ply:Health() <= 60 ) then color = Color( 150, 250, 50, 255 ); + elseif ( ply:Health() <= 80 ) then color = Color( 100, 255, 50, 255 ); end + + pos = ( pos + Vector( 0, 0, 10 ) ):ToScreen(); + cam.Start3D( LocalPlayer():EyePos(), LocalPlayer():EyeAngles() ); + render.SuppressEngineLighting( true ); + render.SetColorModulation( color.r/255, color.g/255, color.b/255, 1 ); + if ESP_Mat then + render.MaterialOverride( ESP_Mat ); + else + ESP_Mat = CreateMaterial( string.lower( "ASDFWTFBBQ" ), "VertexLitGeneric", { ["$basetexture"] = "models/debug/debugwhite", ["$model"] = 1, ["$ignorez"] = 1 } ); --Last minute change + render.MaterialOverride( ESP_Mat ); + end + ply:DrawModel(); + render.SetColorModulation( self:AddToColor( color.r, 150 )/255, self:AddToColor( color.g, 150 )/255, self:AddToColor( color.b, 150 )/255, 1 ); + + if (IsValid( ply:GetActiveWeapon() )) then + ply:GetActiveWeapon():DrawModel() + end + + render.SetColorModulation( 1, 1, 1, 1 ); + + --render.MaterialOverride(); + render.SetModelLighting( 4, color.r/255, color.g/255, color.b/255 ); + ply:DrawModel(); + render.MaterialOverride(); + render.SuppressEngineLighting( false ); + cam.End3D(); + local color = team.GetColor( ply:Team( ) ); + local width, height = surface.GetTextSize( tostring( ply:Nick() ) ); -- I have to do tostring because sometimes errors would occur + draw.DrawText( ply:Nick(), ESP_Font, pos.x, pos.y-height/2, color, 1 ); + if ( ply:GetNetworkedString( "UserGroup" ) != "user" ) then + local width, height = surface.GetTextSize( ply:GetNetworkedString( "UserGroup" ) ); + draw.DrawText( ply:GetNetworkedString( "UserGroup" ), ESP_Font, pos.x, pos.y-height-14, Color( 255, 200, 50, 255 ), 1 ); + end + if (IsValid( ply:GetActiveWeapon() )) then + local width, height = surface.GetTextSize( ply:GetActiveWeapon():GetPrintName() or ply:GetActiveWeapon():GetClass() ); + draw.DrawText( ply:GetActiveWeapon():GetPrintName() or ply:GetActiveWeapon():GetClass(), ESP_Font, pos.x, pos.y+14, Color( 255, 200, 50 ), 1 ); + end + end + end + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "esp", unpack( players ) ) + else + return "esp", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_god_limited.lua b/lua/ev_plugins/sh_god_limited.lua new file mode 100644 index 0000000..583f026 --- /dev/null +++ b/lua/ev_plugins/sh_god_limited.lua @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Enable godmode for a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Godmode" +PLUGIN.Description = "Enable godmode for one's self." +PLUGIN.Author = "Overv" +PLUGIN.ChatCommand = "sgod" +PLUGIN.Usage = "[enabled]" +PLUGIN.Privileges = { "Self God" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Self God" ) ) then + local players = {} + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( evolve:FindPlayer( ply:Nick(), ply, true ) ) do + if ply:EV_IsAdmin() or ply:EV_GetRank() ~= pl:EV_GetRank() or ply == pl then + players[#players+1] = pl + + if ( enabled ) then pl:GodEnable() else pl:GodDisable() end + pl.EV_GodMode = enabled + end + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has enabled godmode for ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has disabled godmode for ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:PlayerSpawn( ply ) + if ( ply.EV_GodMode ) then ply:GodEnable() end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "sgod", unpack( players ) ) + else + return "Godmode", evolve.category.actions, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_godmode.lua b/lua/ev_plugins/sh_godmode.lua index 51df51f..7e30f47 100644 --- a/lua/ev_plugins/sh_godmode.lua +++ b/lua/ev_plugins/sh_godmode.lua @@ -16,12 +16,10 @@ function PLUGIN:Call( ply, args ) local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 for _, pl in ipairs( evolve:FindPlayer( args, ply, true ) ) do - if ply:EV_IsAdmin() or ply:EV_GetRank() ~= pl:EV_GetRank() or ply == pl then - players[#players+1] = pl - - if ( enabled ) then pl:GodEnable() else pl:GodDisable() end - pl.EV_GodMode = enabled - end + players[#players+1] = pl + + if ( enabled ) then pl:GodEnable() else pl:GodDisable() end + pl.EV_GodMode = enabled end if ( #players > 0 ) then diff --git a/lua/ev_plugins/sh_grav.lua b/lua/ev_plugins/sh_grav.lua new file mode 100644 index 0000000..04aa0e6 --- /dev/null +++ b/lua/ev_plugins/sh_grav.lua @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Set the gravity of the server. +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Gravity" +PLUGIN.Description = "Set the server gravity." +PLUGIN.Author = "Mattocaster 6 & Matt J" +PLUGIN.ChatCommand = "gravity" +PLUGIN.Usage = "" +PLUGIN.Privileges = { "Gravity" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Gravity" ) ) then + if ( #args > 0 ) then + RunConsoleCommand( "sv_gravity",args[1] ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has set the server gravity to ",evolve.colors.red, args[1], evolve.colors.white, "." ) + else + RunConsoleCommand( "sv_gravity","600") + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has reset the server gravity." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_hax.lua b/lua/ev_plugins/sh_hax.lua new file mode 100644 index 0000000..25452e6 --- /dev/null +++ b/lua/ev_plugins/sh_hax.lua @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------------------------------------------------- + THE HAAAAAAAAAAAAAAAAAAAX! +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Hax" +PLUGIN.Description = "The HAAAAAAAAAAAX!" +PLUGIN.Author = "Divran" +PLUGIN.ChatCommand = "hax" +PLUGIN.Usage = "[players]" +PLUGIN.Privileges = { "throw monitor hax" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "throw monitor hax" ) ) then + local players = evolve:FindPlayer( args, ply ) + + for _, pl in ipairs( players ) do + pl:SetMoveType( MOVETYPE_WALK ) + self:SpawnTrain( pl:GetPos() + pl:GetForward() * 1000 + Vector(0,0,50), pl:GetForward() * -1 ) + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.white, "HERE COME THE HAX, ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + else + evolve:Notify( ply, evolve.colors.red, "No matching players found." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:SpawnTrain( Pos, Direction ) + local train = ents.Create( "prop_physics" ) + train:SetModel("models/props_lab/monitor02.mdl") + train:SetAngles( Direction:Angle() ) + train:SetPos( Pos ) + train:Spawn() + train:Activate() + train:EmitSound( "vo/npc/male01/hacks01.wav", 100, 100 ) + train:GetPhysicsObject():SetVelocity( Direction * 50000 ) + + --timer.Create( "TrainRemove_"..CurTime(), 5, 1, function( train ) train:Remove() end, train ) + timer.Simple( 5, function() train:Remove() end ) +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + RunConsoleCommand( "ev", "hax", unpack( players ) ) + else + return "Hax", evolve.category.punishment + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_hunger.lua b/lua/ev_plugins/sh_hunger.lua new file mode 100644 index 0000000..f62a2da --- /dev/null +++ b/lua/ev_plugins/sh_hunger.lua @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Set the health of a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Hunger" +PLUGIN.Description = "Set the hunger of a player." +PLUGIN.Author = "EntranceJew" +PLUGIN.ChatCommand = "hunger" +PLUGIN.Usage = " [hunger]" +PLUGIN.Privileges = { "Hunger" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Hunger" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local hunger = math.Clamp( tonumber( args[ #args ] ) or 100, 0, 2147483647 ) + + for _, pl in ipairs( players ) do + pl:setDarkRPVar("Energy", hunger ) + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has set the hunger of ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " to " .. hunger .. "." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "hunger", unpack( players ) ) + else + args = {} + for i = 1, 10 do + args[i] = { i * 10 } + end + return "Hunger", evolve.category.actions, args + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_innocent.lua b/lua/ev_plugins/sh_innocent.lua new file mode 100644 index 0000000..c7cd70a --- /dev/null +++ b/lua/ev_plugins/sh_innocent.lua @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Innocent +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "innocent" +PLUGIN.Description = "Makes a player innocent" +PLUGIN.Author = "-[LCG]- Marvincmarvin | mostly Overv" +PLUGIN.ChatCommand = "innocent" +PLUGIN.Usage = "[players]" +PLUGIN.Privileges = { "TTT Innocent" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "TTT Innocent" ) ) then + local players = evolve:FindPlayer( args, ply ) + + for _, pl in ipairs( players ) do + pl:SetRole(ROLE_INNOCENT) + SendFullStateUpdate() + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "an innocent." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_mapcycle.lua b/lua/ev_plugins/sh_mapcycle.lua new file mode 100644 index 0000000..94cecc6 --- /dev/null +++ b/lua/ev_plugins/sh_mapcycle.lua @@ -0,0 +1,477 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Automatic map cycle +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Map Cycle" +PLUGIN.Description = "Automatically cycle maps." +PLUGIN.Author = "Divran" +PLUGIN.ChatCommand = "mapcycle" +PLUGIN.Usage = "[add/remove/toggle/moveup/movedown/interval] [mapname/interval]" +PLUGIN.Privileges = { "Map Cycle" } + +PLUGIN.Enabled = false +PLUGIN.Maps = {} +PLUGIN.Interval = -1 +PLUGIN.ChangeAt = -1 + +if (SERVER) then + + ---------------------------- + -- Call + ---------------------------- + + local funcs = { ["add"] = true, ["remove"] = true, ["toggle"] = true, ["moveup"] = true, ["movedown"] = true, ["interval"] = true } + function PLUGIN:Call( ply, args ) + + -- Error checking + if (!ply:EV_HasPrivilege( "Map Cycle" )) then + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + return + end + if (!args[1] or args[1] == "") then + evolve:Notify( ply, evolve.colors.red, "You must specify an action (add/remove/toggle/moveup/movedown/interval)" ) + return + end + if (!funcs[args[1]]) then + evolve:Notify( ply, evolve.colors.red, "Invalid action ('"..args[1].."')." ) + return + end + + if (!self[args[1]]( self, ply, args )) then return end -- If the function ran alright, call it client side... + + umsg.Start( "ev_mapcycle_clientside_cmd" ) + umsg.Char( #args ) + for i=1,#args do + umsg.String( args[i] ) + end + umsg.End() + end + + util.AddNetworkString("ev_mapcycle_datastream") +end + +function PLUGIN:Notify( ... ) -- Helper function to block messages running on the client (potentially making it print twice) + if (CLIENT) then return end + evolve:Notify( ... ) +end + +if (CLIENT) then + usermessage.Hook( "ev_mapcycle_clientside_cmd", function( um ) + local n = um:ReadChar() + local args = {} + for i=1,n do + args[i] = um:ReadString() + end + + PLUGIN[args[1]]( PLUGIN, { Nick = function() end }, args ) + end) +end + +---------------------------- +-- Add +---------------------------- + +function PLUGIN:add( ply, args ) + if (!args[2] or args[2] == "") then + self:Notify( ply, evolve.colors.red, "You must specify a map to add." ) + return + end + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " added the map ", evolve.colors.red, args[2], evolve.colors.white, " to the map cycle list." ) + self.Maps[#self.Maps+1] = args[2] + self:Save() + if (CLIENT) then evolve:MapCyclePlugin_UpdateTab() end + + return true +end + +---------------------------- +-- remove +---------------------------- + +function PLUGIN:remove( ply, args ) + if (!args[2] or args[2] == "") then + self:Notify( ply, evolve.colors.red, "You must specify a map." ) + return + end + + local nr = tonumber(args[2]) + if (!nr or nr == 0) then + self:Notify( ply, evolve.colors.red, "The specified map must be the number index of the map." ) + return + end + + if (!self.Maps[nr]) then + self:Notify( ply, evolve.colors.red, "That map is not on the cycle list." ) + return + end + + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " removed the map ", evolve.colors.red, self.Maps[nr], evolve.colors.white, " from the map cycle list." ) + table.remove( self.Maps, nr ) + self:Save() + if (CLIENT) then evolve:MapCyclePlugin_UpdateTab() end + + return true +end + +---------------------------- +-- Toggle +---------------------------- + +function PLUGIN:toggle( ply, args ) + if (CLIENT) then return end + + self.Enabled = !self.Enabled + + self.ChangeAt = RealTime() + self.Interval * 60 + self:Update() + + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " toggled the map cycle. It is now ", evolve.colors.red, self.Enabled and "enabled" or "disabled", evolve.colors.white, "." ) + self:Save() +end + +---------------------------- +-- Move Up +---------------------------- + +function PLUGIN:moveup( ply, args ) + if (!args[2] or args[2] == "") then + self:Notify( ply, evolve.colors.red, "You must specify a map." ) + return + end + + local nr = tonumber(args[2]) + if (!nr or nr == 0) then + self:Notify( ply, evolve.colors.red, "The specified map must be the number index of the map." ) + return + end + + if (nr == 1) then + self:Notify( ply, evolve.colors.red, "The specified map is already at the top of the list." ) + return + end + + if (!self.Maps[nr]) then + self:Notify( ply, evolve.colors.red, "That map is not on the cycle list." ) + return + end + + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " moved the map ", evolve.colors.red, self.Maps[nr], evolve.colors.white, " one step up in the map cycle list." ) + + local temp = self.Maps[nr-1] + self.Maps[nr-1] = self.Maps[nr] + self.Maps[nr] = temp + + self:Save() + if (CLIENT) then evolve:MapCyclePlugin_UpdateTab() end + + return true +end + +---------------------------- +-- Move Down +---------------------------- + +function PLUGIN:movedown( ply, args ) + if (!args[2] or args[2] == "") then + self:Notify( ply, evolve.colors.red, "You must specify a map." ) + return + end + + local nr = tonumber(args[2]) + if (!nr or nr == 0) then + self:Notify( ply, evolve.colors.red, "The specified map must be the number index of the map." ) + return + end + + if (nr == #self.Maps) then + self:Notify( ply, evolve.colors.red, "The specified map is already at the bottom of the list." ) + return + end + + if (!self.Maps[nr]) then + self:Notify( ply, evolve.colors.red, "That map is not on the cycle list." ) + return + end + + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " moved the map ", evolve.colors.red, self.Maps[nr], evolve.colors.white, " one step down in the map cycle list." ) + + local temp = self.Maps[nr+1] + self.Maps[nr+1] = self.Maps[nr] + self.Maps[nr] = temp + + self:Save() + if (CLIENT) then evolve:MapCyclePlugin_UpdateTab() end + + return true +end + +---------------------------- +-- Interval +---------------------------- + +function PLUGIN:interval( ply, args ) + if (CLIENT) then return end + + if (!args[2] or args[2] == "") then + self:Notify( ply, evolve.colors.red, "You must specify an interval." ) + return + end + + local nr = tonumber( args[2] ) + if (!nr or nr == 0) then + self:Notify( ply, evolve.colors.red, "Invalid interval specified." ) + return + end + + self.Interval = nr + self.ChangeAt = RealTime() + self.Interval * 60 + + self:Update() + self:Save() + + if (args[3]) then + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " changed the map cycle interval to ", evolve.colors.red, tostring(self.Interval), evolve.colors.white, " minutes.", evolve.colors.red, " (" .. args[3] .. ")" ) + else + self:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " changed the map cycle interval to ", evolve.colors.red, tostring(self.Interval), evolve.colors.white, " minutes." ) + end + + return true +end + +---------------------------- +-- Interval +-- Update all changes on all clients +---------------------------- +if (CLIENT) then + net.Receive( "ev_mapcycle_datastream", function( len, ply ) + local decoded = net.ReadTable() + for k,v in pairs( decoded ) do + if (PLUGIN[k] != nil) then + PLUGIN[k] = v + end + end + + if (decoded.TimeDifference) then + PLUGIN.ChangeAt = RealTime() + decoded.TimeDifference + end + + if evolve.MapCyclePlugin_UpdateTab then + evolve:MapCyclePlugin_UpdateTab() + end + end) +end + +local old_changeat = 0 +function PLUGIN:Update( ply, Send_Maps ) + if (CLIENT) then return end + + local recipients = ply + local data = {} + + if (Send_Maps) then + data.Maps = self.Maps + end + + data.Interval = self.Interval + data.Enabled = self.Enabled + data.TimeDifference = self.ChangeAt - RealTime() + + timer.Adjust( "Evolve_UpdateMapCycle", math.max( self.Interval/100, 300 ), 0, function() self:Update() end, self ) + + net.Start( "ev_mapcycle_datastream" ) + net.WriteTable( data ) + + if recipients then + net.Send( recipients ) + else + net.Broadcast() + end +end + +---------------------------- +-- Save +-- Save the map cycle and other data to a file +---------------------------- + +function PLUGIN:Save() + if (CLIENT) then return end + file.Write( "evolve/mapcycle.txt", evolve.von.serialize( { self.Enabled, self.Interval, self.Maps } ) ) +end + +---------------------------- +-- Load +-- Load the map cycle and other data from the file +---------------------------- + +function PLUGIN:Load() + if (CLIENT) then return end + if (file.Exists( "evolve/mapcycle.txt", "DATA")) then + local data = file.Read( "evolve/mapcycle.txt", "DATA" ) + if (data and data != "") then + data = evolve.von.deserialize( data ) + if (next(data)) then + self.Enabled = data[1] + self.Interval = data[2] + self.Maps = data[3] + self.ChangeAt = RealTime() + self.Interval * 60 + self:Update( nil, true ) + else + evolve:Notify( evolve.colors.red, "Error loading map cycle file: Data table is empty" ) + end + else + evolve:Notify( evolve.colors.red, "Error loading map cycle file: File is empty" ) + end + else + self.Enabled = false + self.Interval = 0 + self.Maps = {} + end +end + +---------------------------- +-- Think +-- Change map at the right time +---------------------------- +PLUGIN.NextUpdate = RealTime() + 60 +function PLUGIN:Think() + -- Check if enabled + if (!self.Enabled) then return end + + -- Don't run on client + if (CLIENT) then return end + + -- Check if the next map is valid + local NextMap = self.Maps[1] + if (!NextMap or NextMap == "") then return end + + -- Check if we want to send an update to the client + if self.NextUpdate < RealTime() then + self.NextUpdate = RealTime() + 60 + self:Update() + end + + -- Check if the timer has run out + if (RealTime() > self.ChangeAt and self.ChangeAt != -1) then + local _, maps_inverted = evolve:MapPlugin_GetMaps() + if (!maps_inverted[NextMap]) then + evolve:Notify( evolve.colors.red, "MAP CYCLE ERROR: Next map is not a valid map! Map cycle disabled." ) + self.Enabled = false + self:Update() + return + end + + table.remove( self.Maps, 1 ) + self.Maps[#self.Maps+1] = NextMap + self:Update() + self:Save() + + evolve:Notify( evolve.colors.red, "Map changing!" ) + self.ChangeAt = -1 + timer.Simple( 0.5, function() RunConsoleCommand( "changelevel", NextMap ) end ) + end +end + +-- Send the info when the player spawns +function PLUGIN:PlayerInitialSpawn( ply ) + timer.Simple( 3, function() + if IsValid(ply) then + self:Update( ply, true ) + end + end) +end + +-- Initialization +timer.Simple( 1, function() + if (!evolve.MapPlugin_GetMaps) then + evolve:Notify( evolve.colors.red, "YOU MUST HAVE THE MAP LIST PLUGIN ('sh_mapslist.lua') TO USE THIS PLUGIN!" ) + return + end + PLUGIN:Load() +end) + +-- Update the time for all players every 10 minutes +timer.Create( "Evolve_UpdateMapCycle", 600, 0, function() PLUGIN:Update() end ) + +if (CLIENT) then + surface.CreateFont( "Trebuchet36", { + font = "Trebuchet18", + size = 36, + weight = 500, + blursize = 0, + scanlines = 0, + antialias = true, + underline = false, + italic = false, + strikeout = false, + symbol = false, + rotary = false, + shadow = false, + additive = false, + outline = false + } ) + + function PLUGIN:HUDPaint() + if (self.Enabled) then + local nextmap = self.Maps[1] + if (nextmap and nextmap != "" and self.ChangeAt and self.ChangeAt != -1) then + + + local t = math.max(self.ChangeAt-RealTime(),0) + local hour = math.floor(t/3600) + local minute = math.floor(t/60)-(60*hour) + local second = math.floor(t - hour * 3600 - minute*60) + + local r = 0 + + + if (t < 300) then + r = 127.5 + math.cos(RealTime() * 3) * 127.5 + + if t < 60 then + surface.SetDrawColor( Color(255, 0, 0, 150 + math.sin( RealTime() * 4 ) * 80) ) + surface.DrawRect( 0, 0, ScrW(), ScrH() ) + surface.SetFont( "Trebuchet36" ) + surface.SetTextColor( Color(0,0,0,255) ) + local str = string.format( "MAP WILL CHANGE IN %02d! SAVE YOUR STUFF", second ) + local w,h = surface.GetTextSize( str ) + surface.SetTextPos( ScrW()/2 - w/2, ScrH()/2 - h/2 - 40 ) + surface.DrawText( str ) + if not self.Warned then + surface.PlaySound( "ambient/alarms/alarm_citizen_loop1.wav" ) + self.Warned = true + end + elseif self.Warned then + self.Warned = nil + end + end + + surface.SetFont( "ScoreboardText" ) + + local str1 = "Next map: " .. nextmap + local str2 = string.format( "Time left: %02d:%02d:%02d",hour,minute,second) + + local w1, h1 = surface.GetTextSize( str1 ) + local w2, h2 = surface.GetTextSize( str2 ) + + local w, h = math.max( w1, w2 ) + 24, h1+h2+6 + local x, y = ScrW() / 2 - w / 2, 44 - h / 2 + + draw.RoundedBox( 6, x, y, w, h, Color(r, 0, 0, 200) ) + + surface.SetTextColor( Color(255,255,255,255) ) + surface.SetTextPos( x + w/2 - w1/2, y + 2 ) + surface.DrawText( str1 ) + surface.SetTextPos( x + w/2 - w2/2, y + 4 + h1 ) + surface.DrawText( str2 ) + end + end + end +end + +function evolve:MapCyclePlugin_GetMaps() + return PLUGIN.Maps +end + +evolve:RegisterPlugin( PLUGIN ) + diff --git a/lua/ev_plugins/sh_mapslist.lua b/lua/ev_plugins/sh_mapslist.lua new file mode 100644 index 0000000..5b9fccd --- /dev/null +++ b/lua/ev_plugins/sh_mapslist.lua @@ -0,0 +1,76 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Get maps and gamemodes for use in the maps tab +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Get Maps" +PLUGIN.Description = "Gets all maps on the server and sends them to the client for use in other plugins." +PLUGIN.Author = "Divran" +PLUGIN.ChatCommand = nil +PLUGIN.Usage = nil +PLUGIN.Maps = {} +PLUGIN.Maps_Inverted = {} +PLUGIN.Gamemodes = {} +PLUGIN.Gamemodes_Inverted = {} + +if (SERVER) then + function PLUGIN:GetMaps() + self.Maps = {} + self.Gamemodes = {} + + local files, _ = file.Find( "maps/*.bsp", "GAME" ) + for k, filename in pairs( files ) do + self.Maps[k] = filename:gsub( "%.bsp$", "" ) + self.Maps_Inverted[self.Maps[k]] = k + end + + local _, folders = file.Find( "gamemodes/*", "GAME" ) + for k, foldername in pairs( folders ) do + self.Gamemodes[k] = foldername + self.Gamemodes_Inverted[foldername] = k + end + end + PLUGIN:GetMaps() + + util.AddNetworkString("ev_sendmaps") + + function PLUGIN:PlayerInitialSpawn( ply ) + timer.Simple( 2, function() + if IsValid(ply) then + net.Start( "ev_sendmaps" ) + net.WriteTable( self.Maps ) + net.WriteTable( self.Gamemodes ) + net.Send( ply ) + end + end) + end + concommand.Add( "ev_changemapandgamemode", function( ply, command, args ) + if ( ply:EV_HasPrivilege("Map changing") ) then + local mapc = args[1] + local gamemodec = args[2] + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has changed the map to ", evolve.colors.red, mapc, evolve.colors.white, " and gamemode to ", evolve.colors.red, gamemodec, evolve.colors.white, "." ) + timer.Simple( 0.5, function() RunConsoleCommand("gamemode", gamemodec) end) + timer.Simple( 0.55, function() RunConsoleCommand("changelevel", mapc) end) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end + end) +else + function PLUGIN.RecieveMaps( len ) + PLUGIN.Maps = net.ReadTable() + PLUGIN.Gamemodes = net.ReadTable() + end + net.Receive("ev_sendmaps", PLUGIN.RecieveMaps) +end + +function evolve:MapPlugin_GetMaps() + return PLUGIN.Maps, PLUGIN.Maps_Inverted +end + +function evolve:MapPlugin_GetGamemodes() + return PLUGIN.Gamemodes, PLUGIN.Gamemodes_Inverted +end + + +evolve:RegisterPlugin( PLUGIN ) + diff --git a/lua/ev_plugins/sh_money.lua b/lua/ev_plugins/sh_money.lua new file mode 100644 index 0000000..3cd69d4 --- /dev/null +++ b/lua/ev_plugins/sh_money.lua @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Set the money of a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Money(DarkRP)" +PLUGIN.Description = "Set the money of a player." +PLUGIN.Author = "Grey" +PLUGIN.ChatCommand = "money" +PLUGIN.Usage = "[players] [money]" +PLUGIN.Privileges = { "Money" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Money" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local money = tonumber( args[ #args ] ) or 100 + + for _, pl in ipairs( players ) do + RunConsoleCommand("rp_setmoney", pl:Name(), money) + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has set the money of ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " to " .. money .. "." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "money", unpack( players ) ) + else + args = {} + for i = 1, 10 do + args[i] = { 10 * 10^(i-1) } + end + return "Money(DarkRP)", evolve.category.actions, args + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_motd.lua b/lua/ev_plugins/sh_motd.lua index fefb847..582dd57 100644 --- a/lua/ev_plugins/sh_motd.lua +++ b/lua/ev_plugins/sh_motd.lua @@ -1,101 +1,178 @@ -/*------------------------------------------------------------------------------------------------------------------------- - Message of the Day --------------------------------------------------------------------------------------------------------------------------*/ +-- Remember to create the motd.txt in the data folder and add the contents!! local PLUGIN = {} -PLUGIN.Title = "MOTD" -PLUGIN.Description = "Message of the Day." -PLUGIN.Author = "Divran" +PLUGIN.Title = "MOTD2" +PLUGIN.Description = "Better MOTD" +PLUGIN.Author = "Grey" PLUGIN.ChatCommand = "motd" PLUGIN.Usage = nil -PLUGIN.Privileges = nil +PLUGIN.Privileges = { "Skip MOTD" } +MOTD_ENABLED = true; +MOTD_ACCEPT_WAIT = 5; +MOTD_DECLINE_CONFIRMATION = true; +_window = nil -function PLUGIN:Call(ply, args) - self:OpenMotd(ply) +if SERVER then + util.AddNetworkString( "MOTD2Packet" ) +else + ReceivedMOTD = false end +function PLUGIN:Call( ply, args ) + self:OpenMotd2( ply ) -function PLUGIN:PlayerInitialSpawn(ply) - timer.Simple(1, function() ply:ConCommand("evolve_startmotd") end) end -function PLUGIN:OpenMotd(ply) +function MOTDPlayerInitialSpawn( ply ) + if (file.Exists("evolve/motd.txt", "DATA")) then + timer.Create("MOTD2TimerFor"..ply:Nick(),3,3,function() + net.Start( "MOTD2Packet" ) + local tmpstr = file.Read("evolve/motd.txt", "DATA") + if tmpstr then + net.WriteString( tmpstr ) + else + net.WriteString( "Bad MOTD" ) + end + net.Send( ply) + end) + else + Msg("\n") + Msg("====================== \n") + Msg("Missing MOTD file! \n") + Msg("Make sure the file exists as: motd.txt in data/evolve/! \n") + Msg("====================== \n") + Msg("\n") + end + --timer.Simple( 7, function() ply:ConCommand("ev_motd2") end) +end +if SERVER then + hook.Add("PlayerInitialSpawn", "playerInitialSpawn", MOTDPlayerInitialSpawn) +end +function PLUGIN:OpenMotd2( ply ) if (SERVER) then - ply:ConCommand("evolve_motd") + ply:ConCommand("ev_motd2") + else + LocalPlayer():ConCommand("ev_motd2") end end - if (SERVER) then - if file.Exists("evolvemotd.txt", "DATA") then - resource.AddFile("data/evolvemotd.txt") - end - - for k,v in pairs(player.GetAll()) do - v:ConCommand("evolve_startmotd") + if (file.Exists("evolve/motd.txt", "DATA")) then + print("Received Valid MOTD2") + else + Msg("\n") + Msg("====================== \n") + Msg("Missing MOTD file! \n") + Msg("Make sure the file exists as: motd.txt in data/evolve/! \n") + Msg("====================== \n") + Msg("\n") end end if (CLIENT) then - function PLUGIN:CreateMenu() - self.StartPanel = vgui.Create("DFrame") - local w,h = 150,50 - self.StartPanel:Center() - self.StartPanel:SetSize(w, h) - self.StartPanel:SetTitle("Welcome!") - self.StartPanel:SetVisible(false) - self.StartPanel:SetDraggable(true) - self.StartPanel:ShowCloseButton(false) - self.StartPanel:SetDeleteOnClose(false) - self.StartPanel:SetScreenLock(true) - self.StartPanel:MakePopup() - - self.OpenButton = vgui.Create("DButton", self.StartPanel) - self.OpenButton:SetSize(150 / 2 - 4, 20) - self.OpenButton:SetPos(2, 25) - self.OpenButton:SetText("Open MOTD") - self.OpenButton.DoClick = function() - PLUGIN.MotdPanel:SetVisible(true) - PLUGIN.StartPanel:SetVisible(false) - end - - self.CloseButton = vgui.Create("DButton",self.StartPanel) - self.CloseButton:SetSize(150 / 2 - 6, 20) - self.CloseButton:SetPos(150 / 2 + 4, 25) - self.CloseButton:SetText("Close") - self.CloseButton.DoClick = function() - PLUGIN.StartPanel:SetVisible(false) + net.Receive( "MOTD2Packet" , function( length ) + local motdstr = net.ReadString() + if (ReceivedMOTD == true) then + return; end - - self.MotdPanel = vgui.Create("DFrame") - local w,h = ScrW() - 200,ScrH() - 200 - self.MotdPanel:SetPos(100, 100) - self.MotdPanel:SetSize(w, h) - self.MotdPanel:SetTitle("MOTD") - self.MotdPanel:SetVisible(false) - self.MotdPanel:SetDraggable(false) - self.MotdPanel:ShowCloseButton(true) - self.MotdPanel:SetDeleteOnClose(false) - self.MotdPanel:SetScreenLock(true) - self.MotdPanel:MakePopup() - - self.MotdBox = vgui.Create("HTML", self.MotdPanel) - self.MotdBox:StretchToParent(4, 25, 4, 4) - self.MotdBox:SetHTML(file.Read("evolvemotd.txt")) - end - - concommand.Add("evolve_motd", function(ply,cmd,args) - if file.Exists("evolvemotd.txt", "DATA") then - PLUGIN.MotdPanel:SetVisible(true) + ReceivedMOTD = true + local MOTD_HTML = "" + if (tonumber(length)>0) then + MOTD_HTML = motdstr + print("Valid MOTD Received in MOTD2 Plugin") + else + print("No MOTD Given.") + MOTD_HTML = "" end + if ( !MOTD_ENABLED ) then return; end + local _w = ScrW( ); + local _h = ScrH( ); + + _window = vgui.Create( "DPanel" ); + local _html = vgui.Create( "HTML", _window ); + + local _accept = vgui.Create( "DButton", _window ); + _accept:SetText( "#Accept " .. " ( " .. MOTD_ACCEPT_WAIT .. " ) " ) + _accept:SetWide( _accept:GetWide( ) * 1.5 ) + _accept:SetTooltip( "I agree to the terms and conditions." ) + _accept.DoClick = function() + print("Accepted MOTD") + _window:ClosePanel( ); + end + + local _decline = vgui.Create( "DButton", _window ); + _decline:SetText( "#Decline" ) + _decline:SetWide( _decline:GetWide( ) * 1.5 ) + _decline:SetTooltip( "I do not agree to the terms and conditions and I agree to remove any and all content and associated files of this game-mode from my PC." ) + _decline.DoClick = function() + RunConsoleCommand( "disconnect" ); + end + + // + // Hack to fix ClosePanel + // + _window.ClosePanel = function( ) + --_decline:Remove( ); + --_decline = nil; + --_accept:Remove( ); + --_accept = nil; + --_html:Remove( ); + --_html = nil; + _window:SetVisible( false ); + --_window:Remove( ); + --_window = nil; + end + + + _window:SetSize( _w - _w / 3, _h - _h / 3 ); + _window:Center( ); + -- _window:SetPos( _w / 2, -_h ) + -- _window:MoveTo( _w / 2, _h / 4, 1 ); + + _html:SetPos( 0, 0 ); + _html:SetSize( _window:GetWide( ), _window:GetTall( ) - 30 ) + + _accept:SetPos( ( _window:GetWide( ) / 2 ) - _accept:GetWide( ), _window:GetTall( ) - 25 ); + _decline:SetPos( ( _window:GetWide( ) / 2 ) + _decline:GetWide( ), _window:GetTall( ) - 25 ); + + _html:SetHTML( MOTD_HTML ); + + if ( MOTD_ACCEPT_WAIT && MOTD_ACCEPT_WAIT > 0 ) then + _accept:SetDisabled( true ); + for i = 1, MOTD_ACCEPT_WAIT do + timer.Simple( i, function( ) + if ( MOTD_ACCEPT_WAIT - i == 0 ) then + _accept:SetText( "#Accept" ) + else + _accept:SetText( "#Accept" .. " ( " .. MOTD_ACCEPT_WAIT - i .. " ) " ) + end + end ) + end + timer.Simple( MOTD_ACCEPT_WAIT, function( ) + _accept:SetDisabled( false ); + end ) + end + _window:SetVisible( true ); + _window:MakePopup( ); + if LocalPlayer():EV_HasPrivilege( "Skip MOTD" ) then + _window:ClosePanel( ) + end + end) - - concommand.Add("evolve_startmotd", function(ply,cmd,args) - if file.Exists("evolvemotd.txt", "DATA") then - if not PLUGIN.StartPanel then PLUGIN:CreateMenu() end - PLUGIN.StartPanel:SetVisible(true) - end + concommand.Add("ev_motd2",function(ply,cmd,args) + if _window then + _window:SetVisible( true ) + end end) - + function MOTDHook() + ply2=LocalPlayer() + ply2:ConCommand("ev_motd2") + end + hook.Add( "MOTD", "MOTD", MOTDHook) + concommand.Add( "motd", function( ) hook.Call( "MOTD", GAMEMODE ); end ); + concommand.Add( "rules", function( ) hook.Call( "MOTD", GAMEMODE ); end ); + concommand.Add( "tos", function( ) hook.Call( "MOTD", GAMEMODE ); end ); + concommand.Add( "eula", function( ) hook.Call( "MOTD", GAMEMODE ); end ); + concommand.Add( "terms", function( ) hook.Call( "MOTD", GAMEMODE ); end ); end -evolve:RegisterPlugin(PLUGIN) \ No newline at end of file +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_nolag.lua b/lua/ev_plugins/sh_nolag.lua new file mode 100644 index 0000000..9be7971 --- /dev/null +++ b/lua/ev_plugins/sh_nolag.lua @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------------------------------------------------------- + This command eliminate serverlags. Very useful if crappy adv-dupe shit got spawned and fuck up the server. + Visit http://www.rodcust.eu/ +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "No-Lag" +PLUGIN.Description = "With !nolag you can freeze all props at once." +PLUGIN.Author = "dOiF [AUT]" +PLUGIN.ChatCommand = "nolag" +PLUGIN.Privileges = { "Admin Anti-Lag" } + +function PLUGIN:Call( ply ) + if ( ply:EV_HasPrivilege( "Admin Anti-Lag" ) ) then + local Ent = ents.FindByClass("prop_physics") + for _,Ent in pairs(Ent) do + if Ent:IsValid() then + local phys = Ent:GetPhysicsObject() + if phys then + if phys:IsValid() then + phys:EnableMotion(false) + end + end + end + end + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has frozen all props on the server." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end + +end + +evolve:RegisterPlugin( PLUGIN ) diff --git a/lua/ev_plugins/sh_norecoil.lua b/lua/ev_plugins/sh_norecoil.lua new file mode 100644 index 0000000..9428d3d --- /dev/null +++ b/lua/ev_plugins/sh_norecoil.lua @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------------------------------------------------- + NoRecoil a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Recoil Control" +PLUGIN.Description = "Disable recoil for a player." +PLUGIN.Author = "Grey" +PLUGIN.ChatCommand = "norecoil" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "Recoil Control" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "NoRecoil" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + pl:SetNWBool( "EV_NoRecoiled", enabled ) + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has disabled recoil for ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " have recoil." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:CalcView( ply, pos, angles, fov ) + if ply:GetNWBool( "EV_NoRecoiled", false ) then + return { + origin = ply:EyePos(), + angles = ply:EyeAngles(), + fov = fov + } + end +end +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "norecoil", unpack( players ) ) + else + return "NoRecoil", evolve.category.actions, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_observation.lua b/lua/ev_plugins/sh_observation.lua new file mode 100644 index 0000000..2ff4921 --- /dev/null +++ b/lua/ev_plugins/sh_observation.lua @@ -0,0 +1,120 @@ +--[[ + Observation plugin for Evolve. + By `impulse. +]]-- + +local PLUGIN = {} + +PLUGIN.Title = "Observation" +PLUGIN.Description = "Noclip around hidden." +PLUGIN.Author = "`impulse" +PLUGIN.ChatCommand = "observe" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "Observation Mode" } + +PLUGIN.SavedPoints = {} + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Observation Mode" ) ) then + + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + + if ( !enabled ) then + + if ( self.SavedPoints[ pl ] == nil ) then + + evolve:Notify( pl, evolve.colors.red, "You are not in observation mode!" ) + return "" + + end + + pl:SetRenderMode( RENDERMODE_NORMAL ) + pl:SetColor( 255, 255, 255, 255 ) + pl:SetMoveType( MOVETYPE_WALK ) + pl:GodDisable() + pl:SetPos( self.SavedPoints[ pl ].pos ) + pl:SetEyeAngles( self.SavedPoints[ pl ].ang ) + self.SavedPoints[ pl ] = nil + + for _, w in ipairs( pl:GetWeapons() ) do + + w:SetRenderMode( RENDERMODE_NORMAL ) + w:SetColor( 255, 255, 255, 255 ) + + end + + else + + if ( self.SavedPoints[ pl ] ~= nil ) then + + evolve:Notify( pl, evolve.colors.red, "You are already in observation mode!" ) + return "" + + end + + self.SavedPoints[ pl ] = { + pos = pl:GetPos(), + ang = pl:EyeAngles() + } + + pl:SetRenderMode( RENDERMODE_NONE ) + pl:SetColor( 255, 255, 255, 0 ) + pl:SetMoveType( MOVETYPE_NOCLIP ) + pl:GodEnable() + + for _, w in ipairs( ply:GetWeapons() ) do + + w:SetRenderMode( RENDERMODE_NONE ) + w:SetColor( 255, 255, 255, 0 ) + + end + + end + + end + + if ( #players > 0 ) then + + if ( enabled ) then + + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " enter observation mode." ) + + else + + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " exit observation mode." ) + + end + + else + + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + + end + + else + + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + + end + +end + +function PLUGIN:Menu( arg, players ) + + if ( arg ) then + + table.insert( players, arg ) + RunConsoleCommand( "ev", "observe", unpack( players ) ) + + else + + return "Observation", evolve.category.actions, { { "Enter", 1 }, { "Exit", 0 } } + + end + +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_permadeath.lua b/lua/ev_plugins/sh_permadeath.lua new file mode 100644 index 0000000..4e6d7ec --- /dev/null +++ b/lua/ev_plugins/sh_permadeath.lua @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------------------------------------------------------- + PermaDeath a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Permadeath" +PLUGIN.Description = "Disable respawning for a player." +PLUGIN.Author = "Grey" +PLUGIN.ChatCommand = "nospawn" +PLUGIN.Usage = "[players] [1/0]" +PLUGIN.Privileges = { "Respawn Control" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Respawn Control" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + + for _, pl in ipairs( players ) do + pl:SetNWBool( "EV_NoRespawn", enabled ) + end + + if ( #players > 0 ) then + if ( enabled ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has prevented ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " from respawning." ) + else + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has allowed ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " to respawn." ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function NoRespawnCheck( ply ) + if ply:GetNWBool( "EV_NoRespawn", false ) then + ply:Kill() + end +end +hook.Add("PlayerSpawn","EVPermaDeathCheck",NoRespawnCheck) +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "permadeath", unpack( players ) ) + else + return "Permadeath", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_permamute.lua b/lua/ev_plugins/sh_permamute.lua new file mode 100644 index 0000000..898a1ca --- /dev/null +++ b/lua/ev_plugins/sh_permamute.lua @@ -0,0 +1,57 @@ +local Plugin = {} +Plugin.Title = "PermaMuter" +Plugin.Description = "Permanently mute players." +Plugin.Author = "Tom" +Plugin.ChatCommand = "permamute" +Plugin.Usage = "[players] [1/0]" +Plugin.Privileges = { "PermaMute" } + +function Plugin:Call( ply, args ) + if (!sql.TableExists( "permamuted_players" ) ) then + query = "CREATE TABLE permamuted_players ( steamID varchar(255), isMuted int )" + result = sql.Query(query) + end + + if ( ply:EV_HasPrivilege( "PermaMute" )) then + local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 + local players = evolve:FindPlayer( args, ply, true ) + for _, pl in ipairs( players ) do + if ( enabled ) then + query = "UPDATE permamuted_players SET isMuted = 1 WHERE steamID = '"..pl:SteamID().."'" + sql.Query(query) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has permanently muted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + pl:SetNWBool( "Muted", enabled ) + pl:SendLua( "LocalPlayer():ConCommand( \"-voicerecord\" )" ) + else + query = "UPDATE permamuted_players SET isMuted = 0 WHERE steamID = '"..pl:SteamID().."'" + sql.Query(query) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has unmuted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + pl:SetNWBool( "Muted", enabled ) + end + end + end +end + +function Plugin:PlayerCanHearPlayersVoice( _, ply ) + ID = sql.QueryValue( "SELECT isMuted from permamuted_players WHERE steamID = '"..ply:SteamID().."'" ) + if ( ID == 1 || ply.EV_MUTED) then return false end +end + +function CMOnSpawn( ply) + ID = sql.QueryValue( "SELECT isMuted from permamuted_players WHERE steamID = '"..ply:SteamID().."'" ) + if ( ID == 1 || ply.EV_MUTED) then + ply:SetNWBool( "Muted", enabled ) + ply:SendLua( "LocalPlayer():ConCommand( \"-voicerecord\" )" ) + end +end +hook.Add("PlayerSpawn","CheckIfMuted",CMOnSpawn) +function Plugin:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "permamute", unpack( players ) ) + else + return "Permanently Mute", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } + end +end + +evolve:RegisterPlugin( Plugin ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_playernames.lua b/lua/ev_plugins/sh_playernames.lua index 42d98e3..cb3ccb0 100644 --- a/lua/ev_plugins/sh_playernames.lua +++ b/lua/ev_plugins/sh_playernames.lua @@ -46,54 +46,56 @@ else if ( pl != LocalPlayer() and pl:Health() > 0 ) then local visible = hook.Call( "EV_ShowPlayerName", nil, pl ) - if ( visible != false ) then - local td = {} - td.start = LocalPlayer():GetShootPos() - td.endpos = pl:GetShootPos() - local trace = util.TraceLine( td ) - - if ( !trace.HitWorld ) then - surface.SetFont( "DefaultBold" ) - local w = surface.GetTextSize( pl:Nick():gsub( "&","--" ) ) + 32 - local h = 24 + if ( visible != false ) then + if ( LocalPlayer():EV_HasPrivilege( "Player names" ) ) then + local td = {} + td.start = LocalPlayer():GetShootPos() + td.endpos = pl:GetShootPos() + local trace = util.TraceLine( td ) - local pos = pl:GetShootPos() - local bone = pl:LookupBone( "ValveBiped.Bip01_Head1" ) - if ( bone ) then - pos = pl:GetBonePosition( bone ) - end - - local drawPos = pl:GetShootPos():ToScreen() - local distance = LocalPlayer():GetShootPos():Distance( pos ) - drawPos.x = drawPos.x - w / 2 - drawPos.y = drawPos.y - h - 25 - - local alpha = 255 - if ( distance > 512 ) then - alpha = 255 - math.Clamp( ( distance - 512 ) / ( 2048 - 512 ) * 255, 0, 255 ) + if ( !trace.HitWorld ) then + surface.SetFont( "DefaultBold" ) + local w = surface.GetTextSize( pl:Nick():gsub( "&","--" ) ) + 32 + local h = 24 + + local pos = pl:GetShootPos() + local bone = pl:LookupBone( "ValveBiped.Bip01_Head1" ) + if ( bone ) then + pos = pl:GetBonePosition( bone ) + end + + local drawPos = pl:GetShootPos():ToScreen() + local distance = LocalPlayer():GetShootPos():Distance( pos ) + drawPos.x = drawPos.x - w / 2 + drawPos.y = drawPos.y - h - 25 + + local alpha = 255 + if ( distance > 512 ) then + alpha = 255 - math.Clamp( ( distance - 512 ) / ( 2048 - 512 ) * 255, 0, 255 ) + end + + surface.SetDrawColor( 62, 62, 62, alpha ) + surface.DrawRect( drawPos.x, drawPos.y, w, h ) + surface.SetDrawColor( 129, 129, 129, alpha ) + surface.DrawOutlinedRect( drawPos.x, drawPos.y, w, h ) + + if ( pl:GetNWBool( "EV_Chatting", false ) ) then + surface.SetMaterial( self.iconChat ) + elseif ( pl:GetNWBool( "EV_AFK", false ) ) then + surface.SetMaterial( self.iconAFK ) + elseif ( evolve.ranks[ pl:EV_GetRank() ] ) then + surface.SetMaterial( evolve.ranks[ pl:EV_GetRank() ].IconTexture ) + else + surface.SetMaterial( self.iconUser ) + end + + surface.SetDrawColor( 255, 255, 255, math.Clamp( alpha * 2, 0, 255 ) ) + surface.DrawTexturedRect( drawPos.x + 5, drawPos.y + 5, 14, 14 ) + + local col = evolve.ranks[ pl:EV_GetRank() ].Color or team.GetColor( pl:Team() ) + col.a = math.Clamp( alpha * 2, 0, 255 ) + draw.DrawText( pl:Nick(), "DefaultBold", drawPos.x + 28, drawPos.y + 5, col, 0 ) end - - surface.SetDrawColor( 62, 62, 62, alpha ) - surface.DrawRect( drawPos.x, drawPos.y, w, h ) - surface.SetDrawColor( 129, 129, 129, alpha ) - surface.DrawOutlinedRect( drawPos.x, drawPos.y, w, h ) - - if ( pl:GetNWBool( "EV_Chatting", false ) ) then - surface.SetMaterial( self.iconChat ) - elseif ( pl:GetNWBool( "EV_AFK", false ) ) then - surface.SetMaterial( self.iconAFK ) - elseif ( evolve.ranks[ pl:EV_GetRank() ] ) then - surface.SetMaterial( evolve.ranks[ pl:EV_GetRank() ].IconTexture ) - else - surface.SetMaterial( self.iconUser ) - end - - surface.SetDrawColor( 255, 255, 255, math.Clamp( alpha * 2, 0, 255 ) ) - surface.DrawTexturedRect( drawPos.x + 5, drawPos.y + 5, 14, 14 ) - - local col = evolve.ranks[ pl:EV_GetRank() ].Color or team.GetColor( pl:Team() ) - col.a = math.Clamp( alpha * 2, 0, 255 ) - draw.DrawText( pl:Nick(), "DefaultBold", drawPos.x + 28, drawPos.y + 5, col, 0 ) end end end diff --git a/lua/ev_plugins/sh_ragdoll.lua b/lua/ev_plugins/sh_ragdoll.lua index f69ea67..577294e 100644 --- a/lua/ev_plugins/sh_ragdoll.lua +++ b/lua/ev_plugins/sh_ragdoll.lua @@ -19,13 +19,30 @@ function PLUGIN:Call( ply, args ) if ( enabled ) then if ( !pl.EV_Ragdolled and pl:Alive() ) then pl:DrawViewModel( false ) - pl:StripWeapons() + pl:DrawWorldModel( false ) + + pl.active_weapon = pl:GetActiveWeapon():GetClass() + --[[local weapons = pl:GetWeapons() + pl.weapon_store = {} + for k,v in pairs(weapons) do + table.insert(pl.weapon_store, { + class=v:GetClass(), + hold=v:GetHoldType(), + clip1=v:Clip1(), + clip2=v:Clip2(), + nextP=v:GetNextPrimaryFire(), + nextS=v:GetNextSecondaryFire() + }) + end + pl:StripWeapons()]] local doll = ents.Create( "prop_ragdoll" ) doll:SetModel( pl:GetModel() ) doll:SetPos( pl:GetPos() ) doll:SetAngles( pl:GetAngles() ) doll:Spawn() + local phys = doll:GetPhysicsObject() + phys:SetVelocity(pl:GetVelocity()); doll:Activate() pl.EV_Ragdoll = doll @@ -36,10 +53,32 @@ function PLUGIN:Call( ply, args ) pl.EV_Ragdolled = true end else + pl:UnSpectate() + pl:DrawViewModel( true ) + pl:DrawWorldModel( true ) pl:SetNoTarget( false ) pl:SetParent() - pl.EV_Ragdolled = false - pl:Spawn() + local phys = pl.EV_Ragdoll:GetPhysicsObject() + pl:SetVelocity(phys:GetVelocity()) + pl.EV_Ragdoll:Remove() + + --[[pl:SetSuppressPickupNotices(true) + for k,v in pairs( pl.weapon_store ) do + pl:Give(v['class']) + local weapon = pl:GetWeapon(v['class']) + + weapon:SetHoldType(v['hold']) + weapon:SetClip1(v['clip1']) + weapon:SetClip2(v['clip2']) + weapon:SetNextPrimaryFire(v['nextP']) + weapon:SetNextSecondaryFire(v['nextS']) + end + pl:SetSuppressPickupNotices(false)]] + pl:SelectWeapon(pl.active_weapon) + + pl.active_weapon = nil + pl.weapon_store = nil + pl.EV_Ragdolled = false end end diff --git a/lua/ev_plugins/sh_respawn.lua b/lua/ev_plugins/sh_respawn.lua index b3038f7..1d4f19f 100644 --- a/lua/ev_plugins/sh_respawn.lua +++ b/lua/ev_plugins/sh_respawn.lua @@ -16,6 +16,12 @@ function PLUGIN:Call( ply, args ) for _, pl in ipairs( players ) do pl:Spawn() + local nametest = string.lower(gmod.GetGamemode().Name) + if (nametest == "trouble in terrorist town" ) then + pl:SetTeam( TEAM_TERROR ) + pl:Spawn() + print("Respawning in TTT...") + end end if ( #players > 0 ) then diff --git a/lua/ev_plugins/sh_sandbox.lua b/lua/ev_plugins/sh_sandbox.lua new file mode 100644 index 0000000..af1b7c2 --- /dev/null +++ b/lua/ev_plugins/sh_sandbox.lua @@ -0,0 +1,232 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Relocates settings for +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Sandbox" +PLUGIN.Description = "Sandbox settings relocated." +PLUGIN.Author = "Overv & EntranceJew" +PLUGIN.ChatCommand = nil +PLUGIN.Usage = nil +PLUGIN.Privileges = { "Sandbox Settings" } +PLUGIN.Icon = "world" +PLUGIN.Settings = { + sbox_maxprops = { + label = "Props", + desc = "Max number of props.", + stype = "limit", + min = 0, + max = 200, + default = 150, + isconvar = true, + }, + sbox_maxragdolls = { + label = "Ragdolls", + desc = "Max number of ragdolls.", + stype = "limit", + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxvehicles = { + label = "Vehicles", + desc = "Max number of vehicles.", + stype = "limit", + min = 0, + max = 200, + default = 6, + isconvar = true, + }, + sbox_maxeffects = { + label = "Effects", + desc = "Max number of efects.", + stype = "limit", + min = 0, + max = 200, + default = 50, + isconvar = true, + }, + sbox_maxballoons = { + label = "Balloons", + desc = "Max number of balloons.", + stype = "limit", + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxnpcs = { + label = "NPCs", + desc = "Max number of NPCs.", + stype = "limit", + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxdynamite = { + label = "Dynamite", + desc = "Max number of dynamite.", + stype = "limit", + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxlamps = { + label = "Lamps", + desc = "Max number of lamps.", + stype = "limit", + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxlights = { + label = "Lights", + desc = "Max number of lights.", + stype = "limit", + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxwheels = { + label = "Wheels", + desc = "Max number of wheels.", + stype = "limit", + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxthrusters = { + label = "Thrusters", + desc = "Max number of thrusters.", + stype = "limit", + min = 0, + max = 200, + default = 30, + isconvar = true, + }, + sbox_maxhoverballs = { + label = "Hoverballs", + desc = "Max number of hoverballs.", + stype = "limit", + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxbuttons = { + label = "Buttons", + desc = "Max number of buttons.", + stype = "limit", + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxemitters = { + label = "Emitters", + desc = "Max number of emitters.", + stype = "limit", + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxspawners = { + label = "Spawners", + desc = "Max number of spawners.", + stype = "limit", + min = 0, + max = 200, + default = 100, + isconvar = true, + }, + sbox_maxturrets = { + label = "Turrets", + desc = "Max number of turrets.", + stype = "limit", + min = 0, + max = 200, + default = 100, + isconvar = true, + }, + + sbox_godmode = { + label = "Godmode", + desc = "Toggle godmode globally.", + stype = "bool", + default = false, + isconvar = true, + }, + sbox_noclip = { + label = "Noclip", + desc = "Toggle the ability to use noclip.", + stype = "bool", + default = false, + isconvar = true, + }, + sbox_playershurtplayers = { + label = "PvP", + desc = "Toggle player vs player damage.", + stype = "bool", + default = true, + isconvar = true, + }, + sbox_weapons = { + label = "Weapons", + desc = "Toggle the usage of weapons.\nWon't do much in DarkRP.", + stype = "bool", + default = true, + isconvar = true, + }, + g_ragdoll_maxcount = { + label = "Keep NPC bodies", + desc = "Toggle.", + stype = "bool", + default = 0, + multiplier = 8, + isconvar = true, + }, + sbox_persist = { + label = 'Persistant Mode', + desc = "Makes everything exist ... more.", + stype = 'bool', + default = false, + isconvar = true, + }, + physgun_limited = { + label = 'Limited Physgun', + desc = "Less physgun to manage.", + stype = 'bool', + default = false, + isconvar = true, + }, + sbox_bonemanip_npc = { + label = 'Bone Manipulate NPCs', + desc = "Manipulate the bones of NPCs.", + stype = 'bool', + default = true, + isconvar = true, + }, + sbox_bonemanip_player = { + label = 'Bone Manipulate Players', + desc = "Manipulate the bones of players.", + stype = 'bool', + default = false, + isconvar = true, + }, + sbox_bonemanip_misc = { + label = 'Bone Manipulate Others', + desc = "Manipulate the bones of anything else.", + stype = 'bool', + default = false, + isconvar = true, + }, +} + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_serversettings.lua b/lua/ev_plugins/sh_serversettings.lua new file mode 100644 index 0000000..6d138af --- /dev/null +++ b/lua/ev_plugins/sh_serversettings.lua @@ -0,0 +1,65 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Relocates settings for +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Server" +PLUGIN.Description = "Server settings outside the utilities menu." +PLUGIN.Author = "EntranceJew" +PLUGIN.ChatCommand = nil +PLUGIN.Usage = nil +PLUGIN.Privileges = { "Server Settings" } +PLUGIN.Icon = "server" +PLUGIN.Settings = { + sv_password = { + label = 'Connect Password', + desc = 'Only people who know the code can join!', + stype = 'string', + default = 'example' + }, + sv_kickerrornum = { + label = "Kick for Clientside Errors", + desc = "Kicks clients that experience this many errors.\n0=Don't kick.", + stype = "limit", + min = 0, + max = 200, + default = 0, + isconvar = true, + }, + sv_allowcslua = { + label = 'Allow Client Lua', + desc = "Allows clients to run lua. Usually you don't want this.", + stype = 'bool', + default = false, + isconvar = true, + }, + sv_gravity = { + label = "Gravity", + desc = "F=G((m1*m2)/r^2)", + stype = "limit",--float + min = -200, + max = 600, + default = 600, + isconvar = true, + }, + phys_timescale = { + label = "Physics Timescale", + desc = "Time is relative. Is it your uncle?", + stype = "limit",--float + min = 0, + max = 2, + default = 1.0, + isconvar = true, + }, + gmod_physiterations = { + label = "Physics Iterations", + desc = "How frequently we get physical.", + stype = "limit",--float + min = 1, + max = 10, + default = 1, + isconvar = true, + }, +} + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_size.lua b/lua/ev_plugins/sh_size.lua new file mode 100644 index 0000000..6c5f411 --- /dev/null +++ b/lua/ev_plugins/sh_size.lua @@ -0,0 +1,81 @@ +-- Name: Size +-- Desc: Aw`llows you to see people at different sizes +-- Author: Lixquid + +-- Heavily based on Overv's original Scale plugin + +local PLUGIN = {} +PLUGIN.Title = "Size" +PLUGIN.Description = "Allows you to see people at different sizes" +PLUGIN.Author = "Lixquid" +PLUGIN.ChatCommand = "size" +PLUGIN.Usage = " " +PLUGIN.Privileges = { "Size" } + +function PLUGIN:RenderScene() + for _, v in pairs( player.GetAll() ) do + if v:GetModelScale() != v:GetNetworkedFloat("EV_Size",1) then + v:SetModelScale( v:GetNetworkedFloat("EV_Size",1) , 0) + end + end +end + +function PLUGIN:Call( ply, args ) + if ply:EV_HasPrivilege( "Size" ) then + if #args >= 1 then + local scale = tonumber( args[ #args ] ) + + if scale then + scale = math.Clamp( scale, 0.05, 20 ) + local players = evolve:FindPlayer( args, ply ) + if #players > 0 then + for _, pl in pairs( players ) do + pl:SetNetworkedFloat( "EV_Size", scale ) + pl:SetHull( Vector( -16 * scale, -16 * scale, 0 ), Vector( 16 * scale, 16 * scale, 72 * scale ) ) + pl:SetHullDuck( Vector( -16 * scale, -16 * scale, 0 ), Vector( 16 * scale, 16 * scale, 36 * scale ) ) + pl:SetViewOffset( Vector( 0, 0, 68 * scale ) ) + pl:SetViewOffsetDucked( Vector( 0, 0, 32 * scale ) ) + pl:SetStepSize( scale * 16 ) -- Best Guess, anyone? + pl:SetCollisionBounds( Vector( -16 * scale, -16 * scale, 0 ), Vector( 16 * scale, 16 * scale, 72 * scale ) ) + pl:SetWalkSpeed( 150 * ( scale + scale + scale ) * 0.33 + 100 ) + pl:SetRunSpeed( 100 * ( scale + scale + scale ) * 0.33 + 400 ) + pl:SetJumpPower( 160 * scale ) + --pl:SetGravity( 1 / scale ) + end + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has set the size of ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " to " .. scale .. "." ) + else + evolve:Notify( plscale, evolve.colors.red, "No matching players found." ) + end + else + evolve:Notify( plscale, evolve.colors.red, "You must specify numeric size parameters!" ) + end + else + evolve:Notify( plscale, evolve.colors.red, "You need to specify at least one player and one size parameter!" ) + end + else + evolve:Notify( plscale, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:CalcView( ply, origin, angles, fov, nearZ, farZ ) + if ply:GetNetworkedFloat("EV_Size",1) == 1 then return end + + local scale = ply:GetNetworkedFloat("EV_Size",1) + + origin = origin + Vector( 0, 0, 64 * scale ) +end + +function PLUGIN:Menu( arg, players ) + if arg then + table.insert( players, arg ) + RunConsoleCommand( "ev", "size", unpack( players ) ) + else + return "Size", evolve.category.actions, { + { "Default", 1 }, + { "Giant", 10 }, + { "Small", 0.7 }, + { "Tiny", 0.3} + } + end +end +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_spawnpoint.lua b/lua/ev_plugins/sh_spawnpoint.lua new file mode 100644 index 0000000..68122e2 --- /dev/null +++ b/lua/ev_plugins/sh_spawnpoint.lua @@ -0,0 +1,49 @@ + +local PLUGIN = {}; + +PLUGIN.Title = "Spawnpoint"; +PLUGIN.Description = "Set your spawnpoint."; +PLUGIN.Author = "DarKSunrise"; +PLUGIN.ChatCommand = "spawnpoint"; +PLUGIN.Usage = "[set/reset]"; +PLUGIN.Privileges = {"Set and reset spawnpoint",} + +PLUGIN.spawnpoints = {}; + +function PLUGIN:Call(ply, args) + if(not ply:EV_HasPrivilege("Set and reset spawnpoint")) then + evolve:Notify(ply, evolve.colors.red, evolve.constants.notallowed); + return; + end + local players = evolve:FindPlayer( args, ply, true ) + local arg1 = tostring(args[ 1 ]) or "" + local enabled = tostring(args[ #args ]) or "" + if (arg1 == "set") or (arg1 == "reset") then + players = {}; + table.insert(players,ply) + enabled = arg1 + end + for _, pl in ipairs( players ) do + if (string.lower(enabled) != "reset") then + evolve:Notify(pl, evolve.colors.white, "Your ", evolve.colors.blue, "spawnpoint ", evolve.colors.white, "has been ", evolve.colors.blue, "set", evolve.colors.white, "!"); + + self.spawnpoints[pl] = { + pos = ply:GetPos(), + ang = ply:EyeAngles() + }; + else + evolve:Notify(pl, evolve.colors.white, "Your ", evolve.colors.blue, "spawnpoint ", evolve.colors.white, "has been ", evolve.colors.red, "reset", evolve.colors.white, "!"); + + self.spawnpoints[pl] = nil; + end + end +end + +function PLUGIN:PlayerSpawn(ply) + if(self.spawnpoints[ply] and ply:EV_HasPrivilege("Set and reset spawnpoint")) then + ply:SetPos(self.spawnpoints[ply].pos); + ply:SetEyeAngles(self.spawnpoints[ply].ang); + end +end + +evolve:RegisterPlugin(PLUGIN); \ No newline at end of file diff --git a/lua/ev_plugins/sh_thirdperson.lua b/lua/ev_plugins/sh_thirdperson.lua new file mode 100644 index 0000000..e2c0e02 --- /dev/null +++ b/lua/ev_plugins/sh_thirdperson.lua @@ -0,0 +1,126 @@ +local PLUGIN = {} +PLUGIN.Title = "Third Person" +PLUGIN.Description = "Allows players to toggle third person view." +PLUGIN.Author = "Alan Edwardes" +PLUGIN.ChatCommand = "thirdperson" +PLUGIN.Usage = "[1/0]" +PLUGIN.Privileges = { "Third Person" } +function PointDir( from, to) + local ang = to - from + return ang:Angle() +end +function PLUGIN:CalcView( ply, pos, angles, fov ) + if ply.EV_ThirdPerson then + local tracev = ply:GetEyeTrace() + ply.EV_TP_LookPos = tracev.HitPos + tmporigin = pos-(angles:Forward()*50)+(angles:Right()*40) + if angles.y>0 then + origangle = Angle( angles.p, angles.y+39, angles.r) + else + origangle = Angle( angles.p, angles.y-39, angles.r) + end + tmpangles = PointDir(pos-(angles:Forward()*50)+(angles:Right()*40), ply.EV_TP_LookPos) + if ply.EV_ViewAngle then + + if ply.EV_ViewAngle.p<0 and tmpangles.p>0 then + ply.EV_ViewAngle.p=ply.EV_ViewAngle.p+360 + end + if ply.EV_ViewAngle.p>0 and tmpangles.p<0 then + ply.EV_ViewAngle.p=ply.EV_ViewAngle.p-360 + end + if ply.EV_ViewAngle.y<0 and tmpangles.y>0 then + ply.EV_ViewAngle.y=ply.EV_ViewAngle.y+360 + end + if ply.EV_ViewAngle.y>0 and tmpangles.y<0 then + ply.EV_ViewAngle.y=ply.EV_ViewAngle.y-360 + end + if ply.EV_ViewAngle.r<0 and tmpangles.r>0 then + ply.EV_ViewAngle.r=ply.EV_ViewAngle.r+360 + end + if ply.EV_ViewAngle.r>0 and tmpangles.r<0 then + ply.EV_ViewAngle.r=ply.EV_ViewAngle.r-360 + end + tmpangles2 = ply.EV_ViewAngle + else + tmpangles2 = origangle + ply.EV_ViewAngle = origangle + end + ply.EV_ViewAngle=tmpangles + --if math.NormalizeAngle(angles.y) > 0 then + if (math.abs(tmpangles2.y - tmpangles.y)<30 and math.abs(tmpangles2.p - tmpangles.p)<30 and math.abs(tmpangles2.r - tmpangles.r)<30 ) then + return { + origin = tmporigin, + angles = Angle((tmpangles.p + tmpangles2.p)/2,(tmpangles.y + tmpangles2.y)/2,(tmpangles.r + tmpangles2.r)/2), + fov = fov + } + else + return { + origin = tmporigin, + angles = Angle((tmpangles.p),(tmpangles.y ),(tmpangles.r )), + fov = fov + } + end + --else + --return { + -- origin = pos-(angles:Forward()*50)+(angles:Right()*40), + -- angles = angles:RotateAroundAxis(angles:Up(),-39), + -- fov = fov + --} + --end + end +end + +function PLUGIN:ShouldDrawLocalPlayer( ply ) + if ply.EV_ThirdPerson then return true end +end + +function PLUGIN:PlayerInitialSpawn( ply ) + timer.Create("SetThirdPersonViewLoadIn", 5, 1, function() + --[[ + For some reason you can't add to the player + table before the player has completely loaded + in, so delay it 5 seconds. + ]]-- + if ply then + self:SetThirdPersonView( ply, ply:GetProperty( "ThirdPersonView" ) ) + end + end ) +end + +function PLUGIN:SetThirdPersonView( ply, setting ) + if setting ~= nill then + ply:SendLua("LocalPlayer().EV_ThirdPerson = " .. tostring(setting) ) + end +end + +function PLUGIN:Call( ply, args ) + if ply:EV_HasPrivilege( "Third Person" ) then + if args[1] == "0" then + ply:SetProperty( "ThirdPersonView", false ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to first person view." ) + self:SetThirdPersonView( ply, false ) + else + ply:SetProperty( "ThirdPersonView", true ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to third person view." ) + self:SetThirdPersonView( ply, true ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) + +local PLUGIN = {} +PLUGIN.Title = "First Person" +PLUGIN.Description = "So players can just type !firstperson to return to normal." +PLUGIN.Author = "Alan Edwardes" +PLUGIN.ChatCommand = "firstperson" + +function PLUGIN:Call( ply, args ) + ply:SetProperty( "ThirdPersonView", false ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to first person view." ) + ply:SendLua( "LocalPlayer().EV_ThirdPerson = false" ) +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_tpa.lua b/lua/ev_plugins/sh_tpa.lua new file mode 100644 index 0000000..8335ae7 --- /dev/null +++ b/lua/ev_plugins/sh_tpa.lua @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Goto a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "TPA" +PLUGIN.Description = "Go to a player if they accept." +PLUGIN.Author = "[DARK]Grey" +PLUGIN.ChatCommand = "tpa" +PLUGIN.Usage = "[player]" +PLUGIN.Privileges = { "TPA" } +Evolve_TPA_Table = {} +Evolve_TPA_Table_Num = 1 +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "TPA" ) and ply:IsValid() ) then + local players = evolve:FindPlayer( args, ply, false, true ) + + if ( #players < 2 ) then + if ( #players > 0 ) then + evolve:Notify(players[1], evolve.colors.blue, ply:Nick(), evolve.colors.white, " wants to teleport to you. !tpaccept to accept. " ) + evolve:Notify(ply, evolve.colors.white, "TPA sent to ",evolve.colors.red,players[1]:Nick(),evolve.colors.white,"." ) + Evolve_TPA_Table[Evolve_TPA_Table_Num] = {} + Evolve_TPA_Table[Evolve_TPA_Table_Num][1] = ply + Evolve_TPA_Table[Evolve_TPA_Table_Num][2] = players[1] + Evolve_TPA_Table_Num=Evolve_TPA_Table_Num+1 + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( players, true ), evolve.colors.white, "?" ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_tpaccept.lua b/lua/ev_plugins/sh_tpaccept.lua new file mode 100644 index 0000000..eadf028 --- /dev/null +++ b/lua/ev_plugins/sh_tpaccept.lua @@ -0,0 +1,94 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Goto a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "TPAccept" +PLUGIN.Description = "Accept TPA Request" +PLUGIN.Author = "[DARK]Grey" +PLUGIN.ChatCommand = "tpaccept" +PLUGIN.Usage = "" +PLUGIN.Privileges = { "Teleport Accept" } + +PLUGIN.Positions = {} + +if Evolve_TPA_Table then + print ("TPA Table Exists.") +else + print ("Creating TPA Table.") + Evolve_TPA_Table = {} + Evolve_TPA_Table_Num = 0 +end +for i=0,360,45 do table.insert( PLUGIN.Positions, Vector(math.cos(i),math.sin(i),0) ) end -- Around +table.insert( PLUGIN.Positions, Vector(0,0,1) ) -- Above + +function PLUGIN:FindPosition( ply ) + local size = Vector( 32, 32, 72 ) + + local StartPos = ply:GetPos() + Vector(0,0,size.z/2) + + for _,v in ipairs( self.Positions ) do + local Pos = StartPos + v * size * 1.5 + + local tr = {} + tr.start = Pos + tr.endpos = Pos + tr.mins = size / 2 * -1 + tr.maxs = size / 2 + local trace = util.TraceHull( tr ) + + if (!trace.Hit) then + return Pos - Vector(0,0,size.z/2) + end + end + + return false +end + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Teleport Accept" ) and ply:IsValid() ) then + local numiterations = 0; + for k,v in pairs(Evolve_TPA_Table) do + local tmptable = v; + if tmptable then + local frompl = tmptable[1] + local topl = tmptable[2] + if (topl == ply) then + numiterations = numiterations + 1 + table.remove(tmptable,k) + evolve:Notify(ply, evolve.colors.white, "Accepted TPA from ",evolve.colors.red,frompl:Nick(),evolve.colors.white,"." ) + evolve:Notify(frompl, evolve.colors.white, "TPA accepted by ",evolve.colors.red,topl:Nick(),evolve.colors.white,"." ) + if ( frompl:InVehicle() ) then frompl:ExitVehicle() end + if ( topl:InVehicle() ) then topl:ExitVehicle() end + if ( frompl:GetMoveType() == MOVETYPE_NOCLIP) then + frompl:SetPos( topl:GetPos() + topl:GetForward() * 45 ) + else + local Pos = self:FindPosition( topl ) + if (Pos) then + frompl:SetPos( Pos ) + else + frompl:SetPos( topl:GetPos() + Vector(0,0,72) ) + end + end + end + else + print("No data received for TPA temp table.") + end + end + if numiterations < 1 then + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + RunConsoleCommand( "ev", "goto", unpack( players ) ) + else + return "Goto", evolve.category.teleportation + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_tpdeny.lua b/lua/ev_plugins/sh_tpdeny.lua new file mode 100644 index 0000000..fe99548 --- /dev/null +++ b/lua/ev_plugins/sh_tpdeny.lua @@ -0,0 +1,81 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Goto a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "TPDeny" +PLUGIN.Description = "Deny TPA Request" +PLUGIN.Author = "[DARK]Grey" +PLUGIN.ChatCommand = "tpdeny" +PLUGIN.Usage = "" +PLUGIN.Privileges = { "Teleport Deny" } + +PLUGIN.Positions = {} + +if Evolve_TPA_Table then + print ("TPA Table Exists.") +else + print ("Creating TPA Table.") + Evolve_TPA_Table = {} + Evolve_TPA_Table_Num = 0 +end +for i=0,360,45 do table.insert( PLUGIN.Positions, Vector(math.cos(i),math.sin(i),0) ) end -- Around +table.insert( PLUGIN.Positions, Vector(0,0,1) ) -- Above + +function PLUGIN:FindPosition( ply ) + local size = Vector( 32, 32, 72 ) + + local StartPos = ply:GetPos() + Vector(0,0,size.z/2) + + for _,v in ipairs( self.Positions ) do + local Pos = StartPos + v * size * 1.5 + + local tr = {} + tr.start = Pos + tr.endpos = Pos + tr.mins = size / 2 * -1 + tr.maxs = size / 2 + local trace = util.TraceHull( tr ) + + if (!trace.Hit) then + return Pos - Vector(0,0,size.z/2) + end + end + + return false +end + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Teleport Deny" ) and ply:IsValid() ) then + local numiterations = 0; + for k,v in pairs(Evolve_TPA_Table) do + local tmptable = v; + if tmptable then + local frompl = tmptable[1] + local topl = tmptable[2] + if (topl == ply) then + numiterations = numiterations + 1 + table.remove(tmptable,k) + evolve:Notify(frompl, evolve.colors.white, "TPA declined by ",evolve.colors.red,topl:Nick(),evolve.colors.white,"." ) + end + else + print("No data received for TPA temp table.") + end + end + if numiterations < 1 then + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + RunConsoleCommand( "ev", "goto", unpack( players ) ) + else + return "Goto", evolve.category.teleportation + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_traitor.lua b/lua/ev_plugins/sh_traitor.lua new file mode 100644 index 0000000..ce5c3fd --- /dev/null +++ b/lua/ev_plugins/sh_traitor.lua @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Traitor +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Traitor" +PLUGIN.Description = "Makes a player traitor" +PLUGIN.Author = "-[LCG]- Marvincmarvin | mostly Overv" +PLUGIN.ChatCommand = "traitor" +PLUGIN.Usage = "[players]" +PLUGIN.Privileges = { "TTT Traitor" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "TTT Traitor" ) ) then + local players = evolve:FindPlayer( args, ply ) + + for _, pl in ipairs( players ) do + pl:SetRole(ROLE_TRAITOR) + SendFullStateUpdate() + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has traitorized ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_twerkparty.lua b/lua/ev_plugins/sh_twerkparty.lua new file mode 100644 index 0000000..5b31180 --- /dev/null +++ b/lua/ev_plugins/sh_twerkparty.lua @@ -0,0 +1,57 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Kill a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Twerk" +PLUGIN.Description = "Twerkify a player." +PLUGIN.Author = "[DARK]Grey" +PLUGIN.ChatCommand = "twerk" +PLUGIN.Usage = "[players]" +PLUGIN.Privileges = { "Twerk", "Twerk Others" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Twerk" ) ) then + local arg1 = tostring(args[ 1 ]) or "" + if #args == 0 then + arg1 = "" + end + if (tostring(args) == "") then + arg1="" + end + local players = evolve:FindPlayer( args, ply ) + local enabled = false + if ( arg1 == "" or !arg1) then + players = evolve:FindPlayer( ply:Nick(), ply ) + enabled = true + else + if ply:EV_HasPrivilege( "Twerk Others" ) then + enabled = true + end + end + for _, pl in ipairs( players ) do + if (enabled == true) then + print("Made "..pl:Nick().." twerk.") + pl:SendLua( "LocalPlayer():ConCommand( \"act muscle\" )" ) + end + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has made ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, " twerk." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + RunConsoleCommand( "ev", "twerk", unpack( players ) ) + else + return "Twerk", evolve.category.punishment + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_veto.lua b/lua/ev_plugins/sh_veto.lua new file mode 100644 index 0000000..d027007 --- /dev/null +++ b/lua/ev_plugins/sh_veto.lua @@ -0,0 +1,23 @@ +local PLUGIN = {} +PLUGIN.Title = "Veto" +PLUGIN.Description = "Veto a mapvote." +PLUGIN.Author = "Feha" +PLUGIN.ChatCommand = "veto" +PLUGIN.Privileges = { "Veto" } + +function PLUGIN:Call( ply, args ) + if (ply:EV_HasPrivilege( "Veto" )) then + self:VotemapVeto( ply ) + end +end + +function PLUGIN:VotemapVeto( ply ) + if (timer.IsTimer( "evolve_votemap" )) then + timer.Destroy( "evolve_votemap" ) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " used his powers to ", evolve.colors.red, "veto", evolve.colors.white, " the voted mapchange." ) + else + evolve:Notify( ply, evolve.colors.red, "No voted mapchange currently in progress." ) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_votemap.lua b/lua/ev_plugins/sh_votemap.lua new file mode 100644 index 0000000..29c1793 --- /dev/null +++ b/lua/ev_plugins/sh_votemap.lua @@ -0,0 +1,122 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Vote for a map +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Votemap" +PLUGIN.Description = "Vote for a map." +PLUGIN.Author = "Feha and [DARK]Grey" +PLUGIN.ChatCommand = "votemap" +PLUGIN.Usage = '[name/num]' +PLUGIN.Privileges = { "Votemap" } +PLUGIN.Maps = {} +PLUGIN.Votes = {} +PLUGIN.Voters = {} +tmpGlobalMap = "" +-- Initialization +function PLUGIN:Initialize() + CreateConVar("ev_votemap_percent","0.6") --How many percent of the players that have to vote for the same map + CreateConVar("ev_votemap_delay","10") --How many seconds after a voted mapchange have started that it still can be stopped + self:GetMaps() +end +-- Get map list from the map list plugin +function PLUGIN:GetMaps() + local files = file.Find( "maps/*.bsp", "GAME" ) + local temp = "" + local i = 0; + for _, filename in pairs( files ) do + temp = string.sub(filename,1,string.len(filename)-4) + table.insert( PLUGIN.Maps, temp) + end +end + +-- Does the map exist on the server? +function PLUGIN:MapExists( map ) + for index, name in pairs( self.Maps ) do + if (index == tonumber(map) or name == map) then + return true, index + end + end + return false, 0 +end + + +function PLUGIN:Call( ply, args ) + if (ply:EV_HasPrivilege( "Votemap" )) then + if (args[1] and args[1] != "") then + if (!timer.Exists( "evolve_votemap" )) then + local map = args[1] + local exists, index = PLUGIN:MapExists( map ) + if (!exists) then + evolve:Notify( ply, evolve.colors.red, "That map does not exist." ) + else + --No need to remove a vote if the player have not voted for anything + if (self.Voters[ply]) then + self:RemoveVote( self.Voters[ply] ) + end + + local votesLeft = self:GetVotesNeeded() - self:GetVotes(index) - 1 + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " voted for ", evolve.colors.red, self.Maps[index], evolve.colors.white, ". It needs ", evolve.colors.red, tostring(votesLeft), evolve.colors.white, " more." ) + + self:AddVote( index ) + + --Set what map the player have voted for so we can remove a vote from it if player change his mind + self.Voters[ply] = index + end + else + evolve:Notify( ply, evolve.colors.red, "Already changing to a map." ) + end + else + --print maps to console + evolve:Notify( ply, evolve.colors.red, "Printed a list of the maps in console." ) + for index, name in pairs( self.Maps ) do + ply:PrintMessage( HUD_PRINTCONSOLE, index .. ": " .. name ) + end + end + end +end + +function PLUGIN:AddVote( index ) + if (!self.Votes[index]) then + self.Votes[index] = 0 + end + + self.Votes[index] = self.Votes[index] + 1 + + --As we added a vote for the map, we should check if it has enough votes + self:CheckVote( index ) +end + +function PLUGIN:RemoveVote( index ) + if (!self.Votes[index]) then + self.Votes[index] = 0 + end + + self.Votes[index] = self.Votes[index] - 1 +end + +function PLUGIN:GetVotes( index ) + if (!self.Votes[index]) then + self.Votes[index] = 0 + end + + return self.Votes[index] +end + +function PLUGIN:GetVotesNeeded( ) + return math.ceil(#player.GetAll() * tonumber(GetConVarString("ev_votemap_percent"))) +end + +function PLUGIN:CheckVote( index ) + if (self.Votes[index] >= PLUGIN:GetVotesNeeded( )) then + local map = self.Maps[index] + tmpGlobalMap = map + local delay = tonumber(GetConVarString("ev_votemap_delay")) + evolve:Notify( evolve.colors.red, "Warning:", evolve.colors.white, " changing map to ", evolve.colors.red, map, evolve.colors.white, " in ", evolve.colors.red, tostring(delay), evolve.colors.white, " seconds." ) + timer.Create( "evolve_votemap", delay, 1, function( ) + game.ConsoleCommand( "changelevel " .. tmpGlobalMap .. "\n" ) + end) + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_wallet.lua b/lua/ev_plugins/sh_wallet.lua new file mode 100644 index 0000000..1609178 --- /dev/null +++ b/lua/ev_plugins/sh_wallet.lua @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Set the health of a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Wallet" +PLUGIN.Description = "Set the DarkRP Wallet of a player." +PLUGIN.Author = "EntranceJew" +PLUGIN.ChatCommand = "wallet" +PLUGIN.Usage = " [ammount]" +PLUGIN.Privileges = { "Wallet" } + +function PLUGIN:Call( ply, args ) + if ( ply:EV_HasPrivilege( "Wallet" ) ) then + local players = evolve:FindPlayer( args, ply, true ) + local amount = math.Clamp( tonumber( args[ #args ] ) or 100, 0, 2147483647 ) + + for _, pl in ipairs( players ) do + pl:addMoney( amount ) + end + + if ( #players > 0 ) then + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has given ", evolve.colors.red, evolve:CreatePlayerList( players ), Color(123,178,68,255), GAMEMODE.Config.currency..amount, evolve.colors.white, "." ) + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers ) + end + else + evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed ) + end +end + +function PLUGIN:Menu( arg, players ) + if ( arg ) then + table.insert( players, arg ) + RunConsoleCommand( "ev", "wallet", unpack( players ) ) + else + args = {} + for i = 1, 10 do + args[i] = { i * 10 } + end + return "Wallet", evolve.category.actions, args + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sv_consolecommands.lua b/lua/ev_plugins/sv_consolecommands.lua index 98a51f4..033c5e3 100644 --- a/lua/ev_plugins/sv_consolecommands.lua +++ b/lua/ev_plugins/sv_consolecommands.lua @@ -22,11 +22,16 @@ function PLUGIN:CCommand( ply, com, cargs ) local command = cargs[1] local args = self:GetArguments( cargs ) + local silentnotify = evolve.SilentNotify or string.Left( command, 1 ) == "@" + if(silentnotify) then + command = string.sub(command, 2) + end evolve:Log( evolve:PlayerLogStr( ply ) .. " ran command '" .. command .. "' with arguments '" .. table.concat( args, " " ) .. "' via console." ) for _, plugin in ipairs( evolve.plugins ) do if ( plugin.ChatCommand == command or ( type( plugin.ChatCommand ) == "table" and table.HasValue( plugin.ChatCommand, command ) ) ) then + evolve.SilentNotify = silentnotify res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) evolve.SilentNotify = false diff --git a/lua/ev_plugins/sv_rankovertime.lua b/lua/ev_plugins/sv_rankovertime.lua new file mode 100644 index 0000000..c2f0036 --- /dev/null +++ b/lua/ev_plugins/sv_rankovertime.lua @@ -0,0 +1,103 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Increases peoples' ranks over time +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Ranks over time" +PLUGIN.Description = "Increases peoples' ranks over time." +PLUGIN.Author = "Divran" +PLUGIN.ChatCommand = "rankup" +PLUGIN.Usage = "<[block/unblock] [player]> OR JUST <[player]>" +PLUGIN.Privileges = { "Block ranks over time", "Unblock ranks over time" } + +--------- EDITABLE AREA +-- rankname = { targetrank, timerequired (seconds) } +PLUGIN.RankUps = { + --["guest"] = { "respected", 60*10 }, + --["respected"] = { "admin", 60*60 }, + --["admin"] = { "superadmin", 60*120 }, + --["superadmin"] = { "owner", 60*240 }, + } +--------- EDITABLE AREA + +-- Don't edit below unless you know what you're doing. + +local function formattime( time ) + local days = tonumber(os.date("!%j",time))-1 + return os.date("!"..days.." days, %H:%M:%S",time) +end + +function PLUGIN:Initialize() + if(self.RankUps && table.Count(self.RankUps) == 0) then return end + timer.Create("EV_RankOverTime",1,0,function() + for k,ply in ipairs( player.GetAll() ) do + local BlockRankOverTime = ply:GetProperty("BlockRankOverTime",false) + if (BlockRankOverTime != true) then + local PlayTime = ply:GetProperty( "PlayTime" ) + if (PlayTime) then + local CurPlayTime = math.Round(PlayTime + ply:TimeConnected()) + if (self.RankUps[ply:EV_GetRank()]) then + local NextRankUp = self.RankUps[ply:EV_GetRank()] + if (CurPlayTime and NextRankUp and NextRankUp[2] and CurPlayTime > NextRankUp[2]) then + ply:EV_SetRank(NextRankUp[1]) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has been ranked up to ", evolve.colors.red, NextRankUp[1], evolve.colors.white, " for playing on the server for ", evolve.colors.red, formattime(NextRankUp[2]), evolve.colors.white, "." ) + end + end + end + end + end + end) +end + +function PLUGIN:Call( ply, args ) + + if (args and args[1] and args[1] == "block" and ply:EV_HasPrivilege( "Block ranks over time" )) then + if (args[2]) then + local temp = evolve:FindPlayer(args[2],false) + if (temp and temp[1] and temp[1]:IsPlayer()) then + temp[1]:SetProperty("BlockRankOverTime",true) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has blocked ", evolve.colors.red, temp[1]:Nick(), evolve.colors.white, " from ranking over time." ) + end + end + elseif (args and args[1] and args[1] == "unblock" and ply:EV_HasPrivilege( "Block ranks over time" )) then + if (args[2]) then + local temp = evolve:FindPlayer(args[2],false) + if (temp and temp[1] and temp[1]:IsPlayer()) then + temp[1]:SetProperty("BlockRankOverTime",nil) + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has unblocked ", evolve.colors.red, temp[1]:Nick(), evolve.colors.white, "'s ranking over time." ) + end + end + else + local tply = ply + if (args and #args > 0) then + local temp = evolve:FindPlayer( args[1], false ) + if (temp and temp[1] and temp[1]:IsPlayer()) then + tply = temp[1] + end + end + + local BlockRankOverTime = ply:GetProperty("BlockRankOverTime",false) + if (BlockRankOverTime != true) then + local PlayTime = tply:GetProperty( "PlayTime" ) + if (PlayTime) then + local CurPlayTime = math.Round(PlayTime + tply:TimeConnected()) + if (self.RankUps[tply:EV_GetRank()]) then + local NextRankUp = self.RankUps[tply:EV_GetRank()] + if (CurPlayTime and NextRankUp and NextRankUp[2]) then + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " has played on this server for ",evolve.colors.red, formattime(CurPlayTime), evolve.colors.white, "." ) + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " will rank up in ",evolve.colors.red, formattime(NextRankUp[2]-CurPlayTime), evolve.colors.white, "." ) + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " will become a(n) ",evolve.colors.red, NextRankUp[1], evolve.colors.white, " after the next rankup." ) + else + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " will not rank up. Have they already reached the max rank?" ) + end + else + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " will not rank up. Have they already reached the max rank?" ) + end + end + else + evolve:Notify( ply, evolve.colors.blue, tply:Nick(), evolve.colors.white, " will not rank up because their rank over time has been blocked." ) + end + end +end + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index fa1d213..d02b7d1 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -1,28 +1,100 @@ +--[[ + + Fixed by MadDog + May 2012 +]] + +/*------------------------------------------------------------------------------------------------------------------------- + Restriction +-------------------------------------------------------------------------------------------------------------------------*/ +require ("player_manager") local PLUGIN = {} PLUGIN.Title = "Restriction" PLUGIN.Description = "Restricts weapons." PLUGIN.Author = "Overv" - +ForcePMTest = false +if SERVER then + util.PrecacheModel( "models/player/kleiner.mdl" ) + function PlayerChangeModel( ply ) + timer.Simple(0.1,function() + local tmpname = ply:GetModel() + --print(tmpname) + local playermodels = player_manager.AllValidModels() + local name = "WTFBBQ" + for k,v in pairs(playermodels) do + if (string.lower(v) == string.lower(tmpname)) then + name = k + end + end + --print("Player's new model: "..name) + if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "&" .. name ) and !ply:EV_HasPrivilege( "&" .. name ) and string.lower(name) != "kleiner") or (ForcePMTest and !string.find(name,"kleiner")) then + evolve:Notify( ply, evolve.colors.red, "You can't use this player model!" ) + ply:SetModel("models/player/kleiner.mdl") + ply:ConCommand("cl_playermodel kleiner") + if ply:Alive() then + ply:Kill() + end + return + end + end) + end + hook.Add("PlayerSpawn","EVPMRestrictOnSpawn",PlayerChangeModel) + hook.Add("PlayerSetModel","EVPMRestrict",PlayerChangeModel) +end function PLUGIN:PlayerSpawnSWEP( ply, name, tbl ) - if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "@" .. name ) and !ply:EV_HasPrivilege( "@" .. name ) ) then - evolve:Notify( ply, evolve.colors.red, "You are not allowed to spawn this weapon!" ) - return false + if ( ply.EV_Jailed ) then return false end + local nametest = string.lower(gmod.GetGamemode().Name) + if (nametest!="trouble in terrorist town") then + if (ConVarExists("ev_restrict_weapons")) then + if (GetConVarNumber("ev_restrict_weapons")==0) then + return true + end + end + if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "@" .. name ) and !ply:EV_HasPrivilege( "@" .. name ) ) then + evolve:Notify( ply, evolve.colors.red, "You are not allowed to spawn this weapon!" ) + return false + else + return true + end end end function PLUGIN:PlayerGiveSWEP( ply, name, tbl ) - if ( self:PlayerSpawnSWEP( ply, name, tbl ) == false ) then - return false + if ( ply.EV_Jailed ) then return false end + local nametest = string.lower(gmod.GetGamemode().Name) + if (nametest!="trouble in terrorist town") then + if (ConVarExists("ev_restrict_weapons")) then + if (GetConVarNumber("ev_restrict_weapons")==0) then + return true + end + end + if ( self:PlayerSpawnSWEP( ply, name, tbl ) == false ) then + return false + else + return true + end end end function PLUGIN:PlayerSpawnSENT( ply, class ) - if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, ":" .. class ) and !ply:EV_HasPrivilege( ":" .. class ) ) then - evolve:Notify( ply, evolve.colors.red, "You are not allowed to spawn this entity!" ) - return false + if ( ply.EV_Jailed ) then return false end + local nametest = string.lower(gmod.GetGamemode().Name) + if (nametest!="trouble in terrorist town") then + if (ConVarExists("ev_restrict_entities")) then + if (GetConVarNumber("ev_restrict_entities")==0) then + return true + end + end + if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, ":" .. class ) and !ply:EV_HasPrivilege( ":" .. class ) ) then + evolve:Notify( ply, evolve.colors.red, "You are not allowed to spawn this entity!" ) + return false + else + return true + end end end function PLUGIN:CanTool( ply, tr, class ) + if ( ply.EV_Jailed ) then return false end if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "#" .. class ) and !ply:EV_HasPrivilege( "#" .. class ) ) then evolve:Notify( ply, evolve.colors.red, "You are not allowed to use this tool!" ) return false @@ -35,19 +107,31 @@ function PLUGIN:PlayerSpawn( ply ) end function PLUGIN:PlayerCanPickupWeapon( ply, wep ) - if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "@" .. wep:GetClass() ) and !ply:EV_HasPrivilege( "@" .. wep:GetClass() ) and ( !ply.EV_PickupTimeout or CurTime() < ply.EV_PickupTimeout ) ) then - return false + if ( ply.EV_Jailed ) then return false end + local nametest = string.lower(gmod.GetGamemode().Name) + if (nametest!="trouble in terrorist town") then + if (ConVarExists("ev_restrict_weapons")) then + if (GetConVarNumber("ev_restrict_weapons")==0) then + return true + end + end + if ( GAMEMODE.IsSandboxDerived and table.HasValue( evolve.privileges, "@" .. wep:GetClass() ) and !ply:EV_HasPrivilege( "@" .. wep:GetClass() ) and ( !ply.EV_PickupTimeout or CurTime() < ply.EV_PickupTimeout ) ) then + return false + end end end -function PLUGIN:Initialize() +function PLUGIN:Initialize() + if CLIENT then return end + + evolve:LoadRanks() // Weapons local weps = {} - + for _, wep in pairs( weapons.GetList() ) do table.insert( weps, "@" .. wep.ClassName ) end - + table.Add( weps, { "@weapon_crowbar", "@weapon_pistol", @@ -57,34 +141,37 @@ function PLUGIN:Initialize() "@weapon_crossbow", "@weapon_shotgun", "@weapon_357", - "@weapon_rpg", + "@weapon_Rpg", "@weapon_ar2", - "@weapon_physgun", + "@weapon_physgun", "@weapon_annabelle", "@weapon_slam", "@weapon_stunstick", } ) - + table.Add( evolve.privileges, weps ) - - // Entities + local playermodels = {} + for k,v in pairs(player_manager.AllValidModels()) do + table.insert(playermodels, "&" .. tostring(k)) + end + table.Add( evolve.privileges, playermodels ) + // Entities local entities = {} - + for class, ent in pairs( scripted_ents.GetList() ) do if ( ent.t.Spawnable or ent.t.AdminSpawnable ) then table.insert( entities, ":" .. ( ent.ClassName or class ) ) end end - + table.Add( evolve.privileges, entities ) - + // Tools local tools = {} - + if ( GAMEMODE.IsSandboxDerived ) then - local stools,_ = file.Find( "weapons/gmod_tool/stools/*.lua", "LUA" ) - for _, val in ipairs( stools ) do - local _, __, class = string.find( val, "([%w_]*)%.lua" ) + for _, val in ipairs( file.Find( "weapons/gmod_tool/stools/*.lua", "LUA" ) ) do + local _, __, class = string.find( val, "([%w_]*).lua" ) table.insert( tools, "#" .. class ) end @@ -95,42 +182,43 @@ function PLUGIN:Initialize() table.insert( tools, "#" .. class ) end end - + table.Add( evolve.privileges, tools ) - - // If this is the first time the restriction plugin runs, add all weapon and entity privileges to all ranks so it doesn't break anything - if ( !evolve:GetGlobalVar( "RestrictionSetUp", false ) ) then - for id, rank in pairs( evolve.ranks ) do - if ( id != "owner" ) then - table.Add( rank.Privileges, weps ) + + --this table is kept so when new entities/tools are added they get added to every rank + if ( file.Exists( "evolve/allentitiescache.txt", "DATA" ) ) then + evolve.allentities = evolve.von.deserialize(file.Read( "evolve/allentitiescache.txt", "DATA" )) + else + evolve.allentities = {} + end + + for id, rank in pairs( evolve.ranks ) do + if ( id == "owner" ) then continue; end + + for id,name in pairs(weps) do + if !table.HasValue(evolve.allentities, name) then + table.insert( rank.Privileges, name ) + table.insert( evolve.allentities, name) end end - - evolve:SetGlobalVar( "RestrictionSetUp", true ) - evolve:SaveRanks() - end - - if ( !evolve:GetGlobalVar( "RestrictionSetUpEnts", false ) ) then - for id, rank in pairs( evolve.ranks ) do - if ( id != "owner" ) then - table.Add( rank.Privileges, entities ) + + for id,name in pairs(entities) do + if !table.HasValue(evolve.allentities, name) then + table.insert( rank.Privileges, name ) + table.insert( evolve.allentities, name) end end - - evolve:SetGlobalVar( "RestrictionSetUpEnts", true ) - evolve:SaveRanks() - end - - if ( !evolve:GetGlobalVar( "RestrictionSetUpTools2", false ) ) then - for id, rank in pairs( evolve.ranks ) do - if ( id != "owner" ) then - table.Add( rank.Privileges, tools ) + + for id,name in pairs(tools) do + if !table.HasValue(evolve.allentities, name) then + table.insert( rank.Privileges, name ) + table.insert( evolve.allentities, name) end end - - evolve:SetGlobalVar( "RestrictionSetUpTools2", true ) - evolve:SaveRanks() end -end + file.Write( "evolve/allentitiescache.txt", evolve.von.serialize(evolve.allentities)) + + evolve:SaveRanks() +end evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_sourcebans.lua b/lua/ev_sourcebans.lua index eac8923..e51add3 100644 --- a/lua/ev_sourcebans.lua +++ b/lua/ev_sourcebans.lua @@ -67,7 +67,16 @@ local function syncBans() end ) evolve:CommitProperties() end -timer.Create( "EV_SourceBansSync", 300, 0, syncBans ) -timer.Simple( 1, syncBans ) +--timer.Create( "EV_SourceBansSync", 300, 0, syncBans ) +--timer.Simple( 1, syncBans ) + +hook.add("PlayerInitialSpawn", "evolve_banCheck", function(ply) + local steamId = ply:SteamID() + sourcebans.CheckForBan(steamid, function(result) + if result then + ply:Kick("You are banned from this server.") + end + end) +end) end diff --git a/lua/ev_sv_init.lua b/lua/ev_sv_init.lua index cf0e0e5..aff4f41 100644 --- a/lua/ev_sv_init.lua +++ b/lua/ev_sv_init.lua @@ -6,6 +6,7 @@ print( "\n=====================================================" ) print( " Evolve 1.0 by Overv succesfully started serverside." ) print( "=====================================================\n" ) +evolve:LoadSettings() --@DEV: We have to do this here so that we know how to behave elsewhere. evolve:LoadPlugins() // Tell the clients Evolve is installed on the server