From 4cca4ddbce169bc16032ffaffce78f8186f71887 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:45:44 -0500 Subject: [PATCH 01/52] Player Model Restriction (Framework) Allows for player model restriction, using prefix "&" --- lua/ev_framework.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 0651ee2..7fa4b84 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -894,6 +894,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 @@ -907,6 +909,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 From 908a9ddc64177109f5242ba75685ffded1ebb88c Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:47:20 -0500 Subject: [PATCH 02/52] Playermodel Restriction (Ranks Tab) The actual tab. Requires built in player manager. Allows you to modify permissions for playermodels. --- lua/ev_menu/tab_ranks.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) 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 From 4860355a59f6a3e874d37e62574ff4bba3b2add0 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:49:14 -0500 Subject: [PATCH 03/52] Restriction Fixes + Playermodel Restriciton Fixes issues, allows for TTT compatibility, and adds playermodel restriction. --- lua/ev_plugins/sv_restriction.lua | 203 +++++++++++++++++++++--------- 1 file changed, 147 insertions(+), 56 deletions(-) diff --git a/lua/ev_plugins/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index 91b4d30..92281a6 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -1,28 +1,101 @@ +--[[ + + Fixed by MadDog + May 2012 +]] + +/*------------------------------------------------------------------------------------------------------------------------- + Restriction +-------------------------------------------------------------------------------------------------------------------------*/ +require ("von") +require ("player_manager") local PLUGIN = {} PLUGIN.Title = "Restriction" PLUGIN.Description = "Restricts weapons." -PLUGIN.Author = "Overv" - +PLUGIN.Author = "[DARK]Grey and 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 +108,33 @@ 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 + else + return true + 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,73 +144,77 @@ 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 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( "ev_allentitiescache.txt", "DATA" ) ) then + evolve.allentities = von.deserialize(file.Read( "ev_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( "ev_allentitiescache.txt", von.serialize(evolve.allentities)) + + evolve:SaveRanks() +end evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file From 63ad283ae08fe727148ae3b99c9f1d0ec608bcda Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:51:54 -0500 Subject: [PATCH 04/52] God Changes Reverts god. See !sgod / "Self God" --- lua/ev_plugins/sh_godmode.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 From 4014575dc44d90422e9830e961028e50430531b8 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:53:05 -0500 Subject: [PATCH 05/52] Self God / !sgod Replacement for the new version of godmode. Makes it so that users can only god themselves when using !sgod, and then you can give higher ranks the normal god. --- lua/ev_plugins/sh_god_limited.lua | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lua/ev_plugins/sh_god_limited.lua 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 From 97ead2085f5015bc8acd64854878347c3c6684a7 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:54:00 -0500 Subject: [PATCH 06/52] TTT Functions See title. --- lua/ev_plugins/sh_detective.lua | 32 ++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_innocent.lua | 32 ++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_traitor.lua | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 lua/ev_plugins/sh_detective.lua create mode 100644 lua/ev_plugins/sh_innocent.lua create mode 100644 lua/ev_plugins/sh_traitor.lua 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_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_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 From e76f678d1bc0a7bc5b722b03693ba5cb122ae16f Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:57:18 -0500 Subject: [PATCH 07/52] Respawn fixes + TTT support Allows respawning players in TTT, plus some fixes. --- lua/ev_plugins/sh_respawn.lua | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 4635d4f47cfc4daff52e698bab867e019170aa65 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:58:16 -0500 Subject: [PATCH 08/52] TPA / Voluntary Teleport You want this. It's amazingly useful so that you don't have to continually teleport users. --- lua/ev_plugins/sh_tpa.lua | 37 +++++++++++++ lua/ev_plugins/sh_tpaccept.lua | 94 ++++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_tpdeny.lua | 81 +++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 lua/ev_plugins/sh_tpa.lua create mode 100644 lua/ev_plugins/sh_tpaccept.lua create mode 100644 lua/ev_plugins/sh_tpdeny.lua 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 From 8c147f94fadf404f9cbe7d58fb6010f97aa33863 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 15:59:33 -0500 Subject: [PATCH 09/52] Expirimental Prop Protection May have a few bugs, but works well for the most part. Includes !friends to let users share props, and convars to configure. --- lua/ev_plugins/sh_propprotection.lua | 450 +++++++++++++++++++++++++++ 1 file changed, 450 insertions(+) create mode 100644 lua/ev_plugins/sh_propprotection.lua diff --git a/lua/ev_plugins/sh_propprotection.lua b/lua/ev_plugins/sh_propprotection.lua new file mode 100644 index 0000000..a8b9713 --- /dev/null +++ b/lua/ev_plugins/sh_propprotection.lua @@ -0,0 +1,450 @@ +local PLUGIN = {} +PLUGIN.Title = "Prop Protection"; +PLUGIN.Description = "A Plugin to prevent minges from spawning blacklisted props and touching others props"; +PLUGIN.Author = "[DARK]Grey and Northdegree"; +PLUGIN.Privileges = { "Can Spawn Blacklist", "Manage BlackList", "Can Touch WorldProps"}; +PLUGIN.ChatCommand = "friends" +PLUGIN.Usage = " (Name/SteamID)" +PP_Settings = {}; +PP_Blacklist = {}; + + +/*================ Add/Remove Func ==========================*/ +/*----------------------------------------------------- + -- FRIENDS -- + ---------------------------------------------------*/ +function PLUGIN:Call( ply, args ) + local action = args[1] + if action == "add" then + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findply = evolve:FindPlayer( args[2] ) + if ( #findply > 1 ) then + evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) + return + end + if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end + findply = findply[1] + if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You cant add yourself as your friend!\", NOTIFY_ERROR, 5)") return end + local findsteam = findply:SteamID() + local findname = findply:Nick() + if CheckFriendship(ply, findply) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is already in your Friendlist!\", NOTIFY_ERROR, 5)") return end + table.insert(ply.PP_Friends, {findsteam, findname}) + sql.Query("INSERT INTO `ev_pp_friends` (ply,friendid,friendname) VALUES ("..sql.SQLStr(ply:SteamID())..","..sql.SQLStr(findsteam)..","..sql.SQLStr(findname)..");") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been added to your Friendlist!\", NOTIFY_GENERIC, 5)") + findply:SendLua("GAMEMODE:AddNotify(\"You now can touch "..ply:Nick().."'s Props!\", NOTIFY_GENERIC, 5)") + elseif action == "remove" then + if string.match( args[2],"STEAM_[0-5]:[0-9]:[0-9]+") then + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findsteam = args[2] + if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\"This Player is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end + local findname = "" + for k,v in pairs(ply.PP_Friends) do + if v[1] == findsteam then + findname = v[2] + table.remove(ply.PP_Friends, k) + end + end + sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") + else + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findply = evolve:FindPlayer( args[2] ) + if ( #findply > 1 ) then + evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) + return + end + if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end + findply = findply[1] + if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You are not your own friend!\", NOTIFY_ERROR, 5)") return end + local findsteam = findply:SteamID() + local findname = findply:Nick() + if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end + for k,v in pairs(ply.PP_Friends) do + if v[1] == findsteam then + table.remove(ply.PP_Friends, k) + end + end + sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") + findply:SendLua("GAMEMODE:AddNotify(\"You can't touch "..ply:Nick().."'s Props anymore!\", NOTIFY_GENERIC, 5)") + end + else + if not ply.PP_Friends then ply.PP_Friends = {} end + evolve:Notify(ply, evolve.colors.blue, ply:Nick().."'s friendlist :") + for index,frply in pairs(ply.PP_Friends) do + evolve:Notify(ply, evolve.colors.blue, frply[2], evolve.colors.white, " ("..frply[1]..")") + end + evolve:Notify(ply, evolve.colors.blue, "-------------------------") + end +end + + + ---------------------------------------------------*/ +local function savePPSettings(ply, cmd, args) + for sname,setting in pairs(PP_Settings) do + if (ConVarExists("ev_"..sname)) then + sql.Query("UPDATE `ev_pp_settings` SET `"..sname.."`='"..GetConVar("ev_"..sname):GetString().."';") + end + end +end +concommand.Add("ev_pp_save_settings", savePPSettings) +timer.Create("PP Autosave",60,0,savePPSettings) +/*----------------------------------------------------- + -- Blacklist -- + ---------------------------------------------------*/ +local function PP_AddBlackList(ply, cmd, args) + if !ply:EV_HasPrivilege( "Manage BlackList" ) then ply:SendLua("GAMEMODE:AddNotify(\"You are not allowed to do that!\", NOTIFY_ERROR, 5)") return end + if not args[1] then ply:SendLua("GAMEMODE:AddNotify(\"Invalid Argument(s)\", NOTIFY_ERROR, 3)") return end + local model = string.lower(args[1]) + model = string.Replace(model, "\\", "/") + if table.HasValue(PP_Blacklist,model) then ply:SendLua("GAMEMODE:AddNotify(\"This Model is already Black-/Whitelisted!\", NOTIFY_ERROR, 5)") return end + table.insert(PP_Blacklist, model) + sql.Query("INSERT INTO `ev_pp_blacklist` (model) VALUES ("..sql.SQLStr(model)..");") + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has added the Model ", evolve.colors.red, model, evolve.colors.white, " to the Black-/Whitelist." ) +end +concommand.Add("ev_pp_add_blacklist", PP_AddBlackList) + +local function PP_RemoveBlackList(ply, cmd, args) + if !ply:EV_HasPrivilege( "Manage BlackList" ) then ply:SendLua("GAMEMODE:AddNotify(\"You are not allowed to do that!\", NOTIFY_ERROR, 5)") return end + if not args[1] then ply:SendLua("GAMEMODE:AddNotify(\"Invalid Argument(s)\", NOTIFY_ERROR, 3)") return end + local model = string.lower(args[1]) + model = string.Replace(model, "\\", "/") + if !table.HasValue(PP_Blacklist,model) then ply:SendLua("GAMEMODE:AddNotify(\"This Model is not Black-/Whitelisted!\", NOTIFY_ERROR, 5)") return end + for k,v in pairs(PP_Blacklist) do + if v == model then + table.remove(PP_Blacklist, k) + end + end + sql.Query("DELETE FROM `ev_pp_blacklist` WHERE `model`="..sql.SQLStr(model)..";") + evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has removed the Model ", evolve.colors.red, model, evolve.colors.white, " from the Black-/Whitelist." ) +end +concommand.Add("ev_pp_Remove_blacklist", PP_RemoveBlackList) + +local function PP_GetBlackList(ply, cmd, args) + for k,model in pairs(PP_Blacklist) do + umsg.Start("ev_pp_blockedmodel", ply) + umsg.String(model) + umsg.End() + end +end +concommand.Add("ev_pp_get_blacklist", PP_GetBlackList) +/*================ Blacklist ==========================*/ + +function loadPPBlacklist() + sql.Query("SELECT * FROM `ev_pp_blacklist`", function(results) + if results then + for k,v in pairs(results) do + table.insert(PP_Blacklist, v.model) + end + end + end) +end +/*====================================================*/ +function CheckFriendship(ply,targetid) + if not ply.PP_Friends then ply.PP_Friends = {} end + local friends = false + for k,v in pairs(ply.PP_Friends) do + if v[1] == targetid then + friends = true + break + end + end + return friends +end +function loadPPFriends(ply) + local plysteamid = ply:SteamID() + sql.Query("SELECT * FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(plysteamid).."", function(results) + if results then + for k,v in pairs(results) do + local friendid = v.friendid + local friendname = v.friendname + table.insert(ply.PP_Friends, {friendid, friendname}) + end + end + end) +end + +/*================ SETTINGS ==========================*/ +function loadPPSettings() + local results=sql.Query("SELECT * FROM `ev_pp_settings`") + if results then + for k,v in pairs(results[1]) do + PP_Settings[k]=v + if v then + CreateConVar("ev_"..k,tonumber(v)) + end + end + else + sql.Query("INSERT INTO `ev_pp_settings` (ppison) VALUES ('1');"); // Creating default settings + sql.Query("INSERT INTO `ev_pp_settings` (blacklistison) VALUES ('0');"); // Creating default settings + sql.Query("INSERT INTO `ev_pp_settings` (blacklistiswhitelist) VALUES ('0');"); // Creating default settings + loadPPSettings(); + end +end +/*====================================================*/ +function FirstSpawn( ply ) + ply.PP_Friends = {} + loadPPFriends(ply) +end +hook.Add( "PlayerInitialSpawn", "PP_Friends_Load_On_Connect", FirstSpawn ) + +function PLUGIN:Initialize() + if SERVER then + /* CREATING ALL TABLES */ + if (!sql.TableExists("ev_pp_settings")) then + sql.Query("CREATE TABLE `ev_pp_settings` (`ppison` INT DEFAULT '1',`blacklistison` INT DEFAULT '1',`blackiswhitelist` INT DEFAULT '0',`highercantouchlowerrank` INT DEFAULT '1');") + end + if (!sql.TableExists("ev_pp_blacklist")) then + sql.Query("CREATE TABLE `ev_pp_blacklist` (`model` varchar(999));") + end + if (!sql.TableExists("ev_pp_friends")) then + sql.Query("CREATE TABLE `ev_pp_friends` (`ply` varchar(999),`friendid` varchar(999),`friendname` varchar(999));") + end + loadPPSettings(); + loadPPBlacklist(); + if FPP then + RunConsoleCommand("ev_ppison","0") + end + end +end +function CustInit() + if SERVER then + /* CREATING ALL TABLES */ + if (!sql.TableExists("ev_pp_settings")) then + sql.Query("CREATE TABLE `ev_pp_settings` (`ppison` INT DEFAULT '1',`blacklistison` INT DEFAULT '1',`blackiswhitelist` INT DEFAULT '0',`highercantouchlowerrank` INT DEFAULT '1');") + end + if (!sql.TableExists("ev_pp_blacklist")) then + sql.Query("CREATE TABLE `ev_pp_blacklist` (`model` varchar(999));") + end + if (!sql.TableExists("ev_pp_friends")) then + sql.Query("CREATE TABLE `ev_pp_friends` (`ply` varchar(999),`friendid` varchar(999),`friendname` varchar(999));") + end + loadPPSettings(); + loadPPBlacklist(); + if FPP then + RunConsoleCommand("ev_ppison","0") + end + end +end + +//======================== DONT EDIT SOMETHING BELOW THIS UNLESS YOU KNOW WHAT YOU DO!!! ========================================= +if SERVER then + hook.Add("PlayerSpawnProp", "PP_BLACKLIST_CHECK", function(ply, model) + /* -------------- BLACKLIST -------------- */ + if GetConVar("ev_blacklistison"):GetInt() == 1 then + if table.HasValue(PP_Blacklist,string.lower(model)) then + if GetConVar("ev_blackiswhitelist"):GetInt() == 0 then + if !ply:EV_HasPrivilege( "Can Spawn Blacklist" ) then + ply:SendLua("GAMEMODE:AddNotify(\"This Model is Blacklisted!\", NOTIFY_ERROR, 3)") + return false + else + return true + end + end + else + if GetConVar("ev_blackiswhitelist"):GetInt() == 1 then + if !ply:EV_HasPrivilege( "Can Spawn Blacklist" ) then + ply:SendLua("GAMEMODE:AddNotify(\"This Model is Blacklisted!\", NOTIFY_ERROR, 3)") + return false + else + return true + end + end + end + else + return true + end + end) + /* Physgun Pickup Control*/ + function PlayerPickup(ply, ent) + local owner = ent:GetNWEntity("Owner") + local steamid = ent:GetNWString("OwnerID") + local plysteam = ply:SteamID() + if !ent:IsPlayer() then + if (GetConVar("ev_ppison"):GetInt() == 0) or (IsValid(owner) and CheckFriendship(owner,plysteam)) or (steamid == "" and ply:EV_HasPrivilege("Can Touch WorldProps")) or CanTouch(ply, ent) then + if ply:EV_HasPrivilege("Can Touch WorldProps") and (steamid=="") then + return true + elseif (steamid!="") then + return true + else + return false + end + else + return false + end + end + end + hook.Add("PhysgunPickup", "PP_Physgun_Pickup", PlayerPickup) + function CusCanTool( ply, tr, 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 use this tool!" ) + return false + end + return true + end + + function UseTool(ply, trace, toolmode) + local ent = trace.Entity + local owner = ent:GetNWEntity("Owner") + local steamid = ent:GetNWString("OwnerID") + local plysteam = ply:SteamID() + if CusCanTool( ply, trace, toolmode) then + if (GetConVar("ev_ppison"):GetInt() == 0) or (IsValid(owner) and CheckFriendship(owner,plysteam)) or (!IsValid(owner) and steamid == "" and ply:EV_HasPrivilege("Can Touch WorldProps")) or CanTouch(ply, ent) or !IsValid(ent) then + return true + else + return false + end + else + if (ConVarExists("ev_restrict_tools")) then + if (GetConVarNumber("ev_restrict_tools")==0) then + return true + else + return false + end + else + return false + end + end + end + hook.Add("CanTool", "PP_ToolGun_Use", UseTool) +end +if cleanup then + oldcleanup = oldcleanup or cleanup.Add + function cleanup.Add(ply, Type, ent) + if IsValid(ply) and IsValid(ent) then + ent:SetNWEntity("Owner", ply) + ent:SetNWString("OwnerID", ply:SteamID()) + if ent:GetClass() == "gmod_wire_expression2" then + ent:SetCollisionGroup(COLLISION_GROUP_WEAPON) + end + end + return oldcleanup(ply, Type, ent) + end +end + + +function CanTouch(ply, ent) + local owner = ent:GetNWEntity("Owner") + if (ent:GetNWString("OwnerID") == ply:SteamID()) then + return true + else + if (SERVER and IsValid(owner) and ply:EV_BetterThan(owner) and GetConVar("ev_highercantouchlowerrank"):GetInt() == 1) then + return true + else + if !IsValid(owner) then + return true + else + return false + end + end + end +end +/* Show the Owner */ +if CLIENT then + local function HUDPaint() + local LookingEnt = LocalPlayer():GetEyeTraceNoCursor().Entity + local LEOwner = LookingEnt:GetNWString("OwnerID") + if LEOwner == "" then LEOwner = "World Prop" end + if IsValid(LookingEnt) and !LookingEnt:IsPlayer() then + local owner = LEOwner + if LEOwner != "World Prop" then + LEOwner = LookingEnt:GetNWEntity("Owner") + local k,v = pcall(function() + if !IsValid(LEOwner) then owner="Disconnected Player" else owner=LEOwner:Nick() end + end) + if !k then owner="Invalid Player" end + end + surface.SetFont("Default") + local w,h = surface.GetTextSize(owner) + local col = Color(255,0,0,255) + pcall( + function() + if CanTouch(LocalPlayer(),LookingEnt) then + col = Color(0,255,0,255) + else + col = Color(255,0,0,255) + end + end + ) + draw.RoundedBox(4, 5, ScrH()/2 - h - 2, w + 10, 20, Color(0, 0, 0, 110)) + draw.DrawText(owner, "Default", 7, ScrH()/2 - h, col, 0) + surface.SetDrawColor(255,255,255,255) + end + end + hook.Add("HUDPaint", "PP_Show_Owner", HUDPaint) +end +/*---------------Console Command*/ +function evPropParseCommand( ply, comm, args ) + local action = args[1] + if action == "add" then + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findply = evolve:FindPlayer( args[2] ) + if ( #findply > 1 ) then + evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) + return + end + if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end + findply = findply[1] + if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You cant add yourself as your friend!\", NOTIFY_ERROR, 5)") return end + local findsteam = findply:SteamID() + local findname = findply:Nick() + if CheckFriendship(ply, findply) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is already in your Friendlist!\", NOTIFY_ERROR, 5)") return end + table.insert(ply.PP_Friends, {findsteam, findname}) + sql.Query("INSERT INTO `ev_pp_friends` (ply,friendid,friendname) VALUES ("..sql.SQLStr(ply:SteamID())..","..sql.SQLStr(findsteam)..","..sql.SQLStr(findname)..");") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been added to your Friendlist!\", NOTIFY_GENERIC, 5)") + findply:SendLua("GAMEMODE:AddNotify(\"You now can touch "..ply:Nick().."'s Props!\", NOTIFY_GENERIC, 5)") + elseif action == "remove" then + if string.match( args[2],"STEAM_[0-5]:[0-9]:[0-9]+") then + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findsteam = args[2] + if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\"This Player is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end + local findname = "" + for k,v in pairs(ply.PP_Friends) do + if v[1] == findsteam then + findname = v[2] + table.remove(ply.PP_Friends, k) + end + end + sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") + else + if not ply.PP_Friends then ply.PP_Friends = {} end + if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end + local findply = evolve:FindPlayer( args[2] ) + if ( #findply > 1 ) then + evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) + return + end + if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end + findply = findply[1] + if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You are not your own friend!\", NOTIFY_ERROR, 5)") return end + local findsteam = findply:SteamID() + local findname = findply:Nick() + if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end + for k,v in pairs(ply.PP_Friends) do + if v[1] == findsteam then + table.remove(ply.PP_Friends, k) + end + end + sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") + ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") + findply:SendLua("GAMEMODE:AddNotify(\"You can't touch "..ply:Nick().."'s Props anymore!\", NOTIFY_GENERIC, 5)") + end + else + if not ply.PP_Friends then ply.PP_Friends = {} end + evolve:Notify(ply, evolve.colors.blue, ply:Nick().."'s friendlist :") + for index,frply in pairs(ply.PP_Friends) do + evolve:Notify(ply, evolve.colors.blue, frply[2], evolve.colors.white, " ("..frply[1]..")") + end + evolve:Notify(ply, evolve.colors.blue, "-------------------------") + end +end + +concommand.Add("EvPropParseCon",evPropParseCommand) +CustInit() +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file From 3cbf81df4955dd085f18905ca35379e6b9779c56 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:00:34 -0500 Subject: [PATCH 10/52] Respawn Control Another way to control players / punish them. If you !nospawn a player, they'll be slain on spawn. --- lua/ev_plugins/sh_permadeath.lua | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lua/ev_plugins/sh_permadeath.lua 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 From cda135c5f60d0e39d75f12c1b412aab117ab18d2 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:01:50 -0500 Subject: [PATCH 11/52] Observation Mode So you can spy on those darn guests! --- lua/ev_plugins/sh_observation.lua | 120 ++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 lua/ev_plugins/sh_observation.lua 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 From 5bdd2b0be0066af65dac6a363c6777a6e4e22ac9 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:09:47 -0500 Subject: [PATCH 12/52] Map tab + Advert3 Includes !votemap too --- lua/ev_menu/tab_adverts3.lua | 208 +++++++++++++++++++++++++++++++++ lua/ev_menu/tab_maps.lua | 94 +++++++++++++++ lua/ev_plugins/sh_mapslist.lua | 76 ++++++++++++ lua/ev_plugins/sh_veto.lua | 23 ++++ lua/ev_plugins/sh_votemap.lua | 122 +++++++++++++++++++ 5 files changed, 523 insertions(+) create mode 100644 lua/ev_menu/tab_adverts3.lua create mode 100644 lua/ev_menu/tab_maps.lua create mode 100644 lua/ev_plugins/sh_mapslist.lua create mode 100644 lua/ev_plugins/sh_veto.lua create mode 100644 lua/ev_plugins/sh_votemap.lua diff --git a/lua/ev_menu/tab_adverts3.lua b/lua/ev_menu/tab_adverts3.lua new file mode 100644 index 0000000..b77e892 --- /dev/null +++ b/lua/ev_menu/tab_adverts3.lua @@ -0,0 +1,208 @@ +/* +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 = "gui/silkicons/page_white_wrench" +TAB.Author = "SariaFace" +TAB.Width = 520 +TAB.Privileges = { "Advert 3 Menu" } + +if (SERVER) then + function SendAdvertsList(target, cmd, args) + if (target) then + if (adverts and #adverts.Stored) then + datastream.StreamToClients(target, "EV_Adverts3_ReceiveList", adverts.Stored) + end + end + end + concommand.Add("EV_Adverts3_RequestList", SendAdvertsList) +else + local NewAdPanelReg = {} + function NewAdPanelReg:Init() + self:SetPos( 40, (ScrH()/3)*2) + self:SetSize(560, 62) + self:SetTitle("Add new advert") + self:MakePopup() + self:SetZPos(999999) + + 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.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())) then + evolve:Notify(LocalPlayer(), evolve.colors.red, "Incorrect Time input!") + self:Remove() + 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 = true + RunConsoleCommand("ev", "advert3", "add", self.IDInput:GetValue(), newAd.Colour["r"], newAd.Colour["g"], newAd.Colour["b"], tostring(newAd.Time), newAd.Msg) + adverts[self.IDInput:GetValue()] = newAd + timer.Simple(1.0, function() TAB:Update() end) + self:Remove() + end + + end + vgui.Register("NewAdPanel", NewAdPanelReg, "DFrame") + + adverts = {} + function SyncAdverts(hdl, id, enc, dec) + adverts = dec + end + datastream.Hook("EV_Adverts3_ReceiveList", SyncAdverts) + RunConsoleCommand("EV_Adverts3_RequestList") +end +--===================================================================================-- +function TAB:Initialize( pnl ) + 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( 308 ) + self.AdList:AddColumn( "Active" ):SetFixedWidth( 32 ) + + self.New = vgui.Create( "DButton", pnl ) + self.New:SetSize( 60, 22 ) + self.New:SetPos( self.Width - 275, pnl:GetParent():GetTall() - 53 ) + self.New:SetText( "ReSync" ) + self.New.DoClick = function() + self:Request() + end + + self.New = vgui.Create( "DButton", pnl ) + self.New:SetSize( 60, 22 ) + self.New:SetPos( self.Width - 210, pnl:GetParent():GetTall() - 53 ) + self.New:SetText( "New" ) + self.New.DoClick = function() + local newAdInput = vgui.Create("NewAdPanel") + end + + self.Tog = vgui.Create( "DButton", pnl ) + self.Tog:SetSize( 60, 22 ) + self.Tog:SetPos( self.Width - 145, pnl:GetParent():GetTall() - 53 ) + self.Tog:SetText( "Toggle" ) + self.Tog.DoClick = function() + 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"]) + end + + self.Rem = vgui.Create( "DButton", pnl ) + self.Rem:SetSize( 60, 22 ) + self.Rem:SetPos( self.Width - 80, pnl:GetParent():GetTall() - 53 ) + self.Rem:SetText( "Remove" ) + self.Rem.DoClick = function() + local id = self.AdList:GetSelected()[1]:GetValue(1) + RunConsoleCommand("ev", "advert3", "remove", id) + adverts[id] = nil + self:Update() + end + timer.Simple(1.5, function() TAB:Update() end) +end + +function TAB:Update() + 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, data.OnState); + end + self.AdList:SelectFirstItem() +end + +function TAB:Request() + RunConsoleCommand("EV_Adverts3_RequestList") + timer.Simple(2, function() TAB:Update() end) +end + +function TAB:IsAllowed() + return LocalPlayer():EV_HasPrivilege( "Advert 3 Menu" ) +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..9e07182 --- /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 = "world" + +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_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_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 From dcfdacb82b4ff09c92f7c0678601f1eac20c0c72 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:10:15 -0500 Subject: [PATCH 13/52] Twerk Fun punishment --- lua/ev_plugins/sh_twerkparty.lua | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lua/ev_plugins/sh_twerkparty.lua 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 From 00a7185b1d9eadb4a54b3bcb5f74ad0126d6190c Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:12:27 -0500 Subject: [PATCH 14/52] Admin Cheats ESP + No Recoil. --- lua/ev_plugins/sh_esp.lua | 140 +++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_norecoil.lua | 54 +++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 lua/ev_plugins/sh_esp.lua create mode 100644 lua/ev_plugins/sh_norecoil.lua 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_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 From fb50612ba0f4c318a659f5a30787222e96fdda97 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:12:43 -0500 Subject: [PATCH 15/52] Set Spawnpoint Needs work, but fully functional and easy to use already. --- lua/ev_plugins/sh_spawnpoint.lua | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lua/ev_plugins/sh_spawnpoint.lua 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 From 305770fdaedf48d08aa8718f28485355c5dd7f9e Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:13:40 -0500 Subject: [PATCH 16/52] Advert 3 Fix Since I forgot to include the plugin in the map tab commit. --- lua/ev_plugins/sh_advert3.lua | 122 ++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 lua/ev_plugins/sh_advert3.lua diff --git a/lua/ev_plugins/sh_advert3.lua b/lua/ev_plugins/sh_advert3.lua new file mode 100644 index 0000000..ea70517 --- /dev/null +++ b/lua/ev_plugins/sh_advert3.lua @@ -0,0 +1,122 @@ +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][message]" +PLUGIN.Privileges = { "Advert 3" } + +if (SERVER) then + local adFileName= "ev_adverts.txt" + local function writeToFile(data) + file.Write(adFileName, von.serialize(data)) + end + + adverts = {} + adverts.Stored = {} + if (#file.Find(adFileName,"DATA") > 0) then + adverts.Stored = 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) + 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 > 6 then + info[6] = table.concat(info, " ", 6, #info) + elseif #info < 6 then + return "Advert: Incorrect arguements for Add" + end + local ow + if adverts.Stored[info[1]] then + ow = "Overwriting advert \""..adverts.Stored[info[1]].."\"." + end + + adverts.Stored[info[1]] = { + ["Colour"] = Color(tonumber(info[2]),tonumber(info[3]),tonumber(info[4])), + ["Time"] = info[5], + ["Msg"] = info[6], + ["OnState"] = true + } + 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 + 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 From a62b9b91a14e01e93c200c8b17b716f9b6747275 Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 16:31:47 -0500 Subject: [PATCH 17/52] Error fix Includes a bunch of different files. Most aren't even changed, it's just to placate GIT. Includes: AI Disable Drug Earbleed Gravity Control Monitor throwing Mapcycle control DarkRP money Nolag (broken, supposed to freeze all props) Permamute Player resize Spawn protection Thirdperson (expirimental / buggy) --- lua/ev_plugins/sh_aidisable.lua | 27 ++ lua/ev_plugins/sh_drug.lua | 53 +++ lua/ev_plugins/sh_earbleed.lua | 49 +++ lua/ev_plugins/sh_grav.lua | 27 ++ lua/ev_plugins/sh_hax.lua | 54 +++ lua/ev_plugins/sh_mapcycle.lua | 477 ++++++++++++++++++++++++++ lua/ev_plugins/sh_money.lua | 45 +++ lua/ev_plugins/sh_motd.lua | 231 ++++++++----- lua/ev_plugins/sh_nolag.lua | 33 ++ lua/ev_plugins/sh_permamute.lua | 57 +++ lua/ev_plugins/sh_playernames.lua | 94 ++--- lua/ev_plugins/sh_propprotection.lua | 2 +- lua/ev_plugins/sh_size.lua | 81 +++++ lua/ev_plugins/sh_spawnprotection.lua | 80 +++++ lua/ev_plugins/sh_thirdperson.lua | 126 +++++++ lua/ev_plugins/sv_restriction.lua | 2 +- 16 files changed, 1313 insertions(+), 125 deletions(-) create mode 100644 lua/ev_plugins/sh_aidisable.lua create mode 100644 lua/ev_plugins/sh_drug.lua create mode 100644 lua/ev_plugins/sh_earbleed.lua create mode 100644 lua/ev_plugins/sh_grav.lua create mode 100644 lua/ev_plugins/sh_hax.lua create mode 100644 lua/ev_plugins/sh_mapcycle.lua create mode 100644 lua/ev_plugins/sh_money.lua create mode 100644 lua/ev_plugins/sh_nolag.lua create mode 100644 lua/ev_plugins/sh_permamute.lua create mode 100644 lua/ev_plugins/sh_size.lua create mode 100644 lua/ev_plugins/sh_spawnprotection.lua create mode 100644 lua/ev_plugins/sh_thirdperson.lua 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_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_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_mapcycle.lua b/lua/ev_plugins/sh_mapcycle.lua new file mode 100644 index 0000000..d560256 --- /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/ev_mapcycle.txt", 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/ev_mapcycle.txt", "DATA")) then + local data = file.Read( "evolve/ev_mapcycle.txt", "DATA" ) + if (data and data != "") then + data = 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_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..f4a474c 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 ev_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/ev_motd.txt", "DATA")) then + timer.Create("MOTD2TimerFor"..ply:Nick(),3,3,function() + net.Start( "MOTD2Packet" ) + local tmpstr = file.Read("evolve_motd/ev_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: ev_motd.txt in data/evolve_motd/! \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/ev_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: ev_motd.txt in data/evolve_motd/! \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_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_propprotection.lua b/lua/ev_plugins/sh_propprotection.lua index a8b9713..593cfcf 100644 --- a/lua/ev_plugins/sh_propprotection.lua +++ b/lua/ev_plugins/sh_propprotection.lua @@ -1,7 +1,7 @@ local PLUGIN = {} PLUGIN.Title = "Prop Protection"; PLUGIN.Description = "A Plugin to prevent minges from spawning blacklisted props and touching others props"; -PLUGIN.Author = "[DARK]Grey and Northdegree"; +PLUGIN.Author = "Northdegree"; PLUGIN.Privileges = { "Can Spawn Blacklist", "Manage BlackList", "Can Touch WorldProps"}; PLUGIN.ChatCommand = "friends" PLUGIN.Usage = " (Name/SteamID)" 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_spawnprotection.lua b/lua/ev_plugins/sh_spawnprotection.lua new file mode 100644 index 0000000..54c280d --- /dev/null +++ b/lua/ev_plugins/sh_spawnprotection.lua @@ -0,0 +1,80 @@ +/*------------------------------------------------------------------------------------------------------------------------- + NoRecoil a player +-------------------------------------------------------------------------------------------------------------------------*/ + +local PLUGIN = {} +PLUGIN.Title = "Spawn Protection" +PLUGIN.Description = "Players with this permission have spawn protection." +PLUGIN.Author = "Grey" +PLUGIN.Usage = "none" +PLUGIN.Privileges = { "Spawn Protection" } +if SERVER then + local weps = {} + + local function Think() + for k,v in pairs(player.GetAll()) do + if weps[v] then + if v:GetActiveWeapon() && v:GetActiveWeapon():IsValid() && v:GetActiveWeapon() != weps[v] then + hook.Call("PlayerWeaponChanged", gmod.GetGamemode(), v, weps[v], v:GetActiveWeapon()) -- Params: Player (who changed the weapon), Weapon (weapon switch from), Weapon(weapon switched to) + weps[v] = v:GetActiveWeapon() + end + else + if v:GetActiveWeapon() && v:GetActiveWeapon():IsValid() then + weps[v] = v:GetActiveWeapon() + end + end + end + end + hook.Add("Think", "WeaponCheck.Think", Think) + function SPOnWeaponEquip( ply, oldwep, eqwep ) + if (!eqwep:IsWeapon()) then + return; + end + local wepname = string.lower(eqwep:GetClass()) + local hassp = ply:GetNWBool( "EV_SpawnProtected", false) + if (string.match(wepname,"weapon_physgun") or string.match(wepname,"gmod_tool") or string.match(wepname,"gmod_camera") or string.match(wepname,"toolgun") or string.match(wepname,"tool gun") or string.match(wepname,"physgun") or string.match(wepname,"physicsgun") or string.match(wepname,"physcannon") or string.match(wepname,"physicscannon")or string.match(wepname,"phys gun") or string.match(wepname,"physics gun")or string.match(wepname,"phys cannon") or string.match(wepname,"physics cannon")or string.match(wepname,"camera")) then + ply:SetNWBool( "EV_SpawnProtected", hassp ) + else + ply:SetNWBool( "EV_SpawnProtected", false ) + if (hassp == true) then + hassp = false + print("Spawn protection ended for "..ply:Nick()..".") + end + end + end + function SPOnSpawn( ply ) + if ( ply:EV_HasPrivilege( "Spawn Protection" ) ) then + ply:SetNWBool( "EV_SpawnProtected", true ) + timer.Simple(15, function() + if ply and ply:IsPlayer() then + local hassp = ply:GetNWBool( "EV_SpawnProtected", false) + if (hassp == true) then + ply:SetNWBool( "EV_SpawnProtected", false ) + print("Spawn protection ended for "..ply:Nick()..".") + end + end + end) + evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white," or until you draw a weapon." ) + else + ply:SetNWBool( "EV_SpawnProtected", false ) + end + end + function SPShouldTakeDamage( ply, attacker) + if (ply:GetNWBool( "EV_SpawnProtected", false) == true) then + if attacker:IsPlayer() then + evolve:Notify( evolve.colors.red, attacker:Nick(), evolve.colors.white, " has attempted to spawnkill!" ) + local atwep = attacker:GetActiveWeapon() + if atwep:IsWeapon() then + local ammotype=atwep:GetPrimaryAmmoType( ) + attacker:RemoveAmmo(attacker:GetAmmoCount(ammotype),ammotype) + attacker:DropWeapon(atwep) + end + return false; + end + end + end + hook.Add("PlayerWeaponChanged","EVSpawnProtect_OnWeaponDraw",SPOnWeaponEquip) + hook.Add("PlayerSpawn","EVSpawnProtect_OnPlayerSpawn",SPOnSpawn) + hook.Add("PlayerShouldTakeDamage","EVSpawnProtect_OnPlayerDamage",SPShouldTakeDamage) +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/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index 92281a6..aa003b9 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -12,7 +12,7 @@ require ("player_manager") local PLUGIN = {} PLUGIN.Title = "Restriction" PLUGIN.Description = "Restricts weapons." -PLUGIN.Author = "[DARK]Grey and Overv" +PLUGIN.Author = "Overv" ForcePMTest = false if SERVER then util.PrecacheModel( "models/player/kleiner.mdl" ) From 1b2da9d59c7b50db145a8864d58d6b7da090b48c Mon Sep 17 00:00:00 2001 From: GreyGeist Date: Sun, 11 May 2014 21:11:04 -0500 Subject: [PATCH 18/52] Restriction Fixes Fixes VON --- lua/ev_plugins/sv_restriction.lua | 1 - lua/includes/modules/von.lua | 608 ++++++++++++++++++++++++++++++ 2 files changed, 608 insertions(+), 1 deletion(-) create mode 100644 lua/includes/modules/von.lua diff --git a/lua/ev_plugins/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index aa003b9..a4c48f3 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -7,7 +7,6 @@ /*------------------------------------------------------------------------------------------------------------------------- Restriction -------------------------------------------------------------------------------------------------------------------------*/ -require ("von") require ("player_manager") local PLUGIN = {} PLUGIN.Title = "Restriction" diff --git a/lua/includes/modules/von.lua b/lua/includes/modules/von.lua new file mode 100644 index 0000000..1912d04 --- /dev/null +++ b/lua/includes/modules/von.lua @@ -0,0 +1,608 @@ +--[[ vON 1.1.1 + + Copyright 2012-2013 Alexandru-Mihai Maftei + aka Vercas + + You may use this for any purpose as long as: + - You don't remove this copyright notice. + - You don't claim this to be your own. + - You properly credit the author (Vercas) if you publish your work based on (and/or using) this. + + If you modify the code for any purpose, the above obligations still apply. + + Instead of copying this code over for sharing, rather use the link: + https://dl.dropbox.com/u/1217587/GMod/Lua/von%20for%20GMOD.lua + + The author may not be held responsible for any damage or losses directly or indirectly caused by + the use of vON. + + If you disagree with the above, don't use the code. + +----------------------------------------------------------------------------------------------------------------------------- + + Thanks to the following people for their contribution: + - Divran Suggested improvements for making the code quicker. + Suggested an excellent new way of deserializing strings. + Lead me to finding an extreme flaw in string parsing. + - pennerlord Provided some performance tests to help me improve the code. + - Chessnut Reported bug with handling of nil values when deserializing array components. + +----------------------------------------------------------------------------------------------------------------------------- + + The value types supported in this release of vON are: + - table + - number + - boolean + - string + - nil + - Entity + - Player + - Vector + - Angle + + These are the native Lua types one would normally serialize. + + Some very common GMod Lua types. + +----------------------------------------------------------------------------------------------------------------------------- + + New in this version: + - Fixed problem with handling of nils in array tables. +--]] + +local _deserialize, _serialize, _d_meta, _s_meta, d_findVariable, s_anyVariable +local sub, gsub, find, insert, concat, error, tonumber, tostring, type, next, getEnt, getPly = string.sub, string.gsub, string.find, table.insert, table.concat, error, tonumber, tostring, type, next, Entity, player.GetByID + +-- This is kept away from the table for speed. +function d_findVariable(s, i, len, lastType) + local i, c, typeRead, val = i or 1 + + -- Keep looping through the string. + while true do + -- Stop at the end. Throw an error. This function MUST NOT meet the end! + if i > len then + error("vON: Reached end of string, cannot form proper variable.") + end + + -- Cache the character. Nobody wants to look for the same character ten times. + c = sub(s, i, i) + + -- If it just read a type definition, then a variable HAS to come after it. + if typeRead then + -- Attempt to deserialize a variable of the freshly read type. + val, i = _deserialize[lastType](s, i, len) + -- Return the value read, the index of the last processed character, and the type of the last read variable. + return val, i, lastType + + -- @ means nil. It should not even appear in the output string of the serializer. Nils are useless to store. + elseif c == "@" then + return nil, i, lastType + + -- n means a number will follow. Base 10... :C + elseif c == "n" then + lastType = "number" + typeRead = true + + -- b means boolean flags. + elseif c == "b" then + lastType = "boolean" + typeRead = true + + -- " means the start of a string. + elseif c == "\"" then + lastType = "string" + typeRead = true + + -- { means the start of a table! + elseif c == "{" then + lastType = "table" + typeRead = true + + -- n means a number will follow. Base 10... :C + elseif c == "e" then + lastType = "Entity" + typeRead = true + + -- n means a number will follow. Base 10... :C + elseif c == "p" then + lastType = "Player" + typeRead = true + + -- n means a number will follow. Base 10... :C + elseif c == "v" then + lastType = "Vector" + typeRead = true + + -- n means a number will follow. Base 10... :C + elseif c == "a" then + lastType = "Angle" + typeRead = true + + -- If no type has been found, attempt to deserialize the last type read. + elseif lastType then + val, i = _deserialize[lastType](s, i, len) + return val, i, lastType + + -- This will occur if the very first character in the vON code is wrong. + else + error("vON: Malformed data... Can't find a proper type definition. Char#" .. i .. ":" .. c) + end + + -- Move the pointer one step forward. + i = i + 1 + end +end + +-- This is kept away from the table for speed. +-- Yeah, crapload of parameters. +function s_anyVariable(data, lastType, isNumeric, isKey, isLast, nice, indent) + + -- Basically, if the type changes. + if lastType ~= type(data) then + -- Remember the new type. Caching the type is useless. + lastType = type(data) + + -- Return the serialized data and the (new) last type. + -- The second argument, which is true now, means that the data type was just changed. + return _serialize[lastType](data, true, isNumeric, isKey, isLast, nice, indent), lastType + end + + -- Otherwise, simply serialize the data. + return _serialize[lastType](data, false, isNumeric, isKey, isLast, nice, indent), lastType +end + +_deserialize = { + +-- Well, tables are very loose... +-- The first table doesn't have to begin and end with { and }. + ["table"] = function(s, i, len, unnecessaryEnd) + local ret, numeric, i, c, lastType, val, ind, expectValue, key = {}, true, i or 1, nil, nil, nil, 1 + -- Locals, locals, locals, locals, locals, locals, locals, locals and locals. + + -- Keep looping. + while true do + -- Until it meets the end. + if i > len then + -- Yeah, if the end is unnecessary, it won't spit an error. The main chunk doesn't require an end, for example. + if unnecessaryEnd then + return ret, i + + -- Otherwise, the data has to be damaged. + else + error("vON: Reached end of string, incomplete table definition.") + end + end + + -- Cache the character. + c = sub(s, i, i) + --print(i, "table char:", c, tostring(unnecessaryEnd)) + + -- If it's the end of a table definition, return. + if c == "}" then + return ret, i + + -- If it's the component separator, switch to key:value pairs. + elseif c == "~" then + numeric = false + + elseif c == ";" then + -- Lol, nothing! + -- Remenant from numbers, for faster parsing. + + -- OK, now, if it's on the numeric component, simply add everything encountered. + elseif numeric then + -- Find a variable and it's value + val, i, lastType = d_findVariable(s, i, len, lastType) + -- Add it to the table. + ret[ind] = val + + ind = ind + 1 + + -- Otherwise, if it's the key:value component... + else + -- If a value is expected... + if expectValue then + -- Read it. + val, i, lastType = d_findVariable(s, i, len, lastType) + -- Add it? + ret[key] = val + -- Clean up. + expectValue, key = false, nil + + -- If it's the separator... + elseif c == ":" then + -- Expect a value next. + expectValue = true + + -- But, if there's a key read already... + elseif key then + -- Then this is malformed. + error("vON: Malformed table... Two keys declared successively? Char#" .. i .. ":" .. c) + + -- Otherwise the key will be read. + else + -- I love multi-return and multi-assignement. + key, i, lastType = d_findVariable(s, i, len, lastType) + end + end + + i = i + 1 + end + + return nil, i + end, + + +-- Numbers are weakly defined. +-- The declaration is not very explicit. It'll do it's best to parse the number. +-- Has various endings: \n, }, ~, : and ;, some of which will force the table deserializer to go one char backwards. + ["number"] = function(s, i, len) + local i, a = i or 1 + -- Locals, locals, locals, locals + + a = find(s, "[;:}~]", i) + + if a then + return tonumber(sub(s, i, a - 1)), a - 1 + end + + error("vON: Number definition started... Found no end.") + end, + + +-- A boolean is A SINGLE CHARACTER, either 1 for true or 0 for false. +-- Any other attempt at boolean declaration will result in a failure. + ["boolean"] = function(s, i, len) + local c = sub(s,i,i) + -- Only one character is needed. + + -- If it's 1, then it's true + if c == "1" then + return true, i + + -- If it's 0, then it's false. + elseif c == "0" then + return false, i + end + + -- Any other supposely "boolean" is just a sign of malformed data. + error("vON: Invalid value on boolean type... Char#" .. i .. ": " .. c) + end, + + +-- Strings are very easy to parse and also very explicit. +-- " simply marks the type of a string. +-- Then it is parsed until an unescaped " is countered. + ["string"] = function(s, i, len) + local res, i, a = "", i or 1 + -- Locals, locals, locals, locals + + while true do + a = find(s, "\"", i, true) + + if a then + if sub(s, a - 1, a - 1) == "\\" then + res = res .. sub(s, i, a - 2) .. "\"" + i = a + 1 + else + return res .. sub(s, i, a - 2), a + end + else + error("vON: String definition started... Found no end.") + end + end + end, + + +-- Entities are stored simply by the ID. They're meant to be transfered, not stored anyway. +-- Exactly like a number definition, except it begins with "e". + ["Entity"] = function(s, i, len) + local i, a = i or 1 + -- Locals, locals, locals, locals + + a = find(s, "[;:}~]", i) + + if a then + return getEnt(tonumber(sub(s, i, a - 1))), a - 1 + end + + error("vON: Entity ID definition started... Found no end.") + end, + + +-- Exactly like a entity definition, except it begins with "p". + ["Player"] = function(s, i, len) + local i, a = i or 1 + -- Locals, locals, locals, locals + + a = find(s, "[;:}~]", i) + + if a then + return getEnt(tonumber(sub(s, i, a - 1))), a - 1 + end + + error("vON: Player ID definition started... Found no end.") + end, + + +-- A pair of 3 numbers separated by a comma (,). + ["Vector"] = function(s, i, len) + local i, a, x, y, z = i or 1 + -- Locals, locals, locals, locals + + a = find(s, ",", i) + + if a then + x = tonumber(sub(s, i, a - 1)) + i = a + 1 + end + + a = find(s, ",", i) + + if a then + y = tonumber(sub(s, i, a - 1)) + i = a + 1 + end + + a = find(s, "[;:}~]", i) + + if a then + z = tonumber(sub(s, i, a - 1)) + end + + if x and y and z then + return Vector(x, y, z), a - 1 + end + + error("vON: Vector definition started... Found no end.") + end, + + +-- A pair of 3 numbers separated by a comma (,). + ["Angle"] = function(s, i, len) + local i, a, p, y, r = i or 1 + -- Locals, locals, locals, locals + + a = find(s, ",", i) + + if a then + p = tonumber(sub(s, i, a - 1)) + i = a + 1 + end + + a = find(s, ",", i) + + if a then + y = tonumber(sub(s, i, a - 1)) + i = a + 1 + end + + a = find(s, "[;:}~]", i) + + if a then + r = tonumber(sub(s, i, a - 1)) + end + + if p and y and r then + return Angle(p, y, r), a - 1 + end + + error("vON: Angle definition started... Found no end.") + end +} + + +_serialize = { + +-- Uh. Nothing to comment. +-- Shitload of parameters. +-- Makes shit faster than simply passing it around in locals. +-- table.concat works better than normal concatenations WITH LARGE-ISH STRINGS ONLY. + ["table"] = function(data, mustInitiate, isNumeric, isKey, isLast, first) + --print(string.format("data: %s; mustInitiate: %s; isKey: %s; isLast: %s; nice: %s; indent: %s; first: %s", tostring(data), tostring(mustInitiate), tostring(isKey), tostring(isLast), tostring(nice), tostring(indent), tostring(first))) + + local result, keyvals, len, keyvalsLen, keyvalsProgress, val, lastType, newIndent, indentString = {}, {}, #data, 0, 0 + -- Locals, locals, locals, locals, locals, locals, locals, locals, locals and locals. + + -- First thing to be done is separate the numeric and key:value components of the given table in two tables. + -- pairs(data) is slower than next, data as far as my tests tell me. + for k, v in next, data do + -- Skip the numeric keyz. + if type(k) ~= "number" or k < 1 or k > len then + keyvals[#keyvals + 1] = k + end + end + + keyvalsLen = #keyvals + + -- Main chunk - no initial character. + if not first then + result[#result + 1] = "{" + end + + -- Add numeric values. + if len > 0 then + for i = 1, len do + val, lastType = s_anyVariable(data[i], lastType, true, false, i == len and not first, false, 0) + result[#result + 1] = val + end + end + + -- If there are key:value pairs. + if keyvalsLen > 0 then + -- Insert delimiter. + result[#result + 1] = "~" + + -- Insert key:value pairs. + for _i = 1, keyvalsLen do + keyvalsProgress = keyvalsProgress + 1 + + val, lastType = s_anyVariable(keyvals[_i], lastType, false, true, false, false, 0) + + result[#result + 1] = val..":" + + val, lastType = s_anyVariable(data[keyvals[_i]], lastType, false, false, keyvalsProgress == keyvalsLen and not first, false, 0) + + result[#result + 1] = val + end + end + + -- Main chunk needs no ending character. + if not first then + result[#result + 1] = "}" + end + + return concat(result) + end, + + +-- Normal concatenations is a lot faster with small strings than table.concat +-- Also, not so branched-ish. + ["number"] = function(data, mustInitiate, isNumeric, isKey, isLast) + -- If a number hasn't been written before, add the type prefix. + if mustInitiate then + if isKey or isLast then + return "n"..data + else + return "n"..data..";" + end + end + + if isKey or isLast then + return "n"..data + else + return "n"..data..";" + end + end, + + +-- I hope gsub is fast enough. + ["string"] = function(data, mustInitiate, isNumeric, isKey, isLast) + return "\"" .. gsub(data, "\"", "\\\"") .. "v\"" + end, + + +-- Fastest. + ["boolean"] = function(data, mustInitiate, isNumeric, isKey, isLast) + -- Prefix if we must. + if mustInitiate then + if data then + return "b1" + else + return "b0" + end + end + + if data then + return "1" + else + return "0" + end + end, + + +-- Fastest. + ["nil"] = function(data, mustInitiate, isNumeric, isKey, isLast) + return "@" + end, + + +-- Same as numbers, except they start with "e" instead of "n". + ["Entity"] = function(data, mustInitiate, isNumeric, isKey, isLast) + data = data:EntIndex() + + if mustInitiate then + if isKey or isLast then + return "e"..data + else + return "e"..data..";" + end + end + + if isKey or isLast then + return "e"..data + else + return "e"..data..";" + end + end, + + +-- Same as entities, except they start with "e" instead of "n". + ["Player"] = function(data, mustInitiate, isNumeric, isKey, isLast) + data = data:EntIndex() + + if mustInitiate then + if isKey or isLast then + return "p"..data + else + return "p"..data..";" + end + end + + if isKey or isLast then + return "p"..data + else + return "p"..data..";" + end + end, + + +-- 3 numbers separated by a comma. + ["Vector"] = function(data, mustInitiate, isNumeric, isKey, isLast) + if mustInitiate then + if isKey or isLast then + return "v"..data.x..","..data.y..","..data.z + else + return "v"..data.x..","..data.y..","..data.z..";" + end + end + + if isKey or isLast then + return "v"..data.x..","..data.y..","..data.z + else + return "v"..data.x..","..data.y..","..data.z..";" + end + end, + + +-- 3 numbers separated by a comma. + ["Angle"] = function(data, mustInitiate, isNumeric, isKey, isLast) + if mustInitiate then + if isKey or isLast then + return "a"..data.p..","..data.y..","..data.r + else + return "a"..data.p..","..data.y..","..data.r..";" + end + end + + if isKey or isLast then + return "a"..data.p..","..data.y..","..data.r + else + return "a"..data.p..","..data.y..","..data.r..";" + end + end +} + +local _s_table = _serialize.table +local _d_table = _deserialize.table + +_d_meta = { + __call = function(self, str) + if type(str) == "string" then + return _d_table(str, nil, #str, true) + end + error("vON: You must deserialize a string, not a "..type(str)) + end +} +_s_meta = { + __call = function(self, data) + if type(data) == "table" then + return _s_table(data, nil, nil, nil, nil, true) + end + error("vON: You must serialize a table, not a "..type(data)) + end +} + +von = {} + +von.deserialize = setmetatable(_deserialize,_d_meta) +von.serialize = setmetatable(_serialize,_s_meta) \ No newline at end of file From 5f5bf420960b1bc6914ec73be29b91bdf78b348d Mon Sep 17 00:00:00 2001 From: Xandaros Date: Sat, 23 Aug 2014 10:41:59 +0000 Subject: [PATCH 19/52] Make sourcebans live --- lua/ev_sourcebans.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 From 9e863b207fa317735675d2759418b098e519c2e2 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Fri, 19 Sep 2014 12:50:41 -0400 Subject: [PATCH 20/52] Added plugin to set hunger and money in darkrp, made ragdolling not destroy weapons. --- lua/ev_plugins/sh_hunger.lua | 45 +++++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_ragdoll.lua | 45 ++++++++++++++++++++++++++++++++--- lua/ev_plugins/sh_wallet.lua | 45 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 lua/ev_plugins/sh_hunger.lua create mode 100644 lua/ev_plugins/sh_wallet.lua 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_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_wallet.lua b/lua/ev_plugins/sh_wallet.lua new file mode 100644 index 0000000..6caf52b --- /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 ), evolve.colors.green, 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 From ead569434fe48b2ca852d78ba47b33bd554bf03b Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Fri, 19 Sep 2014 18:35:44 -0400 Subject: [PATCH 21/52] That constant doesn't exist, whoops. --- lua/ev_plugins/sh_spawnprotection.lua | 4 ++-- lua/ev_plugins/sh_wallet.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/ev_plugins/sh_spawnprotection.lua b/lua/ev_plugins/sh_spawnprotection.lua index 54c280d..9e71e2c 100644 --- a/lua/ev_plugins/sh_spawnprotection.lua +++ b/lua/ev_plugins/sh_spawnprotection.lua @@ -1,4 +1,4 @@ -/*------------------------------------------------------------------------------------------------------------------------- +/*------------------------------------------------------------------------------------------------------------------------- NoRecoil a player -------------------------------------------------------------------------------------------------------------------------*/ @@ -54,7 +54,7 @@ if SERVER then end end end) - evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white," or until you draw a weapon." ) + evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white, " or until you draw a weapon. ", evolve.colors.red, "GO AWAY SCARY SYMBOLS" ) else ply:SetNWBool( "EV_SpawnProtected", false ) end diff --git a/lua/ev_plugins/sh_wallet.lua b/lua/ev_plugins/sh_wallet.lua index 6caf52b..1609178 100644 --- a/lua/ev_plugins/sh_wallet.lua +++ b/lua/ev_plugins/sh_wallet.lua @@ -20,7 +20,7 @@ function PLUGIN:Call( ply, args ) end if ( #players > 0 ) then - evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has given ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.green, GAMEMODE.Config.currency..amount, evolve.colors.white, "." ) + 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 From 5ae3f7779d790829ebb78e07c65bacae62b32822 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Fri, 19 Sep 2014 18:35:44 -0400 Subject: [PATCH 22/52] That constant doesn't exist, whoops. --- lua/ev_plugins/sh_spawnprotection.lua | 4 ++-- lua/ev_plugins/sh_wallet.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/ev_plugins/sh_spawnprotection.lua b/lua/ev_plugins/sh_spawnprotection.lua index 54c280d..9e71e2c 100644 --- a/lua/ev_plugins/sh_spawnprotection.lua +++ b/lua/ev_plugins/sh_spawnprotection.lua @@ -1,4 +1,4 @@ -/*------------------------------------------------------------------------------------------------------------------------- +/*------------------------------------------------------------------------------------------------------------------------- NoRecoil a player -------------------------------------------------------------------------------------------------------------------------*/ @@ -54,7 +54,7 @@ if SERVER then end end end) - evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white," or until you draw a weapon." ) + evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white, " or until you draw a weapon. ", evolve.colors.red, "GO AWAY SCARY SYMBOLS" ) else ply:SetNWBool( "EV_SpawnProtected", false ) end diff --git a/lua/ev_plugins/sh_wallet.lua b/lua/ev_plugins/sh_wallet.lua index 6caf52b..1609178 100644 --- a/lua/ev_plugins/sh_wallet.lua +++ b/lua/ev_plugins/sh_wallet.lua @@ -20,7 +20,7 @@ function PLUGIN:Call( ply, args ) end if ( #players > 0 ) then - evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has given ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.green, GAMEMODE.Config.currency..amount, evolve.colors.white, "." ) + 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 From 854d5a889226d23700477f3ba5c17c59b0666907 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 22 Sep 2014 01:20:04 +0200 Subject: [PATCH 23/52] Fixed not usable console-commands like "ev map" The function checked only if plugin.ChatCommand was a string - changed it now to same behavior than sv_chatcommands to also check if the plugin.ChatCommand is using a table. So this fixes for example the use of map change plugin from console. --- lua/ev_plugins/sv_consolecommands.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/ev_plugins/sv_consolecommands.lua b/lua/ev_plugins/sv_consolecommands.lua index 4464173..f3ca0c1 100644 --- a/lua/ev_plugins/sv_consolecommands.lua +++ b/lua/ev_plugins/sv_consolecommands.lua @@ -26,8 +26,15 @@ function PLUGIN:CCommand( ply, com, cargs ) 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 == string.lower( command or "" ) ) then - plugin:Call( ply, args ) + if ( plugin.ChatCommand == command or ( type( plugin.ChatCommand ) == "table" and table.HasValue( plugin.ChatCommand, command ) ) ) then + evolve.SilentNotify = string.Left( com, 1 ) == "@" + res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) + evolve.SilentNotify = false + + if ( !res ) then + evolve:Notify( evolve.colors.red, "Plugin '" .. plugin.Title .. "' failed with error:" ) + evolve:Notify( evolve.colors.red, ret ) + end return "" end end @@ -37,4 +44,4 @@ end concommand.Add( "ev", function( ply, com, args ) PLUGIN:CCommand( ply, com, args ) end ) concommand.Add( "evs", function( ply, com, args ) evolve.SilentNotify = true PLUGIN:CCommand( ply, com, args ) evolve.SilentNotify = false end ) -evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file +evolve:RegisterPlugin( PLUGIN ) From 05ff22643a29adceec7bdec4711e69e3602289bf Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 22 Sep 2014 01:30:20 +0200 Subject: [PATCH 24/52] adds map-change tab in menu --- lua/ev_menu/tab_v_maps.lua | 203 +++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 lua/ev_menu/tab_v_maps.lua 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 ) From 74b5521040bdbdb8c60bbfdbbf8fd92e65e8e01b Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Mon, 22 Sep 2014 15:26:22 -0400 Subject: [PATCH 25/52] Re-hooked the menu to work with the net library due to datastream being depreciated. --- lua/ev_menu/tab_adverts3.lua | 86 ++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/lua/ev_menu/tab_adverts3.lua b/lua/ev_menu/tab_adverts3.lua index b77e892..c621028 100644 --- a/lua/ev_menu/tab_adverts3.lua +++ b/lua/ev_menu/tab_adverts3.lua @@ -1,29 +1,59 @@ -/* +--[[ 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 +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 = "gui/silkicons/page_white_wrench" -TAB.Author = "SariaFace" +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 - function SendAdvertsList(target, cmd, args) - if (target) then - if (adverts and #adverts.Stored) then - datastream.StreamToClients(target, "EV_Adverts3_ReceiveList", adverts.Stored) - end - end - end - concommand.Add("EV_Adverts3_RequestList", SendAdvertsList) + util.AddNetworkString("EV_Adverts3") else - local NewAdPanelReg = {} + local NewAdPanelReg = {} function NewAdPanelReg:Init() self:SetPos( 40, (ScrH()/3)*2) self:SetSize(560, 62) @@ -127,19 +157,24 @@ else timer.Simple(1.0, function() TAB:Update() end) self:Remove() end - end vgui.Register("NewAdPanel", NewAdPanelReg, "DFrame") - - adverts = {} - function SyncAdverts(hdl, id, enc, dec) - adverts = dec - end - datastream.Hook("EV_Adverts3_ReceiveList", SyncAdverts) - RunConsoleCommand("EV_Adverts3_RequestList") 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 + --===================================================================================-- function TAB:Initialize( pnl ) + adverts = {} + self.AdList = vgui.Create( "DListView", pnl ) self.AdList:SetSize( self.Width, pnl:GetParent():GetTall() - 58 ) self.AdList:SetMultiSelect( false ) @@ -170,7 +205,9 @@ function TAB:Initialize( pnl ) self.Tog:SetPos( self.Width - 145, pnl:GetParent():GetTall() - 53 ) self.Tog:SetText( "Toggle" ) self.Tog.DoClick = function() - local id = self.AdList:GetSelected()[1]:GetValue(1) + if self.AdList:GetSelected() then + local id = self.AdList:GetSelected()[1]:GetValue(1) + end RunConsoleCommand("ev", "advert3", "toggle", id) adverts[id]["OnState"] = !adverts[id]["OnState"] self.AdList:GetSelected()[1]:SetValue(5, adverts[id]["OnState"]) @@ -186,7 +223,7 @@ function TAB:Initialize( pnl ) adverts[id] = nil self:Update() end - timer.Simple(1.5, function() TAB:Update() end) + timer.Simple(1.5, function() TAB:Request() end) end function TAB:Update() @@ -198,11 +235,12 @@ function TAB:Update() end function TAB:Request() - RunConsoleCommand("EV_Adverts3_RequestList") + self:GetAdverts() timer.Simple(2, function() TAB:Update() end) end function TAB:IsAllowed() return LocalPlayer():EV_HasPrivilege( "Advert 3 Menu" ) end + evolve:RegisterTab( TAB ) \ No newline at end of file From e55a51695af9c0fe1628ff3a4d5ec082c5e87d3f Mon Sep 17 00:00:00 2001 From: X-Coder Date: Wed, 24 Sep 2014 22:23:28 +0200 Subject: [PATCH 26/52] Code-Cleanup Removed indentation and last line break --- lua/ev_plugins/sv_consolecommands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/ev_plugins/sv_consolecommands.lua b/lua/ev_plugins/sv_consolecommands.lua index f3ca0c1..63bfadf 100644 --- a/lua/ev_plugins/sv_consolecommands.lua +++ b/lua/ev_plugins/sv_consolecommands.lua @@ -28,7 +28,7 @@ function PLUGIN:CCommand( ply, com, cargs ) 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 = string.Left( com, 1 ) == "@" - res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) + res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) evolve.SilentNotify = false if ( !res ) then From 03279ea85e27c70d07e3a13b1313258e439577f8 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Thu, 25 Sep 2014 04:42:37 -0400 Subject: [PATCH 27/52] Added DarkRP hooks, although mostly non-operable. Added ability to network settings to / from the server & save them. Added a settings tab and methods for plugins to register / use their own settings. --- lua/ev_framework.lua | 114 ++++++++- lua/ev_menu/tab_settings.lua | 458 +++++++++++++++++++++++++++++++++++ lua/ev_plugins/sh_armor.lua | 25 +- 3 files changed, 592 insertions(+), 5 deletions(-) create mode 100644 lua/ev_menu/tab_settings.lua diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 7fa4b84..5d9fb48 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -26,6 +26,23 @@ evolve.category.punishment = 3 evolve.category.teleportation = 4 evolve.stagedPlugins = {} evolve.plugins = {} +evolve.settings = { + 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.version = 179 _R = debug.getregistry() @@ -37,6 +54,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") @@ -248,6 +266,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:RegisterSettings( plugin.Settings ) end else table.insert( evolve.plugins, { Title = plugin.Title, File = pluginFile } ) end @@ -464,10 +483,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 @@ -503,6 +518,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() @@ -1166,6 +1189,89 @@ 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 +]] + +if SERVER then + function evolve:SaveSettings() + -- will probably have a client version at some point + file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) + end + + function evolve:LoadSettings() + if ( file.Exists( "ev_settings.txt", "DATA" ) ) then + evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) + else + evolve.settings = {} + evolve:SaveSettings() + end + end + evolve:LoadSettings() + + net.Receive( "EV_Settings", function( length, ply ) + -- on = sending, off = requesting + local doit = net.ReadBit() + if ( IsValid( ply ) and ply:IsPlayer() ) then + if doit then + local sets = net.ReadTable() + evolve.settings = sets + evolve:SaveSettings() + else + evolve:SendSettings(ply) + end + end + end ) +end + +function evolve:RegisterSettings( sets ) + table.Merge(evolve.settings, sets) + table.sort(evolve.settings) + return evolve.settings +end + +function evolve:SetSetting( name, value ) + evolve.settings[name] = value + --evolve:SaveSettings() +end + +function evolve:GetSetting( name, default ) + return evolve.settings[name] or default +end + +function evolve:SendSettings( ply ) + --todo: secure params + net.Start("EV_Settings") + net.WriteBit(1) + net.WriteTable(evolve.settings) + if CLIENT then + net.SendToServer() + else + net.Send(ply) + end +end + +if CLIENT then + net.Receive( "EV_Settings", function( length ) + -- on = sending, off = requesting + local doit = net.ReadBit() + if doit then + evolve.settings = net.ReadTable() + else + evolve:SendSettings() + end + end ) +end + /*------------------------------------------------------------------------------------------------------------------------- Global data system -------------------------------------------------------------------------------------------------------------------------*/ diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua new file mode 100644 index 0000000..fe28cba --- /dev/null +++ b/lua/ev_menu/tab_settings.lua @@ -0,0 +1,458 @@ +/*------------------------------------------------------------------------------------------------------------------------- + Tab with settings +-------------------------------------------------------------------------------------------------------------------------*/ + +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" } + +TAB.CatWidth = 166 + +TAB.Frame = nil +TAB.SearchBox = nil +TAB.SearchButton = nil +TAB.SettingsTree = nil +--[[ + this is mapped: + global.nodes['category1'].nodes['category2'] +]] +TAB.Scroll = nil +TAB.Layout = nil +TAB.GraveYard = nil + +TAB.Categories = {} +--[[ + this is mapped: + global.nodes['category1'].nodes['category2'] +]] +--[[ + this WAS mapped: + global['category1']['category2'].sets +]] +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 = { + num_corns = { + label = 'No. Corns', + desc = 'How many corns? This many.', + stype = 'limit', + value = 50, + min = 25, + max = 75, + default = 30}, + num_horns = { + label = 'No. Horns', + desc = 'Remember, we are on a budget.', + stype = 'limit', + value = 1, + min = -3, + max = 30, + default = 2}, + resync_name = { + label = 'Sync Again Label', + desc = 'Can you not decide what to call it?', + stype = 'string', + value = 'reSync', + default = 'ReSync'}, + best_name = { + label = 'Best Name', + desc = 'Who is the best?', + stype = 'string', + value = 'Bungalo', + default = 'EntranceJew'}, + is_great = { + label = 'Is Great', + desc = 'Are you having trouble finding out?', + stype = 'bool', + value = true, + default = false}, + }, + }, + }, + }, +} +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 +-- functions used by buildsettings +function TAB:CreateLimit( pnl, name, item ) + 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 ) + pnl.NumSlider = elm + + -- boring handler overloading + local function mousereleased(mousecode) + evolve:SetSetting(name, math.Round(elm:GetValue())) --@TODO setting the decimals goes here + evolve:SendSettings() + 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 ) + 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 + elm.OnEnter = function(self) + evolve:SetSetting(name, elm:GetValue()) + evolve:SendSettings() + end + + return pnl +end + +function TAB:CreateBool( pnl, name, item ) + 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 + elm.OnChange = function(self) + evolve:SetSetting(name, elm:GetValue()) + evolve:SendSettings() + end + + return pnl +end + +--[[TAB:Update()]] + +function TAB:BuildCategories( atree, acat, 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 cat = acat + 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 + + assert(istable(cat), "GOT NON-TABLE CATEGORY NODE") + print("DEBUG: BuildCategories2 -- Investigating cat shaped like: ") + PrintTable(cat) + if cat.nodes==nil then + print("DEBUG: BuildCategories2 -- 1: Cat @ depth has no nodes, adding node stub.") + cat.nodes={} + else + print("DEBUG: BuildCategories2 -- 2: Cat @ depth has nodes, we must be in an item with multiple children.") + 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:BuildSettings( dpath ) + end + + -- add tree child + tree.nodes[v.label] = node + cat.nodes[v.label] = v.value --assign category as a reference to the position in evolve.settings + + print("DEBUG: BuildCategories2 -- Recursing!!!") + self:BuildCategories( tree.nodes[v.label], cat.nodes[v.label], v.value, depth ) + print("DEBUG: BuildCategories2 -- Returned from recursion!!!") + else + 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) + 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.Categories + 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) do + if k~='nodes' then + if self.Controls[k]~=nil then + print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") + self.Controls[k]:SetParent(self.Layout) + else + print("DEBUG: BuildSettings -- created new element stub: '"..k.."'") + local step = vgui.Create( "DPanel", self.Layout ) + step:SetWide( self.Layout:GetWide() ) + step:SetTall(32) + + if v.stype == 'limit' then + self.Controls[k] = self:CreateLimit( step, k, v ) + elseif v.stype == 'string' then + self.Controls[k] = self:CreateString( step, k, v ) + elseif v.stype == 'bool' then + self.Controls[k] = self:CreateBool( step, k, v ) + else + print("IGNORED ELEMENT OF TYPE '"..v.stype.."', REMOVING STUB") + step:Remove() + end + print("DEBUG: BuildSettings -- finalized element: '"..k.."'") + end + end + 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) + self:GetParent().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()-18) + --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, self.Categories, evolve.settings ) + self:OpenToPath( {"General", "Misc"} ) +end + +evolve:RegisterTab( TAB ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_armor.lua b/lua/ev_plugins/sh_armor.lua index 1d03139..f67c64c 100644 --- a/lua/ev_plugins/sh_armor.lua +++ b/lua/ev_plugins/sh_armor.lua @@ -9,11 +9,34 @@ PLUGIN.Author = "Overv" PLUGIN.ChatCommand = "armor" PLUGIN.Usage = "[players] [armor]" PLUGIN.Privileges = { "Armor" } +PLUGIN.Settings = { + category_plugins = { + value = { + category_armor = { + label = 'Armor', + desc = 'Settings for your Armor', + stype = 'category', + icon = 'shield', + value = { + max_armor = { + label = 'Max Armor', + desc = 'Source Engine overflow Prevention', + stype = 'limit', + value = 100, + min = 100, + max = 255, + default = 150 + }, + } + } + } + } +} 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 ) From 99196102f6221e3be721614c04e02c174333fc01 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Thu, 25 Sep 2014 10:08:55 -0400 Subject: [PATCH 28/52] Restricted plugin auto-registration to the domain of the plugins category. Temporarily commented out darkrp hooks. --- lua/ev_framework.lua | 19 ++++++++++++++++--- lua/ev_plugins/sh_armor.lua | 31 ++++++++++--------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 5d9fb48..40b1ed7 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -266,7 +266,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:RegisterSettings( plugin.Settings ) end + if ( plugin.Settings ) then evolve:RegisterPluginSettings( plugin ) end else table.insert( evolve.plugins, { Title = plugin.Title, File = pluginFile } ) end @@ -519,12 +519,12 @@ hook.Add( "PlayerSpawnedEffect", "EV_SpawnHook", function( ply, model, ent ) ent 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( "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 ) +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 ) @@ -1238,6 +1238,19 @@ function evolve:RegisterSettings( sets ) table.sort(evolve.settings) 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 = plugin.Settings or {} + evolve.settings.category_plugins.value['category_'..string.lower(label)] = { + desc = desc, + icon = icon, + label = label, + stype = 'category', + value = value + } +end function evolve:SetSetting( name, value ) evolve.settings[name] = value diff --git a/lua/ev_plugins/sh_armor.lua b/lua/ev_plugins/sh_armor.lua index f67c64c..2a3d3af 100644 --- a/lua/ev_plugins/sh_armor.lua +++ b/lua/ev_plugins/sh_armor.lua @@ -9,28 +9,17 @@ PLUGIN.Author = "Overv" PLUGIN.ChatCommand = "armor" PLUGIN.Usage = "[players] [armor]" PLUGIN.Privileges = { "Armor" } +PLUGIN.Icon = 'shield' PLUGIN.Settings = { - category_plugins = { - value = { - category_armor = { - label = 'Armor', - desc = 'Settings for your Armor', - stype = 'category', - icon = 'shield', - value = { - max_armor = { - label = 'Max Armor', - desc = 'Source Engine overflow Prevention', - stype = 'limit', - value = 100, - min = 100, - max = 255, - default = 150 - }, - } - } - } - } + max_armor = { + label = 'Max Armor', + desc = 'Source Engine overflow Prevention', + stype = 'limit', + value = 100, + min = 100, + max = 255, + default = 150 + }, } function PLUGIN:Call( ply, args ) From 7384591f33efbfa15cbb1261ae456b73eca527a0 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sat, 27 Sep 2014 14:06:27 -0400 Subject: [PATCH 29/52] Clients request settings on initial load via network. Server properly loads settings from file. Sandbox settings moved to plugin to register under generic settings panel. Atmos settings added as a plugin. Temporarily added "atmos_" to the convar whitelist until I add settings for that. Added privileges for modifying settings and sending settings to the server. Collapsed the use of "Categories" into "SettingsTree". Collapsed the DoChange method into evolve:SetSetting. Commented out debug prints. Added evolve.settingsStructure as a point of reference for validating the hierarchy of settings. Made evolve:SetSetting client-only for now due to referencing LocalPlayer. evolve:GetSetting() now properly evaluates defaults so that something with the default of true won't override a value of false. evolve:SendSettings() now checks for the privilege of "Settings: Send To Server" and defaults to broadcast to all players if called as the server. Made evolve:SaveSettings() available to the client, though this is a mistake, because von isn't available to clients. Made net messages use a string instead of a bit because sends were being mistaken for saves. Server automatically rebroadcasts settings once a player saves them to the server. Registering settings will not overwrite pre-existing settings. This may be unwanted in some cases. We'll deal with that when the time comes. Registering settings copies data instead of referencing. If you're writing a plugin remember to use evolve:GetSettings() instead of your Settings table. Server has the option to re-load settings post-init to overwrite any changes made in server.cfg --- lua/ev_cl_init.lua | 1 + lua/ev_framework.lua | 189 ++++++++++++++++++-------- lua/ev_menu/tab_sandbox.lua | 139 -------------------- lua/ev_menu/tab_settings.lua | 240 ++++++++++++++++++++++------------ lua/ev_plugins/sh_atmos.lua | 122 +++++++++++++++++ lua/ev_plugins/sh_convar.lua | 3 +- lua/ev_plugins/sh_sandbox.lua | 218 ++++++++++++++++++++++++++++++ lua/ev_sv_init.lua | 1 + 8 files changed, 635 insertions(+), 278 deletions(-) delete mode 100644 lua/ev_menu/tab_sandbox.lua create mode 100644 lua/ev_plugins/sh_atmos.lua create mode 100644 lua/ev_plugins/sh_sandbox.lua diff --git a/lua/ev_cl_init.lua b/lua/ev_cl_init.lua index 920ff43..c7e7c52 100644 --- a/lua/ev_cl_init.lua +++ b/lua/ev_cl_init.lua @@ -10,4 +10,5 @@ net.Receive( "EV_Init", function( length ) evolve.installed = true evolve:LoadPlugins() + evolve:GetSettings() end ) \ No newline at end of file diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 40b1ed7..9698c92 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -26,7 +26,7 @@ evolve.category.punishment = 3 evolve.category.teleportation = 4 evolve.stagedPlugins = {} evolve.plugins = {} -evolve.settings = { +evolve.settingsStructure = { category_general = { label = 'General', desc = 'This is for general evolve settings.', @@ -43,6 +43,7 @@ evolve.settings = { value = {} } } +evolve.settings = {} evolve.version = 179 _R = debug.getregistry() @@ -1201,89 +1202,159 @@ end allow for user-specific settings LOCK THIS WAY DOWN ]] +if CLIENT then + 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 + --@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 +end +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 -if SERVER then - function evolve:SaveSettings() - -- will probably have a client version at some point - file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) - 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") + net.WriteTable(evolve.settings) + if CLIENT then + net.SendToServer() + elseif SERVER and ply then + net.Send(ply) + elseif SERVER then + net.Broadcast() + end + return true +end + +function evolve:SaveSettings() + -- will probably have a client version at some point + file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) +end - function evolve:LoadSettings() - if ( file.Exists( "ev_settings.txt", "DATA" ) ) then - evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) - else - evolve.settings = {} - evolve:SaveSettings() - end - end - evolve:LoadSettings() +if SERVER then + function evolve:LoadSettings() + if ( file.Exists( "ev_settings.txt", "DATA" ) ) then + evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) + end + + --@TODO: do some validaiton here I guess, we would use SetSetting but you know + for k,v in pairs(evolve.settings) do + if ConVarExists(k) then + --@TODO: Don't load setting if convar already set to that value. + RunConsoleCommand("ev", "convar", k, v.value) + else + end + end + end net.Receive( "EV_Settings", function( length, ply ) -- on = sending, off = requesting - local doit = net.ReadBit() + local doit = net.ReadString() + print("GOT NETWORK MESSAGE: "..doit) if ( IsValid( ply ) and ply:IsPlayer() ) then - if doit then - local sets = net.ReadTable() - evolve.settings = sets - evolve:SaveSettings() - else + if doit == "save" then + if ply:EV_HasPrivilege( "Settings: Send To Server" ) then + local sets = net.ReadTable() + --@TODO: do a step-by-step validation of the settings instead of global overwrite + evolve.settings = sets + 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-32) --@TODO: assumes strings are 4 bytes, ergo 32 bits + 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 + + net.Receive( "EV_Settings", function( length ) + -- on = sending, off = requesting + local doit = net.ReadString() + if doit == "save" then + evolve.settings = net.ReadTable() + 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 + if mergepoint[k] == nil then + mergepoint[k] = v + end + end + end end - function evolve:RegisterSettings( sets ) - table.Merge(evolve.settings, sets) - table.sort(evolve.settings) + 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 = plugin.Settings or {} - evolve.settings.category_plugins.value['category_'..string.lower(label)] = { + 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 } -end - -function evolve:SetSetting( name, value ) - evolve.settings[name] = value - --evolve:SaveSettings() -end - -function evolve:GetSetting( name, default ) - return evolve.settings[name] or default -end - -function evolve:SendSettings( ply ) - --todo: secure params - net.Start("EV_Settings") - net.WriteBit(1) - net.WriteTable(evolve.settings) - if CLIENT then - net.SendToServer() - else - net.Send(ply) + for k,v in pairs( del['category_'..string.lower(label)].value ) do + if evolve.settings[k] == nil then + evolve.settings[k] = v + end end end -if CLIENT then - net.Receive( "EV_Settings", function( length ) - -- on = sending, off = requesting - local doit = net.ReadBit() - if doit then - evolve.settings = net.ReadTable() - else - evolve:SendSettings() - end - end ) -end /*------------------------------------------------------------------------------------------------------------------------- Global data system @@ -1355,6 +1426,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/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 index fe28cba..919e319 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -2,13 +2,25 @@ Tab with settings -------------------------------------------------------------------------------------------------------------------------*/ +--[[ + @TODO: settings in general + * Put the console var handling general code into SetSetting? + * Implement setting domains (server/client/shared -- do domain checks so that one user can't overwrite the settings of another with higher privs) + * Bind settings to permissions. + * Implement string validators. + * 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. + * + @TODO: framework overhaul + * make the menu have more methods to call on registered TABs, Open, Close, Hide +]] + 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" } +TAB.Privileges = { "Settings", "Settings: Modify", "Settings: Send To Server" } TAB.CatWidth = 166 @@ -19,20 +31,14 @@ 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.Categories = {} ---[[ - this is mapped: - global.nodes['category1'].nodes['category2'] -]] ---[[ - this WAS mapped: - global['category1']['category2'].sets -]] + TAB.Controls = {} --[[ this is mapped: @@ -87,6 +93,34 @@ local testsettings = { value = true, default = false}, }, + }, + 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', + value = true, + default = false}, + }, + }, + category_hud = { + label = 'HUD', + desc = "Specially modify how your HUD controls.", + stype = 'category', + icon = 'overlays', + value = { + hud_noises = { + label = 'HUD Sounds', + desc = 'If enabled, this will play beepy noises when your hud monitors get dangerously low.', + stype = 'bool', + value = true, + default = true}, + }, }, }, }, @@ -108,8 +142,20 @@ evolve:RegisterSettings( testsettings ) function TAB:IsAllowed() return LocalPlayer():EV_HasPrivilege( "Settings" ) 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) @@ -122,12 +168,12 @@ function TAB:CreateLimit( pnl, name, item ) elm:SetValue( item.value ) elm.Label:SetDark(true) self:SetFocusCallbacks( elm.TextArea ) - pnl.NumSlider = elm + elm.TextArea.OnEnter = mousereleased + pnl.NumSlider = elm.TextArea -- boring handler overloading local function mousereleased(mousecode) - evolve:SetSetting(name, math.Round(elm:GetValue())) --@TODO setting the decimals goes here - evolve:SendSettings() + evolve:SetSetting(name, math.Round(elm:GetValue())) end local scratch_released = elm.Scratch.OnMouseReleased @@ -153,6 +199,15 @@ function TAB:CreateLimit( pnl, name, item ) 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 ) @@ -171,15 +226,34 @@ function TAB:CreateString( pnl, name, item ) pnl.TextEntry = elm -- boring handler overloading + local parent = self elm.OnEnter = function(self) - evolve:SetSetting(name, elm:GetValue()) - evolve:SendSettings() + 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", + value = 0, + 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 ) @@ -198,9 +272,9 @@ function TAB:CreateBool( pnl, name, item ) pnl.CheckBox = elm -- boring handler overloading + local parent = self elm.OnChange = function(self) - evolve:SetSetting(name, elm:GetValue()) - evolve:SendSettings() + evolve:SetSetting(name, self:GetChecked()) end return pnl @@ -208,7 +282,7 @@ end --[[TAB:Update()]] -function TAB:BuildCategories( atree, acat, aset, adepth ) +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 ) @@ -216,10 +290,9 @@ function TAB:BuildCategories( atree, acat, aset, adepth ) ]] --self:BuildCategories2( self.SettingsTree, evolve.settings, self.Categories ) --self:BuildCategories( self.SettingsTree, evolve.settings, self.Categories ) - print("DEBUG: BuildCategories2 -- entering") + --print("DEBUG: BuildCategories2 -- entering") local tree = atree - local cat = acat local set = aset local path = {} --[[if type(apath)=="string" then @@ -232,41 +305,37 @@ function TAB:BuildCategories( atree, acat, aset, adepth ) end]] local depth = adepth or 1 if adepth~= nil then - print("DEBUG: BuildCategories2 -- 'adepth' wasn't nil, incrementing.") + --print("DEBUG: BuildCategories2 -- 'adepth' wasn't nil, incrementing.") depth = adepth+1 else - print("DEBUG: BuildCategories2 -- 'adepth' was nil, at entrypoint depth.") + --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.") + --print("DEBUG: BuildCategories2 -- Investigating tree.") --PrintTable(tree) if tree.nodes==nil then - print("DEBUG: BuildCategories2 -- 1: Tree @ depth has no nodes, adding node stub.") + --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.") + --print("DEBUG: BuildCategories2 -- 2: Tree @ depth has nodes, we must be in an item with multiple children.") end - assert(istable(cat), "GOT NON-TABLE CATEGORY NODE") - print("DEBUG: BuildCategories2 -- Investigating cat shaped like: ") - PrintTable(cat) - if cat.nodes==nil then - print("DEBUG: BuildCategories2 -- 1: Cat @ depth has no nodes, adding node stub.") - cat.nodes={} - else - print("DEBUG: BuildCategories2 -- 2: Cat @ depth has nodes, we must be in an item with multiple children.") + 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) + --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.."' ...") + --print("DEBUG: BuildCategories2 -- Ignoring malformed element '"..k.."' ...") else - print("DEBUG: BuildCategories2 -- Inside setting '"..v.label.."' of type '"..v.stype.."'...") + --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" ) @@ -275,16 +344,16 @@ function TAB:BuildCategories( atree, acat, aset, adepth ) local parent = self node.DoClick = function(self) - print("doclick: "..v.label.." got clicked on @ depth # "..depth) + --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") + --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") + --print("doclick: couldn't find attribute ej_parent, assumed done") brk = false end work = work:GetParentNode() @@ -294,80 +363,89 @@ function TAB:BuildCategories( atree, acat, aset, adepth ) -- add tree child tree.nodes[v.label] = node - cat.nodes[v.label] = v.value --assign category as a reference to the position in evolve.settings - print("DEBUG: BuildCategories2 -- Recursing!!!") - self:BuildCategories( tree.nodes[v.label], cat.nodes[v.label], v.value, depth ) - print("DEBUG: BuildCategories2 -- Returned from recursion!!!") + --print("DEBUG: BuildCategories2 -- Recursing!!!") + self:BuildCategories( tree.nodes[v.label], v.value, depth ) + --print("DEBUG: BuildCategories2 -- Returned from recursion!!!") else - print("DEBUG: BuildCategories2 -- Ignoring non-category '"..v.label.."' of type '"..v.stype.."'.") + 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.."'") + --print("DEBUG: BuildCategories2 -- Iterated over all items at current depth of '"..depth.."'") end function TAB:BuildSettings( tblPath ) - print("DEBUG: BuildSettings -- entering...") + --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.") + --print("DEBUG: BuildSettings -- existing control '"..k.."' moved to grave.") v:SetParent(self.GraveYard) elseif v:GetParent() == self.GraveYard then - print("DEBUG: BuildSettings -- control '"..k.."' was already in the grave.") + --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.") + --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.Categories + 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, "\\")..")") + --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, "\\")..")") + --print("DEBUG: BuildSettings -- settings=self.Categories."..v.."==nil; BREAK ("..table.concat(tblPath, "\\")..")") end - print("DEBUG: Dumping contents of 'settings'.") - PrintTable(settings) + --print("DEBUG: Dumping contents of 'settings'.") + --PrintTable(settings) - for k,v in pairs(settings) do - if k~='nodes' then - if self.Controls[k]~=nil then - print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") - self.Controls[k]:SetParent(self.Layout) + for k,v in pairs(settings.items) do + if self.Controls[v]~=nil then + --print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") + self.Controls[v]:SetParent(self.Layout) + else + 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 + print("CREATING A BOOL, HOO BABY!") + PrintTable(item) + temp = self:CreateBool( step, v, item ) else - print("DEBUG: BuildSettings -- created new element stub: '"..k.."'") - local step = vgui.Create( "DPanel", self.Layout ) - step:SetWide( self.Layout:GetWide() ) - step:SetTall(32) - - if v.stype == 'limit' then - self.Controls[k] = self:CreateLimit( step, k, v ) - elseif v.stype == 'string' then - self.Controls[k] = self:CreateString( step, k, v ) - elseif v.stype == 'bool' then - self.Controls[k] = self:CreateBool( step, k, v ) - else - print("IGNORED ELEMENT OF TYPE '"..v.stype.."', REMOVING STUB") - step:Remove() - end - print("DEBUG: BuildSettings -- finalized element: '"..k.."'") + -- 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 end @@ -409,7 +487,7 @@ function TAB:Initialize( pnl ) 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 + --print( 'SETTINGS SEARCH: '..self:GetValue() ) -- print the form's text as server text end self:SetFocusCallbacks( self.SearchBox ) @@ -441,7 +519,7 @@ function TAB:Initialize( pnl ) 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()-18) + self.Layout:SetWide(self.Scroll:GetWide()-20) --self.Layout:SetPos(0, 0) self.Layout:SetSpaceX(0) self.Layout:SetSpaceY(5) @@ -451,8 +529,8 @@ function TAB:Initialize( pnl ) self.GraveYard:SetSize( 0, 0 ) self.GraveYard:SetPos(-1000, -1000) - self:BuildCategories( self.SettingsTree, self.Categories, evolve.settings ) - self:OpenToPath( {"General", "Misc"} ) + self:BuildCategories( self.SettingsTree, evolve.settingsStructure ) + self:OpenToPath( {"Plugins", "Sandbox"} ) end evolve:RegisterTab( TAB ) \ No newline at end of file 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_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_sandbox.lua b/lua/ev_plugins/sh_sandbox.lua new file mode 100644 index 0000000..4fc3ed2 --- /dev/null +++ b/lua/ev_plugins/sh_sandbox.lua @@ -0,0 +1,218 @@ +/*------------------------------------------------------------------------------------------------------------------------- + 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", + value = 150, + min = 0, + max = 200, + default = 150, + isconvar = true, + }, + sbox_maxragdolls = { + label = "Ragdolls", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxvehicles = { + label = "Vehicles", + desc = "Max number of props.", + stype = "limit", + value = 6, + min = 0, + max = 200, + default = 6, + isconvar = true, + }, + sbox_maxeffects = { + label = "Effects", + desc = "Max number of props.", + stype = "limit", + value = 50, + min = 0, + max = 200, + default = 50, + isconvar = true, + }, + sbox_maxballoons = { + label = "Balloons", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxnpcs = { + label = "NPCs", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxdynamite = { + label = "Dynamite", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, + sbox_maxlamps = { + label = "Lamps", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxlights = { + label = "Lights", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxwheels = { + label = "Wheels", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxthrusters = { + label = "Thrusters", + desc = "Max number of props.", + stype = "limit", + value = 30, + min = 0, + max = 200, + default = 30, + isconvar = true, + }, + sbox_maxhoverballs = { + label = "Hoverballs", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxbuttons = { + label = "Buttons", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, + sbox_maxemitters = { + label = "Emitters", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, + sbox_maxspawners = { + label = "Spawners", + desc = "Max number of props.", + stype = "limit", + value = 100, + min = 0, + max = 200, + default = 100, + isconvar = true, + }, + sbox_maxturrets = { + label = "Turrets", + desc = "Max number of props.", + stype = "limit", + value = 100, + min = 0, + max = 200, + default = 100, + isconvar = true, + }, + + sbox_godmode = { + label = "Godmode", + desc = "Toggle godmode globally.", + stype = "bool", + value = false, + default = false, + isconvar = true, + }, + sbox_noclip = { + label = "Noclip", + desc = "Toggle the ability to use noclip.", + stype = "bool", + value = false, + default = false, + isconvar = true, + }, + sbox_playershurtplayers = { + label = "PvP", + desc = "Toggle player vs player damage.", + stype = "bool", + value = true, + default = true, + isconvar = true, + }, + sbox_weapons = { + label = "Weapons", + desc = "Toggle the usage of weapons. Won't do much in DarkRP.", + stype = "bool", + value = true, + default = true, + isconvar = true, + }, + g_ragdoll_maxcount = { + label = "Keep NPC bodies", + desc = "Toggle.", + stype = "bool", + value = 0, + default = 0, + multiplier = 8, + isconvar = true, + }, +} + +evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_sv_init.lua b/lua/ev_sv_init.lua index cf0e0e5..d5f422b 100644 --- a/lua/ev_sv_init.lua +++ b/lua/ev_sv_init.lua @@ -7,6 +7,7 @@ print( " Evolve 1.0 by Overv succesfully started serverside." ) print( "=====================================================\n" ) evolve:LoadPlugins() +evolve:LoadSettings() --@DEV: We have to do this here so that we know how to behave elsewhere. // Tell the clients Evolve is installed on the server hook.Add( "PlayerSpawn", "EvolveInit", function( ply ) From 5d9d297ad496262dea71c793910976776f3632e1 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sun, 28 Sep 2014 10:45:36 -0400 Subject: [PATCH 30/52] Added alternative to +ev_menu with ev_menu_toggle. Fixed potential bug with search button having difficulties locating the searchbox relative to itself. --- lua/ev_menu/cl_menu.lua | 14 +++++++++++++- lua/ev_menu/tab_settings.lua | 21 ++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) 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_settings.lua b/lua/ev_menu/tab_settings.lua index 919e319..38ce5cd 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -4,14 +4,17 @@ --[[ @TODO: settings in general - * Put the console var handling general code into SetSetting? - * Implement setting domains (server/client/shared -- do domain checks so that one user can't overwrite the settings of another with higher privs) - * Bind settings to permissions. - * Implement string validators. - * 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 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 the menu have more methods to call on registered TABs, Open, Close, Hide + * make autocomplete wrap spaces around a name with spaces in it + * make FindPlayers match registered users that are offline ]] local TAB = {} @@ -499,8 +502,8 @@ function TAB:Initialize( pnl ) self.SearchButton:SetImage( "icon16/find.png" ) self.SearchButton:SetText( "" ) self.SearchButton:SetTooltip( "Press to search settings." ) - self.SearchButton.DoClick = function(self) - self:GetParent().SearchBox:OnEnter() + self.SearchButton.DoClick = function() + self.SearchBox:OnEnter() end self.SettingsTree = vgui.Create( "DTree", self.SearchPanel ) From a8dc8955d4dc28c8454b997564de2c50e2650370 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sun, 28 Sep 2014 10:54:59 -0400 Subject: [PATCH 31/52] Cleaned up whitespace to match the existing standard. My IDE (ZeroBrane) was set to not show tabs and defaulted to two spaces. --- lua/ev_framework.lua | 318 +++++++------- lua/ev_menu/tab_settings.lua | 783 +++++++++++++++++----------------- lua/ev_plugins/sh_armor.lua | 18 +- lua/ev_plugins/sh_sandbox.lua | 366 ++++++++-------- 4 files changed, 746 insertions(+), 739 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 9698c92..8ecb211 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -27,21 +27,21 @@ 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 = {} - } + 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.version = 179 @@ -55,7 +55,7 @@ if SERVER then util.AddNetworkString("EV_PluginFile") util.AddNetworkString("EV_Privilege") util.AddNetworkString("EV_Rank") - util.AddNetworkString("EV_Settings") + util.AddNetworkString("EV_Settings") util.AddNetworkString("EV_RankPrivileges") util.AddNetworkString("EV_RenameRank") util.AddNetworkString("EV_RankPrivilege") @@ -184,7 +184,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 @@ -267,7 +267,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 + if ( plugin.Settings ) then evolve:RegisterPluginSettings( plugin ) end else table.insert( evolve.plugins, { Title = plugin.Title, File = pluginFile } ) end @@ -1196,163 +1196,163 @@ end -------------------------------------------------------------------------------------------------------------------------*/ --[[ - todo: - declare setting types, - add some junk in PLUGIN and TAB loading for settings - allow for user-specific settings - LOCK THIS WAY DOWN + todo: + declare setting types, + add some junk in PLUGIN and TAB loading for settings + allow for user-specific settings + LOCK THIS WAY DOWN ]] if CLIENT then - 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 - --@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 + 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 + --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 end 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 + 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") - net.WriteTable(evolve.settings) - if CLIENT then - net.SendToServer() - elseif SERVER and ply then - net.Send(ply) - elseif SERVER then - net.Broadcast() - end - return true -end - + if CLIENT and !LocalPlayer():EV_HasPrivilege( "Settings: Send To Server" ) then return false end + net.Start("EV_Settings") + net.WriteString("save") + net.WriteTable(evolve.settings) + if CLIENT then + net.SendToServer() + elseif SERVER and ply then + net.Send(ply) + elseif SERVER then + net.Broadcast() + end + return true +end + function evolve:SaveSettings() - -- will probably have a client version at some point - file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) + -- will probably have a client version at some point + file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) end if SERVER then - function evolve:LoadSettings() - if ( file.Exists( "ev_settings.txt", "DATA" ) ) then - evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) - end - - --@TODO: do some validaiton here I guess, we would use SetSetting but you know - for k,v in pairs(evolve.settings) do - if ConVarExists(k) then - --@TODO: Don't load setting if convar already set to that value. - RunConsoleCommand("ev", "convar", k, v.value) - else - end - end - end - - net.Receive( "EV_Settings", function( length, ply ) - -- on = sending, off = requesting - local doit = net.ReadString() - print("GOT NETWORK MESSAGE: "..doit) - if ( IsValid( ply ) and ply:IsPlayer() ) then - if doit == "save" then - if ply:EV_HasPrivilege( "Settings: Send To Server" ) then - local sets = net.ReadTable() - --@TODO: do a step-by-step validation of the settings instead of global overwrite - evolve.settings = sets - 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-32) --@TODO: assumes strings are 4 bytes, ergo 32 bits - end - elseif doit == "send" then - evolve:SendSettings(ply) - end - end + function evolve:LoadSettings() + if ( file.Exists( "ev_settings.txt", "DATA" ) ) then + evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) + end + + --x@TODO: do some validaiton here I guess, we would use SetSetting but you know + for k,v in pairs(evolve.settings) do + if ConVarExists(k) then + --x@TODO: Don't load setting if convar already set to that value. + RunConsoleCommand("ev", "convar", k, v.value) + else + end + end + end + + net.Receive( "EV_Settings", function( length, ply ) + -- on = sending, off = requesting + local doit = net.ReadString() + print("GOT NETWORK MESSAGE: "..doit) + if ( IsValid( ply ) and ply:IsPlayer() ) then + if doit == "save" then + if ply:EV_HasPrivilege( "Settings: Send To Server" ) then + local sets = net.ReadTable() + --x@TODO: do a step-by-step validation of the settings instead of global overwrite + evolve.settings = sets + 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-32) --x@TODO: assumes strings are 4 bytes, ergo 32 bits + 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 - - net.Receive( "EV_Settings", function( length ) - -- on = sending, off = requesting - local doit = net.ReadString() - if doit == "save" then - evolve.settings = net.ReadTable() - elseif doit == "send" then - evolve:SendSettings() - end + function evolve:GetSettings() + net.Start("EV_Settings") + net.WriteString("send") -- request from server + net.SendToServer() + end + + net.Receive( "EV_Settings", function( length ) + -- on = sending, off = requesting + local doit = net.ReadString() + if doit == "save" then + evolve.settings = net.ReadTable() + 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 - if mergepoint[k] == nil then - mergepoint[k] = v - end - end - end + for k,v in pairs(settings) do + if v.stype == "category" then + evolve:RecurseRegister( evolve.settings, v.value ) + else + if mergepoint[k] == nil then + mergepoint[k] = v + end + end + end end function evolve:RegisterSettings( sets ) - table.Merge(evolve.settingsStructure, sets) - evolve:RecurseRegister(evolve.settings, sets) - return evolve.settings + 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 - if evolve.settings[k] == nil then - evolve.settings[k] = v - end - end + 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 + if evolve.settings[k] == nil then + evolve.settings[k] = v + end + end end @@ -1426,10 +1426,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 + --@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/tab_settings.lua b/lua/ev_menu/tab_settings.lua index 38ce5cd..9a9a254 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -3,18 +3,18 @@ -------------------------------------------------------------------------------------------------------------------------*/ --[[ - @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 + @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 = {} @@ -32,10 +32,10 @@ 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'] + 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 @@ -45,7 +45,7 @@ TAB.GraveYard = nil TAB.Controls = {} --[[ this is mapped: - global['num_corns'] + global['num_corns'] ]] local testsettings = { @@ -62,67 +62,74 @@ local testsettings = { icon = 'rainbow', value = { num_corns = { - label = 'No. Corns', - desc = 'How many corns? This many.', - stype = 'limit', - value = 50, - min = 25, - max = 75, - default = 30}, + label = 'No. Corns', + desc = 'How many corns? This many.', + stype = 'limit', + value = 50, + min = 25, + max = 75, + default = 30 + }, num_horns = { - label = 'No. Horns', - desc = 'Remember, we are on a budget.', - stype = 'limit', - value = 1, - min = -3, - max = 30, - default = 2}, + label = 'No. Horns', + desc = 'Remember, we are on a budget.', + stype = 'limit', + value = 1, + min = -3, + max = 30, + default = 2 + }, resync_name = { - label = 'Sync Again Label', - desc = 'Can you not decide what to call it?', - stype = 'string', - value = 'reSync', - default = 'ReSync'}, + label = 'Sync Again Label', + desc = 'Can you not decide what to call it?', + stype = 'string', + value = 'reSync', + default = 'ReSync' + }, best_name = { - label = 'Best Name', - desc = 'Who is the best?', - stype = 'string', - value = 'Bungalo', - default = 'EntranceJew'}, + label = 'Best Name', + desc = 'Who is the best?', + stype = 'string', + value = 'Bungalo', + default = 'EntranceJew' + }, is_great = { - label = 'Is Great', - desc = 'Are you having trouble finding out?', - stype = 'bool', - value = true, - default = false}, + label = 'Is Great', + desc = 'Are you having trouble finding out?', + stype = 'bool', + value = true, + default = false + }, }, - }, - category_settings = { + }, + 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', - value = true, - default = false}, + label = 'Overload server.cfg', + desc = 'If enabled, this will the LoadSettings to execute after server.cfg -- overwriting any values defined there.', + stype = 'bool', + value = true, + default = false + }, }, }, - category_hud = { + category_hud = { label = 'HUD', desc = "Specially modify how your HUD controls.", stype = 'category', icon = 'overlays', value = { hud_noises = { - label = 'HUD Sounds', - desc = 'If enabled, this will play beepy noises when your hud monitors get dangerously low.', - stype = 'bool', - value = true, - default = true}, + label = 'HUD Sounds', + desc = 'If enabled, this will play beepy noises when your hud monitors get dangerously low.', + stype = 'bool', + value = true, + default = true + }, }, }, }, @@ -131,10 +138,10 @@ local testsettings = { for i=1,16 do local set = { label = 'Test Setting #'..i, - desc = 'Testing out item '..i..', huh?', - stype = 'bool', - value = true, - default = false + desc = 'Testing out item '..i..', huh?', + stype = 'bool', + value = true, + default = false } testsettings.category_general.value.category_misc.value["test_set"..i]=set @@ -148,318 +155,318 @@ 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 + --@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.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: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 + 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 + 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", - value = 0, - 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 + --[[ + g_ragdoll_maxcount = { + label = "Keep NPC bodies", + desc = "Toggle.", + stype = "bool", + value = 0, + 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) + --[[ 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.") + --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) + --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: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 + 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: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.."'") + --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) - 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 + --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) + 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, "\\")..")") + --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, "\\")..")") + -- 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) + --print("DEBUG: Dumping contents of 'settings'.") + --PrintTable(settings) for k,v in pairs(settings.items) do - if self.Controls[v]~=nil then - --print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") - self.Controls[v]:SetParent(self.Layout) - else - 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 - print("CREATING A BOOL, HOO BABY!") - PrintTable(item) - temp = self:CreateBool( 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 + if self.Controls[v]~=nil then + --print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") + self.Controls[v]:SetParent(self.Layout) + else + 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 + print("CREATING A BOOL, HOO BABY!") + PrintTable(item) + temp = self:CreateBool( 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 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 + 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 ) @@ -477,63 +484,63 @@ 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 ) + 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.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.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: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 ) - self:OpenToPath( {"Plugins", "Sandbox"} ) + + -- 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 ) + self:OpenToPath( {"Plugins", "Sandbox"} ) end evolve:RegisterTab( TAB ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_armor.lua b/lua/ev_plugins/sh_armor.lua index 2a3d3af..6ff8b80 100644 --- a/lua/ev_plugins/sh_armor.lua +++ b/lua/ev_plugins/sh_armor.lua @@ -11,15 +11,15 @@ PLUGIN.Usage = "[players] [armor]" PLUGIN.Privileges = { "Armor" } PLUGIN.Icon = 'shield' PLUGIN.Settings = { - max_armor = { - label = 'Max Armor', - desc = 'Source Engine overflow Prevention', - stype = 'limit', - value = 100, - min = 100, - max = 255, - default = 150 - }, + max_armor = { + label = 'Max Armor', + desc = 'Source Engine overflow Prevention', + stype = 'limit', + value = 100, + min = 100, + max = 255, + default = 150 + }, } function PLUGIN:Call( ply, args ) diff --git a/lua/ev_plugins/sh_sandbox.lua b/lua/ev_plugins/sh_sandbox.lua index 4fc3ed2..42e50dc 100644 --- a/lua/ev_plugins/sh_sandbox.lua +++ b/lua/ev_plugins/sh_sandbox.lua @@ -11,208 +11,208 @@ PLUGIN.Usage = nil PLUGIN.Privileges = { "Sandbox Settings" } PLUGIN.Icon = "world" PLUGIN.Settings = { - sbox_maxprops = { - label = "Props", - desc = "Max number of props.", - stype = "limit", - value = 150, - min = 0, - max = 200, - default = 150, - isconvar = true, - }, + sbox_maxprops = { + label = "Props", + desc = "Max number of props.", + stype = "limit", + value = 150, + min = 0, + max = 200, + default = 150, + isconvar = true, + }, sbox_maxragdolls = { - label = "Ragdolls", - desc = "Max number of props.", - stype = "limit", - value = 5, - min = 0, - max = 200, - default = 5, - isconvar = true, - }, + label = "Ragdolls", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, sbox_maxvehicles = { - label = "Vehicles", - desc = "Max number of props.", - stype = "limit", - value = 6, - min = 0, - max = 200, - default = 6, - isconvar = true, - }, + label = "Vehicles", + desc = "Max number of props.", + stype = "limit", + value = 6, + min = 0, + max = 200, + default = 6, + isconvar = true, + }, sbox_maxeffects = { - label = "Effects", - desc = "Max number of props.", - stype = "limit", - value = 50, - min = 0, - max = 200, - default = 50, - isconvar = true, - }, + label = "Effects", + desc = "Max number of props.", + stype = "limit", + value = 50, + min = 0, + max = 200, + default = 50, + isconvar = true, + }, sbox_maxballoons = { - label = "Balloons", - desc = "Max number of props.", - stype = "limit", - value = 10, - min = 0, - max = 200, - default = 10, - isconvar = true, - }, + label = "Balloons", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, sbox_maxnpcs = { - label = "NPCs", - desc = "Max number of props.", - stype = "limit", - value = 10, - min = 0, - max = 200, - default = 10, - isconvar = true, - }, + label = "NPCs", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, sbox_maxdynamite = { - label = "Dynamite", - desc = "Max number of props.", - stype = "limit", - value = 10, - min = 0, - max = 200, - default = 10, - isconvar = true, - }, + label = "Dynamite", + desc = "Max number of props.", + stype = "limit", + value = 10, + min = 0, + max = 200, + default = 10, + isconvar = true, + }, sbox_maxlamps = { - label = "Lamps", - desc = "Max number of props.", - stype = "limit", - value = 20, - min = 0, - max = 200, - default = 20, - isconvar = true, - }, + label = "Lamps", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, sbox_maxlights = { - label = "Lights", - desc = "Max number of props.", - stype = "limit", - value = 5, - min = 0, - max = 200, - default = 5, - isconvar = true, - }, + label = "Lights", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, sbox_maxwheels = { - label = "Wheels", - desc = "Max number of props.", - stype = "limit", - value = 20, - min = 0, - max = 200, - default = 20, - isconvar = true, - }, + label = "Wheels", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, sbox_maxthrusters = { - label = "Thrusters", - desc = "Max number of props.", - stype = "limit", - value = 30, - min = 0, - max = 200, - default = 30, - isconvar = true, - }, + label = "Thrusters", + desc = "Max number of props.", + stype = "limit", + value = 30, + min = 0, + max = 200, + default = 30, + isconvar = true, + }, sbox_maxhoverballs = { - label = "Hoverballs", - desc = "Max number of props.", - stype = "limit", - value = 20, - min = 0, - max = 200, - default = 20, - isconvar = true, - }, + label = "Hoverballs", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, sbox_maxbuttons = { - label = "Buttons", - desc = "Max number of props.", - stype = "limit", - value = 20, - min = 0, - max = 200, - default = 20, - isconvar = true, - }, + label = "Buttons", + desc = "Max number of props.", + stype = "limit", + value = 20, + min = 0, + max = 200, + default = 20, + isconvar = true, + }, sbox_maxemitters = { - label = "Emitters", - desc = "Max number of props.", - stype = "limit", - value = 5, - min = 0, - max = 200, - default = 5, - isconvar = true, - }, + label = "Emitters", + desc = "Max number of props.", + stype = "limit", + value = 5, + min = 0, + max = 200, + default = 5, + isconvar = true, + }, sbox_maxspawners = { - label = "Spawners", - desc = "Max number of props.", - stype = "limit", - value = 100, - min = 0, - max = 200, - default = 100, - isconvar = true, - }, + label = "Spawners", + desc = "Max number of props.", + stype = "limit", + value = 100, + min = 0, + max = 200, + default = 100, + isconvar = true, + }, sbox_maxturrets = { - label = "Turrets", - desc = "Max number of props.", - stype = "limit", - value = 100, - min = 0, - max = 200, - default = 100, - isconvar = true, - }, - - sbox_godmode = { - label = "Godmode", - desc = "Toggle godmode globally.", - stype = "bool", - value = false, - default = false, - isconvar = true, - }, + label = "Turrets", + desc = "Max number of props.", + stype = "limit", + value = 100, + min = 0, + max = 200, + default = 100, + isconvar = true, + }, + + sbox_godmode = { + label = "Godmode", + desc = "Toggle godmode globally.", + stype = "bool", + value = false, + default = false, + isconvar = true, + }, sbox_noclip = { - label = "Noclip", - desc = "Toggle the ability to use noclip.", - stype = "bool", - value = false, - default = false, - isconvar = true, - }, + label = "Noclip", + desc = "Toggle the ability to use noclip.", + stype = "bool", + value = false, + default = false, + isconvar = true, + }, sbox_playershurtplayers = { - label = "PvP", - desc = "Toggle player vs player damage.", - stype = "bool", - value = true, - default = true, - isconvar = true, - }, + label = "PvP", + desc = "Toggle player vs player damage.", + stype = "bool", + value = true, + default = true, + isconvar = true, + }, sbox_weapons = { - label = "Weapons", - desc = "Toggle the usage of weapons. Won't do much in DarkRP.", - stype = "bool", - value = true, - default = true, - isconvar = true, - }, + label = "Weapons", + desc = "Toggle the usage of weapons. Won't do much in DarkRP.", + stype = "bool", + value = true, + default = true, + isconvar = true, + }, g_ragdoll_maxcount = { - label = "Keep NPC bodies", - desc = "Toggle.", - stype = "bool", - value = 0, - default = 0, - multiplier = 8, - isconvar = true, - }, + label = "Keep NPC bodies", + desc = "Toggle.", + stype = "bool", + value = 0, + default = 0, + multiplier = 8, + isconvar = true, + }, } evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file From b47fb2b58d3a68b19fe65b7c16208bdcc7974152 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sun, 28 Sep 2014 11:37:35 -0400 Subject: [PATCH 32/52] Added a proper TAB:Update() method that should be capable of refreshing any elements that changed since it was last opened. The GraveYard should be antiquated by now but I haven't tested that. --- lua/ev_menu/tab_settings.lua | 68 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua index 9a9a254..b091607 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -41,6 +41,8 @@ TAB.Scroll = nil TAB.Layout = nil TAB.GraveYard = nil +TAB.CurrentTree = {"Plugins", "Sandbox"} + TAB.Controls = {} --[[ @@ -368,6 +370,7 @@ function TAB:BuildCategories( atree, aset, adepth ) end work = work:GetParentNode() end + parent.CurrentTree = dpath parent:BuildSettings( dpath ) end @@ -394,6 +397,8 @@ function TAB:BuildSettings( tblPath ) 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 @@ -424,39 +429,35 @@ function TAB:BuildSettings( tblPath ) --PrintTable(settings) for k,v in pairs(settings.items) do - if self.Controls[v]~=nil then - --print("DEBUG: BuildSettings -- reassigned parent of existing element: '"..k.."'") - self.Controls[v]:SetParent(self.Layout) + --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 + print("CREATING A BOOL, HOO BABY!") + PrintTable(item) + temp = self:CreateBool( step, v, item ) else - 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 - print("CREATING A BOOL, HOO BABY!") - PrintTable(item) - temp = self:CreateBool( 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.."'") + -- 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 @@ -540,7 +541,10 @@ function TAB:Initialize( pnl ) self.GraveYard:SetPos(-1000, -1000) self:BuildCategories( self.SettingsTree, evolve.settingsStructure ) - self:OpenToPath( {"Plugins", "Sandbox"} ) +end + +function TAB:Update() + self:OpenToPath( self.CurrentTree ) end evolve:RegisterTab( TAB ) \ No newline at end of file From 6d603914d2bba372e07f0e84ab51b3c16a16f44d Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sun, 28 Sep 2014 12:09:44 -0400 Subject: [PATCH 33/52] When doing evolve:LoadSettings() the server will no longer overwrite ConVars that are equal to the loaded value. Scoped evolve:SaveSettings() to the server. Combined the two CLIENT code branches. --- lua/ev_framework.lua | 74 +++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 8ecb211..d97284e 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1202,36 +1202,6 @@ end allow for user-specific settings LOCK THIS WAY DOWN ]] -if CLIENT then - 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 - --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 -end function evolve:GetSetting( name, default ) if evolve.settings[name] == nil then return default @@ -1257,11 +1227,6 @@ function evolve:SendSettings( ply ) end return true end - -function evolve:SaveSettings() - -- will probably have a client version at some point - file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) -end if SERVER then function evolve:LoadSettings() @@ -1271,18 +1236,20 @@ if SERVER then --x@TODO: do some validaiton here I guess, we would use SetSetting but you know for k,v in pairs(evolve.settings) do - if ConVarExists(k) then - --x@TODO: Don't load setting if convar already set to that value. + if ConVarExists(k) and GetConVarString(k)~=tostring(v.value) then RunConsoleCommand("ev", "convar", k, v.value) - else end end end + function evolve:SaveSettings() + -- will probably have a client version at some point + file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) + end net.Receive( "EV_Settings", function( length, ply ) -- on = sending, off = requesting local doit = net.ReadString() - print("GOT NETWORK MESSAGE: "..doit) + 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 @@ -1309,6 +1276,35 @@ elseif CLIENT then 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 + --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() From 1f69c0c8fe0ea22e4d3d3e783fc556f40895633f Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Sun, 28 Sep 2014 16:12:53 -0400 Subject: [PATCH 34/52] Added "color" as an option type. The generated control is a bit quirky for now. Properly measured the length of the networked table. --- lua/ev_framework.lua | 2 +- lua/ev_menu/tab_settings.lua | 95 ++++++++++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index d97284e..de158af 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1262,7 +1262,7 @@ if SERVER then 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-32) --x@TODO: assumes strings are 4 bytes, ergo 32 bits + net.ReadUInt(length-(8+string.len(doit)*8)) --8bits for every ASCII char. end elseif doit == "send" then evolve:SendSettings(ply) diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua index b091607..77c44d7 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -41,7 +41,7 @@ TAB.Scroll = nil TAB.Layout = nil TAB.GraveYard = nil -TAB.CurrentTree = {"Plugins", "Sandbox"} +TAB.CurrentTree = {"General", "Misc"} TAB.Controls = {} @@ -63,6 +63,14 @@ local testsettings = { 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, + value = Color( 0, 110, 160, 255 ), + default = Color( 0, 110, 160, 255 ), + }, num_corns = { label = 'No. Corns', desc = 'How many corns? This many.', @@ -137,7 +145,7 @@ local testsettings = { }, }, } -for i=1,16 do +--[[for i=1,16 do local set = { label = 'Test Setting #'..i, desc = 'Testing out item '..i..', huh?', @@ -147,7 +155,7 @@ for i=1,16 do } testsettings.category_general.value.category_misc.value["test_set"..i]=set -end +end]] evolve:RegisterSettings( testsettings ) @@ -155,6 +163,83 @@ 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 @@ -442,9 +527,9 @@ function TAB:BuildSettings( tblPath ) elseif item.stype == 'string' then temp = self:CreateString( step, v, item ) elseif item.stype == 'bool' then - print("CREATING A BOOL, HOO BABY!") - PrintTable(item) 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() From 32c6642d4c431efb3c108ece872a51c7860da7d8 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Mon, 29 Sep 2014 07:32:36 -0400 Subject: [PATCH 35/52] Reduced network overhead by only sending setting key-values instead of full signatures. Loading/Saving settings now only stores key-values, like above. This could give way to collapsing evolve.settingsStructure into a simple signature compliment to a bare evolve.settings that is keyed only to its value. This would require a "path" element. --- lua/ev_framework.lua | 61 +++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index de158af..139fe53 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1217,7 +1217,11 @@ 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") - net.WriteTable(evolve.settings) + local loaded = {} + for k,v in pairs(evolve.settings) do + loaded[k] = v.value + end + net.WriteTable(loaded) if CLIENT then net.SendToServer() elseif SERVER and ply then @@ -1229,21 +1233,33 @@ function evolve:SendSettings( ply ) end if SERVER then - function evolve:LoadSettings() + function evolve:ClearSettings() if ( file.Exists( "ev_settings.txt", "DATA" ) ) then - evolve.settings = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) + file.Delete( "ev_settings.txt", "DATA" ) end - - --x@TODO: do some validaiton here I guess, we would use SetSetting but you know - for k,v in pairs(evolve.settings) do - if ConVarExists(k) and GetConVarString(k)~=tostring(v.value) then - RunConsoleCommand("ev", "convar", k, v.value) + --@TODO: Maybe make this rebuild evolve.settings? Not sure if we'd need that. + end + + function evolve:LoadSettings() + if ( file.Exists( "ev_settings.txt", "DATA" ) ) then + local loaded = von.deserialize( file.Read( "ev_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 - file.Write( "ev_settings.txt", von.serialize( evolve.settings ) ) + local loaded = {} + for k,v in pairs(evolve.settings) do + loaded[k] = v.value + end + file.Write( "ev_settings.txt", von.serialize(loaded) ) end net.Receive( "EV_Settings", function( length, ply ) @@ -1253,9 +1269,11 @@ if SERVER then if ( IsValid( ply ) and ply:IsPlayer() ) then if doit == "save" then if ply:EV_HasPrivilege( "Settings: Send To Server" ) then - local sets = net.ReadTable() + local loaded = net.ReadTable() + for k,v in pairs(loaded) do + evolve.settings[k].value = v + end --x@TODO: do a step-by-step validation of the settings instead of global overwrite - evolve.settings = sets evolve:SaveSettings() -- tell our clients that our settings changed evolve:SendSettings() @@ -1309,7 +1327,11 @@ elseif CLIENT then -- on = sending, off = requesting local doit = net.ReadString() if doit == "save" then - evolve.settings = net.ReadTable() + 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 @@ -1320,8 +1342,12 @@ function evolve:RecurseRegister( mergepoint, settings ) if v.stype == "category" then evolve:RecurseRegister( evolve.settings, v.value ) else - if mergepoint[k] == nil then + for k2,v2 in pairs(v) do + local prevalue = v.value mergepoint[k] = v + if prevalue~=nil then + mergepoint[k].value = prevalue + end end end end @@ -1345,8 +1371,13 @@ function evolve:RegisterPluginSettings( plugin ) value = value } for k,v in pairs( del['category_'..string.lower(label)].value ) do - if evolve.settings[k] == nil then - evolve.settings[k] = v + 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 end end end From 3e46302cb2e6bdb536c695f712ed70b2004923a5 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Mon, 29 Sep 2014 08:12:19 -0400 Subject: [PATCH 36/52] Removing propprotect and spawn protection plugins as they conflict with existing solutions for now. --- lua/ev_plugins/sh_propprotection.lua | 450 -------------------------- lua/ev_plugins/sh_spawnprotection.lua | 80 ----- 2 files changed, 530 deletions(-) delete mode 100644 lua/ev_plugins/sh_propprotection.lua delete mode 100644 lua/ev_plugins/sh_spawnprotection.lua diff --git a/lua/ev_plugins/sh_propprotection.lua b/lua/ev_plugins/sh_propprotection.lua deleted file mode 100644 index 593cfcf..0000000 --- a/lua/ev_plugins/sh_propprotection.lua +++ /dev/null @@ -1,450 +0,0 @@ -local PLUGIN = {} -PLUGIN.Title = "Prop Protection"; -PLUGIN.Description = "A Plugin to prevent minges from spawning blacklisted props and touching others props"; -PLUGIN.Author = "Northdegree"; -PLUGIN.Privileges = { "Can Spawn Blacklist", "Manage BlackList", "Can Touch WorldProps"}; -PLUGIN.ChatCommand = "friends" -PLUGIN.Usage = " (Name/SteamID)" -PP_Settings = {}; -PP_Blacklist = {}; - - -/*================ Add/Remove Func ==========================*/ -/*----------------------------------------------------- - -- FRIENDS -- - ---------------------------------------------------*/ -function PLUGIN:Call( ply, args ) - local action = args[1] - if action == "add" then - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findply = evolve:FindPlayer( args[2] ) - if ( #findply > 1 ) then - evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) - return - end - if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end - findply = findply[1] - if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You cant add yourself as your friend!\", NOTIFY_ERROR, 5)") return end - local findsteam = findply:SteamID() - local findname = findply:Nick() - if CheckFriendship(ply, findply) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is already in your Friendlist!\", NOTIFY_ERROR, 5)") return end - table.insert(ply.PP_Friends, {findsteam, findname}) - sql.Query("INSERT INTO `ev_pp_friends` (ply,friendid,friendname) VALUES ("..sql.SQLStr(ply:SteamID())..","..sql.SQLStr(findsteam)..","..sql.SQLStr(findname)..");") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been added to your Friendlist!\", NOTIFY_GENERIC, 5)") - findply:SendLua("GAMEMODE:AddNotify(\"You now can touch "..ply:Nick().."'s Props!\", NOTIFY_GENERIC, 5)") - elseif action == "remove" then - if string.match( args[2],"STEAM_[0-5]:[0-9]:[0-9]+") then - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findsteam = args[2] - if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\"This Player is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end - local findname = "" - for k,v in pairs(ply.PP_Friends) do - if v[1] == findsteam then - findname = v[2] - table.remove(ply.PP_Friends, k) - end - end - sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") - else - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findply = evolve:FindPlayer( args[2] ) - if ( #findply > 1 ) then - evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) - return - end - if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end - findply = findply[1] - if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You are not your own friend!\", NOTIFY_ERROR, 5)") return end - local findsteam = findply:SteamID() - local findname = findply:Nick() - if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end - for k,v in pairs(ply.PP_Friends) do - if v[1] == findsteam then - table.remove(ply.PP_Friends, k) - end - end - sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") - findply:SendLua("GAMEMODE:AddNotify(\"You can't touch "..ply:Nick().."'s Props anymore!\", NOTIFY_GENERIC, 5)") - end - else - if not ply.PP_Friends then ply.PP_Friends = {} end - evolve:Notify(ply, evolve.colors.blue, ply:Nick().."'s friendlist :") - for index,frply in pairs(ply.PP_Friends) do - evolve:Notify(ply, evolve.colors.blue, frply[2], evolve.colors.white, " ("..frply[1]..")") - end - evolve:Notify(ply, evolve.colors.blue, "-------------------------") - end -end - - - ---------------------------------------------------*/ -local function savePPSettings(ply, cmd, args) - for sname,setting in pairs(PP_Settings) do - if (ConVarExists("ev_"..sname)) then - sql.Query("UPDATE `ev_pp_settings` SET `"..sname.."`='"..GetConVar("ev_"..sname):GetString().."';") - end - end -end -concommand.Add("ev_pp_save_settings", savePPSettings) -timer.Create("PP Autosave",60,0,savePPSettings) -/*----------------------------------------------------- - -- Blacklist -- - ---------------------------------------------------*/ -local function PP_AddBlackList(ply, cmd, args) - if !ply:EV_HasPrivilege( "Manage BlackList" ) then ply:SendLua("GAMEMODE:AddNotify(\"You are not allowed to do that!\", NOTIFY_ERROR, 5)") return end - if not args[1] then ply:SendLua("GAMEMODE:AddNotify(\"Invalid Argument(s)\", NOTIFY_ERROR, 3)") return end - local model = string.lower(args[1]) - model = string.Replace(model, "\\", "/") - if table.HasValue(PP_Blacklist,model) then ply:SendLua("GAMEMODE:AddNotify(\"This Model is already Black-/Whitelisted!\", NOTIFY_ERROR, 5)") return end - table.insert(PP_Blacklist, model) - sql.Query("INSERT INTO `ev_pp_blacklist` (model) VALUES ("..sql.SQLStr(model)..");") - evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has added the Model ", evolve.colors.red, model, evolve.colors.white, " to the Black-/Whitelist." ) -end -concommand.Add("ev_pp_add_blacklist", PP_AddBlackList) - -local function PP_RemoveBlackList(ply, cmd, args) - if !ply:EV_HasPrivilege( "Manage BlackList" ) then ply:SendLua("GAMEMODE:AddNotify(\"You are not allowed to do that!\", NOTIFY_ERROR, 5)") return end - if not args[1] then ply:SendLua("GAMEMODE:AddNotify(\"Invalid Argument(s)\", NOTIFY_ERROR, 3)") return end - local model = string.lower(args[1]) - model = string.Replace(model, "\\", "/") - if !table.HasValue(PP_Blacklist,model) then ply:SendLua("GAMEMODE:AddNotify(\"This Model is not Black-/Whitelisted!\", NOTIFY_ERROR, 5)") return end - for k,v in pairs(PP_Blacklist) do - if v == model then - table.remove(PP_Blacklist, k) - end - end - sql.Query("DELETE FROM `ev_pp_blacklist` WHERE `model`="..sql.SQLStr(model)..";") - evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has removed the Model ", evolve.colors.red, model, evolve.colors.white, " from the Black-/Whitelist." ) -end -concommand.Add("ev_pp_Remove_blacklist", PP_RemoveBlackList) - -local function PP_GetBlackList(ply, cmd, args) - for k,model in pairs(PP_Blacklist) do - umsg.Start("ev_pp_blockedmodel", ply) - umsg.String(model) - umsg.End() - end -end -concommand.Add("ev_pp_get_blacklist", PP_GetBlackList) -/*================ Blacklist ==========================*/ - -function loadPPBlacklist() - sql.Query("SELECT * FROM `ev_pp_blacklist`", function(results) - if results then - for k,v in pairs(results) do - table.insert(PP_Blacklist, v.model) - end - end - end) -end -/*====================================================*/ -function CheckFriendship(ply,targetid) - if not ply.PP_Friends then ply.PP_Friends = {} end - local friends = false - for k,v in pairs(ply.PP_Friends) do - if v[1] == targetid then - friends = true - break - end - end - return friends -end -function loadPPFriends(ply) - local plysteamid = ply:SteamID() - sql.Query("SELECT * FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(plysteamid).."", function(results) - if results then - for k,v in pairs(results) do - local friendid = v.friendid - local friendname = v.friendname - table.insert(ply.PP_Friends, {friendid, friendname}) - end - end - end) -end - -/*================ SETTINGS ==========================*/ -function loadPPSettings() - local results=sql.Query("SELECT * FROM `ev_pp_settings`") - if results then - for k,v in pairs(results[1]) do - PP_Settings[k]=v - if v then - CreateConVar("ev_"..k,tonumber(v)) - end - end - else - sql.Query("INSERT INTO `ev_pp_settings` (ppison) VALUES ('1');"); // Creating default settings - sql.Query("INSERT INTO `ev_pp_settings` (blacklistison) VALUES ('0');"); // Creating default settings - sql.Query("INSERT INTO `ev_pp_settings` (blacklistiswhitelist) VALUES ('0');"); // Creating default settings - loadPPSettings(); - end -end -/*====================================================*/ -function FirstSpawn( ply ) - ply.PP_Friends = {} - loadPPFriends(ply) -end -hook.Add( "PlayerInitialSpawn", "PP_Friends_Load_On_Connect", FirstSpawn ) - -function PLUGIN:Initialize() - if SERVER then - /* CREATING ALL TABLES */ - if (!sql.TableExists("ev_pp_settings")) then - sql.Query("CREATE TABLE `ev_pp_settings` (`ppison` INT DEFAULT '1',`blacklistison` INT DEFAULT '1',`blackiswhitelist` INT DEFAULT '0',`highercantouchlowerrank` INT DEFAULT '1');") - end - if (!sql.TableExists("ev_pp_blacklist")) then - sql.Query("CREATE TABLE `ev_pp_blacklist` (`model` varchar(999));") - end - if (!sql.TableExists("ev_pp_friends")) then - sql.Query("CREATE TABLE `ev_pp_friends` (`ply` varchar(999),`friendid` varchar(999),`friendname` varchar(999));") - end - loadPPSettings(); - loadPPBlacklist(); - if FPP then - RunConsoleCommand("ev_ppison","0") - end - end -end -function CustInit() - if SERVER then - /* CREATING ALL TABLES */ - if (!sql.TableExists("ev_pp_settings")) then - sql.Query("CREATE TABLE `ev_pp_settings` (`ppison` INT DEFAULT '1',`blacklistison` INT DEFAULT '1',`blackiswhitelist` INT DEFAULT '0',`highercantouchlowerrank` INT DEFAULT '1');") - end - if (!sql.TableExists("ev_pp_blacklist")) then - sql.Query("CREATE TABLE `ev_pp_blacklist` (`model` varchar(999));") - end - if (!sql.TableExists("ev_pp_friends")) then - sql.Query("CREATE TABLE `ev_pp_friends` (`ply` varchar(999),`friendid` varchar(999),`friendname` varchar(999));") - end - loadPPSettings(); - loadPPBlacklist(); - if FPP then - RunConsoleCommand("ev_ppison","0") - end - end -end - -//======================== DONT EDIT SOMETHING BELOW THIS UNLESS YOU KNOW WHAT YOU DO!!! ========================================= -if SERVER then - hook.Add("PlayerSpawnProp", "PP_BLACKLIST_CHECK", function(ply, model) - /* -------------- BLACKLIST -------------- */ - if GetConVar("ev_blacklistison"):GetInt() == 1 then - if table.HasValue(PP_Blacklist,string.lower(model)) then - if GetConVar("ev_blackiswhitelist"):GetInt() == 0 then - if !ply:EV_HasPrivilege( "Can Spawn Blacklist" ) then - ply:SendLua("GAMEMODE:AddNotify(\"This Model is Blacklisted!\", NOTIFY_ERROR, 3)") - return false - else - return true - end - end - else - if GetConVar("ev_blackiswhitelist"):GetInt() == 1 then - if !ply:EV_HasPrivilege( "Can Spawn Blacklist" ) then - ply:SendLua("GAMEMODE:AddNotify(\"This Model is Blacklisted!\", NOTIFY_ERROR, 3)") - return false - else - return true - end - end - end - else - return true - end - end) - /* Physgun Pickup Control*/ - function PlayerPickup(ply, ent) - local owner = ent:GetNWEntity("Owner") - local steamid = ent:GetNWString("OwnerID") - local plysteam = ply:SteamID() - if !ent:IsPlayer() then - if (GetConVar("ev_ppison"):GetInt() == 0) or (IsValid(owner) and CheckFriendship(owner,plysteam)) or (steamid == "" and ply:EV_HasPrivilege("Can Touch WorldProps")) or CanTouch(ply, ent) then - if ply:EV_HasPrivilege("Can Touch WorldProps") and (steamid=="") then - return true - elseif (steamid!="") then - return true - else - return false - end - else - return false - end - end - end - hook.Add("PhysgunPickup", "PP_Physgun_Pickup", PlayerPickup) - function CusCanTool( ply, tr, 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 use this tool!" ) - return false - end - return true - end - - function UseTool(ply, trace, toolmode) - local ent = trace.Entity - local owner = ent:GetNWEntity("Owner") - local steamid = ent:GetNWString("OwnerID") - local plysteam = ply:SteamID() - if CusCanTool( ply, trace, toolmode) then - if (GetConVar("ev_ppison"):GetInt() == 0) or (IsValid(owner) and CheckFriendship(owner,plysteam)) or (!IsValid(owner) and steamid == "" and ply:EV_HasPrivilege("Can Touch WorldProps")) or CanTouch(ply, ent) or !IsValid(ent) then - return true - else - return false - end - else - if (ConVarExists("ev_restrict_tools")) then - if (GetConVarNumber("ev_restrict_tools")==0) then - return true - else - return false - end - else - return false - end - end - end - hook.Add("CanTool", "PP_ToolGun_Use", UseTool) -end -if cleanup then - oldcleanup = oldcleanup or cleanup.Add - function cleanup.Add(ply, Type, ent) - if IsValid(ply) and IsValid(ent) then - ent:SetNWEntity("Owner", ply) - ent:SetNWString("OwnerID", ply:SteamID()) - if ent:GetClass() == "gmod_wire_expression2" then - ent:SetCollisionGroup(COLLISION_GROUP_WEAPON) - end - end - return oldcleanup(ply, Type, ent) - end -end - - -function CanTouch(ply, ent) - local owner = ent:GetNWEntity("Owner") - if (ent:GetNWString("OwnerID") == ply:SteamID()) then - return true - else - if (SERVER and IsValid(owner) and ply:EV_BetterThan(owner) and GetConVar("ev_highercantouchlowerrank"):GetInt() == 1) then - return true - else - if !IsValid(owner) then - return true - else - return false - end - end - end -end -/* Show the Owner */ -if CLIENT then - local function HUDPaint() - local LookingEnt = LocalPlayer():GetEyeTraceNoCursor().Entity - local LEOwner = LookingEnt:GetNWString("OwnerID") - if LEOwner == "" then LEOwner = "World Prop" end - if IsValid(LookingEnt) and !LookingEnt:IsPlayer() then - local owner = LEOwner - if LEOwner != "World Prop" then - LEOwner = LookingEnt:GetNWEntity("Owner") - local k,v = pcall(function() - if !IsValid(LEOwner) then owner="Disconnected Player" else owner=LEOwner:Nick() end - end) - if !k then owner="Invalid Player" end - end - surface.SetFont("Default") - local w,h = surface.GetTextSize(owner) - local col = Color(255,0,0,255) - pcall( - function() - if CanTouch(LocalPlayer(),LookingEnt) then - col = Color(0,255,0,255) - else - col = Color(255,0,0,255) - end - end - ) - draw.RoundedBox(4, 5, ScrH()/2 - h - 2, w + 10, 20, Color(0, 0, 0, 110)) - draw.DrawText(owner, "Default", 7, ScrH()/2 - h, col, 0) - surface.SetDrawColor(255,255,255,255) - end - end - hook.Add("HUDPaint", "PP_Show_Owner", HUDPaint) -end -/*---------------Console Command*/ -function evPropParseCommand( ply, comm, args ) - local action = args[1] - if action == "add" then - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findply = evolve:FindPlayer( args[2] ) - if ( #findply > 1 ) then - evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) - return - end - if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end - findply = findply[1] - if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You cant add yourself as your friend!\", NOTIFY_ERROR, 5)") return end - local findsteam = findply:SteamID() - local findname = findply:Nick() - if CheckFriendship(ply, findply) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is already in your Friendlist!\", NOTIFY_ERROR, 5)") return end - table.insert(ply.PP_Friends, {findsteam, findname}) - sql.Query("INSERT INTO `ev_pp_friends` (ply,friendid,friendname) VALUES ("..sql.SQLStr(ply:SteamID())..","..sql.SQLStr(findsteam)..","..sql.SQLStr(findname)..");") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been added to your Friendlist!\", NOTIFY_GENERIC, 5)") - findply:SendLua("GAMEMODE:AddNotify(\"You now can touch "..ply:Nick().."'s Props!\", NOTIFY_GENERIC, 5)") - elseif action == "remove" then - if string.match( args[2],"STEAM_[0-5]:[0-9]:[0-9]+") then - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findsteam = args[2] - if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\"This Player is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end - local findname = "" - for k,v in pairs(ply.PP_Friends) do - if v[1] == findsteam then - findname = v[2] - table.remove(ply.PP_Friends, k) - end - end - sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") - else - if not ply.PP_Friends then ply.PP_Friends = {} end - if not args[2] then ply:SendLua("GAMEMODE:AddNotify(\"Missing Argument(s)\", NOTIFY_ERROR, 5)") return end - local findply = evolve:FindPlayer( args[2] ) - if ( #findply > 1 ) then - evolve:Notify( ply, evolve.colors.white, "Did you mean ", evolve.colors.red, evolve:CreatePlayerList( pl, true ), evolve.colors.white, "?" ) - return - end - if ( #findply == 0) then ply:SendLua("GAMEMODE:AddNotify(\""..args[2].." cannot be found!\", NOTIFY_ERROR, 5)") return end - findply = findply[1] - if ( findply == ply) then ply:SendLua("GAMEMODE:AddNotify(\"You are not your own friend!\", NOTIFY_ERROR, 5)") return end - local findsteam = findply:SteamID() - local findname = findply:Nick() - if !CheckFriendship(ply,findsteam) then ply:SendLua("GAMEMODE:AddNotify(\""..findname.." is not in your Friendlist!\", NOTIFY_ERROR, 5)") return end - for k,v in pairs(ply.PP_Friends) do - if v[1] == findsteam then - table.remove(ply.PP_Friends, k) - end - end - sql.Query("DELETE FROM `ev_pp_friends` WHERE `ply`="..sql.SQLStr(ply:SteamID()).." AND `friendid`="..sql.SQLStr(findsteam)..";") - ply:SendLua("GAMEMODE:AddNotify(\""..findname.." has been removed from your Friendlist!\", NOTIFY_GENERIC, 5)") - findply:SendLua("GAMEMODE:AddNotify(\"You can't touch "..ply:Nick().."'s Props anymore!\", NOTIFY_GENERIC, 5)") - end - else - if not ply.PP_Friends then ply.PP_Friends = {} end - evolve:Notify(ply, evolve.colors.blue, ply:Nick().."'s friendlist :") - for index,frply in pairs(ply.PP_Friends) do - evolve:Notify(ply, evolve.colors.blue, frply[2], evolve.colors.white, " ("..frply[1]..")") - end - evolve:Notify(ply, evolve.colors.blue, "-------------------------") - end -end - -concommand.Add("EvPropParseCon",evPropParseCommand) -CustInit() -evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file diff --git a/lua/ev_plugins/sh_spawnprotection.lua b/lua/ev_plugins/sh_spawnprotection.lua deleted file mode 100644 index 91bc46a..0000000 --- a/lua/ev_plugins/sh_spawnprotection.lua +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------------------------------------------------------- - NoRecoil a player --------------------------------------------------------------------------------------------------------------------------*/ - -local PLUGIN = {} -PLUGIN.Title = "Spawn Protection" -PLUGIN.Description = "Players with this permission have spawn protection." -PLUGIN.Author = "Grey" -PLUGIN.Usage = "none" -PLUGIN.Privileges = { "Spawn Protection" } -if SERVER then - local weps = {} - - local function Think() - for k,v in pairs(player.GetAll()) do - if weps[v] then - if v:GetActiveWeapon() && v:GetActiveWeapon():IsValid() && v:GetActiveWeapon() != weps[v] then - hook.Call("PlayerWeaponChanged", gmod.GetGamemode(), v, weps[v], v:GetActiveWeapon()) -- Params: Player (who changed the weapon), Weapon (weapon switch from), Weapon(weapon switched to) - weps[v] = v:GetActiveWeapon() - end - else - if v:GetActiveWeapon() && v:GetActiveWeapon():IsValid() then - weps[v] = v:GetActiveWeapon() - end - end - end - end - hook.Add("Think", "WeaponCheck.Think", Think) - function SPOnWeaponEquip( ply, oldwep, eqwep ) - if (!eqwep:IsWeapon()) then - return; - end - local wepname = string.lower(eqwep:GetClass()) - local hassp = ply:GetNWBool( "EV_SpawnProtected", false) - if (string.match(wepname,"weapon_physgun") or string.match(wepname,"gmod_tool") or string.match(wepname,"gmod_camera") or string.match(wepname,"toolgun") or string.match(wepname,"tool gun") or string.match(wepname,"physgun") or string.match(wepname,"physicsgun") or string.match(wepname,"physcannon") or string.match(wepname,"physicscannon")or string.match(wepname,"phys gun") or string.match(wepname,"physics gun")or string.match(wepname,"phys cannon") or string.match(wepname,"physics cannon")or string.match(wepname,"camera")) then - ply:SetNWBool( "EV_SpawnProtected", hassp ) - else - ply:SetNWBool( "EV_SpawnProtected", false ) - if (hassp == true) then - hassp = false - print("Spawn protection ended for "..ply:Nick()..".") - end - end - end - function SPOnSpawn( ply ) - if ( ply:EV_HasPrivilege( "Spawn Protection" ) ) then - ply:SetNWBool( "EV_SpawnProtected", true ) - timer.Simple(15, function() - if ply and ply:IsPlayer() then - local hassp = ply:GetNWBool( "EV_SpawnProtected", false) - if (hassp == true) then - ply:SetNWBool( "EV_SpawnProtected", false ) - print("Spawn protection ended for "..ply:Nick()..".") - end - end - end) - evolve:Notify( ply, evolve.colors.white, "Your spawn protection lasts for ", evolve.colors.red, " 15 seconds ", evolve.colors.white, " or until you draw a weapon.") - else - ply:SetNWBool( "EV_SpawnProtected", false ) - end - end - function SPShouldTakeDamage( ply, attacker) - if (ply:GetNWBool( "EV_SpawnProtected", false) == true) then - if attacker:IsPlayer() then - evolve:Notify( evolve.colors.red, attacker:Nick(), evolve.colors.white, " has attempted to spawnkill!" ) - local atwep = attacker:GetActiveWeapon() - if atwep:IsWeapon() then - local ammotype=atwep:GetPrimaryAmmoType( ) - attacker:RemoveAmmo(attacker:GetAmmoCount(ammotype),ammotype) - attacker:DropWeapon(atwep) - end - return false; - end - end - end - hook.Add("PlayerWeaponChanged","EVSpawnProtect_OnWeaponDraw",SPOnWeaponEquip) - hook.Add("PlayerSpawn","EVSpawnProtect_OnPlayerSpawn",SPOnSpawn) - hook.Add("PlayerShouldTakeDamage","EVSpawnProtect_OnPlayerDamage",SPShouldTakeDamage) -end -evolve:RegisterPlugin( PLUGIN ) \ No newline at end of file From ef9ea808573e0be192f11917d2084a05496a1555 Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Mon, 29 Sep 2014 12:05:21 -0400 Subject: [PATCH 37/52] Reduced network overhead by not sending entire settings table when a value is changed. Added evolve.settingsdelta that acts as a buffer of settings to be sent. This commit can be extended to only send settings changes in bulk, like when the client collapses the settings window / hits "save" or in timed intervals. --- lua/ev_framework.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 139fe53..6f16a4c 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -44,6 +44,7 @@ evolve.settingsStructure = { } } evolve.settings = {} +evolve.settingsdelta = {} evolve.version = 179 _R = debug.getregistry() @@ -1214,12 +1215,14 @@ function evolve:GetSetting( name, default ) end function evolve:SendSettings( ply ) - if CLIENT and !LocalPlayer():EV_HasPrivilege( "Settings: Send To Server" ) then return false end + 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.settings) do - loaded[k] = v.value + for k,v in pairs(evolve.settingsdelta) do + loaded[k] = v end net.WriteTable(loaded) if CLIENT then @@ -1229,6 +1232,7 @@ function evolve:SendSettings( ply ) elseif SERVER then net.Broadcast() end + evolve.settingsdelta={} return true end @@ -1262,15 +1266,15 @@ if SERVER then file.Write( "ev_settings.txt", von.serialize(loaded) ) end - net.Receive( "EV_Settings", function( length, ply ) + 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 - local loaded = net.ReadTable() - for k,v in pairs(loaded) do + 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 @@ -1316,6 +1320,7 @@ elseif CLIENT then 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 From ba0bb99634bc7cf2bbbf654be52526a2573c6d7a Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Wed, 1 Oct 2014 13:01:54 -0400 Subject: [PATCH 38/52] Removed all instances of "value" being assigned in a setting signature, opting to pull from the "default" attribute when registering. Made the map tab use the actual "map" icon. Made sandbox settings consistent with the Utilities menu option. Added Server Settings plugin. --- lua/ev_framework.lua | 4 ++ lua/ev_menu/tab_maps.lua | 2 +- lua/ev_menu/tab_settings.lua | 35 ++--------- lua/ev_plugins/sh_armor.lua | 13 ++-- lua/ev_plugins/sh_sandbox.lua | 88 ++++++++++++++++------------ lua/ev_plugins/sh_serversettings.lua | 65 ++++++++++++++++++++ 6 files changed, 133 insertions(+), 74 deletions(-) create mode 100644 lua/ev_plugins/sh_serversettings.lua diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 6f16a4c..ff70c0f 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1352,6 +1352,8 @@ function evolve:RecurseRegister( mergepoint, settings ) mergepoint[k] = v if prevalue~=nil then mergepoint[k].value = prevalue + else + mergepoint[k].value = mergepoint[k].default end end end @@ -1383,6 +1385,8 @@ function evolve:RegisterPluginSettings( plugin ) 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 diff --git a/lua/ev_menu/tab_maps.lua b/lua/ev_menu/tab_maps.lua index 9e07182..486c9a0 100644 --- a/lua/ev_menu/tab_maps.lua +++ b/lua/ev_menu/tab_maps.lua @@ -3,7 +3,7 @@ TAB.Title = "Maps" TAB.Description = "Change Map." TAB.Author = "Divran" TAB.Width = 520 -TAB.Icon = "world" +TAB.Icon = "map" function TAB:Update() end diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua index 77c44d7..ab67f44 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -68,47 +68,41 @@ local testsettings = { desc = '5/8ths of my friends have a form of color blindness.', stype = 'color', alpha = false, - value = Color( 0, 110, 160, 255 ), default = Color( 0, 110, 160, 255 ), }, num_corns = { label = 'No. Corns', desc = 'How many corns? This many.', stype = 'limit', - value = 50, min = 25, max = 75, - default = 30 + default = 50, }, num_horns = { label = 'No. Horns', desc = 'Remember, we are on a budget.', stype = 'limit', - value = 1, min = -3, max = 30, - default = 2 + default = 1, }, resync_name = { label = 'Sync Again Label', desc = 'Can you not decide what to call it?', stype = 'string', - value = 'reSync', - default = 'ReSync' + default = 'reSync', }, best_name = { label = 'Best Name', desc = 'Who is the best?', stype = 'string', - value = 'Bungalo', - default = 'EntranceJew' + default = 'Bungalo', }, is_great = { label = 'Is Great', desc = 'Are you having trouble finding out?', stype = 'bool', - value = true, - default = false + default = true, }, }, }, @@ -122,23 +116,7 @@ local testsettings = { label = 'Overload server.cfg', desc = 'If enabled, this will the LoadSettings to execute after server.cfg -- overwriting any values defined there.', stype = 'bool', - value = true, - default = false - }, - }, - }, - category_hud = { - label = 'HUD', - desc = "Specially modify how your HUD controls.", - stype = 'category', - icon = 'overlays', - value = { - hud_noises = { - label = 'HUD Sounds', - desc = 'If enabled, this will play beepy noises when your hud monitors get dangerously low.', - stype = 'bool', - value = true, - default = true + default = true, }, }, }, @@ -337,7 +315,6 @@ function TAB:CreateBool( pnl, name, item ) label = "Keep NPC bodies", desc = "Toggle.", stype = "bool", - value = 0, default = 0, multiplier = 8, isconvar = true, diff --git a/lua/ev_plugins/sh_armor.lua b/lua/ev_plugins/sh_armor.lua index 6ff8b80..ce907d0 100644 --- a/lua/ev_plugins/sh_armor.lua +++ b/lua/ev_plugins/sh_armor.lua @@ -12,13 +12,12 @@ PLUGIN.Privileges = { "Armor" } PLUGIN.Icon = 'shield' PLUGIN.Settings = { max_armor = { - label = 'Max Armor', - desc = 'Source Engine overflow Prevention', - stype = 'limit', - value = 100, - min = 100, - max = 255, - default = 150 + label = 'Max Armor', + desc = 'Source Engine overflow Prevention', + stype = 'limit', + min = 100, + max = 255, + default = 100 }, } diff --git a/lua/ev_plugins/sh_sandbox.lua b/lua/ev_plugins/sh_sandbox.lua index 42e50dc..af1b7c2 100644 --- a/lua/ev_plugins/sh_sandbox.lua +++ b/lua/ev_plugins/sh_sandbox.lua @@ -15,7 +15,6 @@ PLUGIN.Settings = { label = "Props", desc = "Max number of props.", stype = "limit", - value = 150, min = 0, max = 200, default = 150, @@ -23,9 +22,8 @@ PLUGIN.Settings = { }, sbox_maxragdolls = { label = "Ragdolls", - desc = "Max number of props.", + desc = "Max number of ragdolls.", stype = "limit", - value = 5, min = 0, max = 200, default = 5, @@ -33,9 +31,8 @@ PLUGIN.Settings = { }, sbox_maxvehicles = { label = "Vehicles", - desc = "Max number of props.", + desc = "Max number of vehicles.", stype = "limit", - value = 6, min = 0, max = 200, default = 6, @@ -43,9 +40,8 @@ PLUGIN.Settings = { }, sbox_maxeffects = { label = "Effects", - desc = "Max number of props.", + desc = "Max number of efects.", stype = "limit", - value = 50, min = 0, max = 200, default = 50, @@ -53,9 +49,8 @@ PLUGIN.Settings = { }, sbox_maxballoons = { label = "Balloons", - desc = "Max number of props.", + desc = "Max number of balloons.", stype = "limit", - value = 10, min = 0, max = 200, default = 10, @@ -63,9 +58,8 @@ PLUGIN.Settings = { }, sbox_maxnpcs = { label = "NPCs", - desc = "Max number of props.", + desc = "Max number of NPCs.", stype = "limit", - value = 10, min = 0, max = 200, default = 10, @@ -73,9 +67,8 @@ PLUGIN.Settings = { }, sbox_maxdynamite = { label = "Dynamite", - desc = "Max number of props.", + desc = "Max number of dynamite.", stype = "limit", - value = 10, min = 0, max = 200, default = 10, @@ -83,9 +76,8 @@ PLUGIN.Settings = { }, sbox_maxlamps = { label = "Lamps", - desc = "Max number of props.", + desc = "Max number of lamps.", stype = "limit", - value = 20, min = 0, max = 200, default = 20, @@ -93,9 +85,8 @@ PLUGIN.Settings = { }, sbox_maxlights = { label = "Lights", - desc = "Max number of props.", + desc = "Max number of lights.", stype = "limit", - value = 5, min = 0, max = 200, default = 5, @@ -103,9 +94,8 @@ PLUGIN.Settings = { }, sbox_maxwheels = { label = "Wheels", - desc = "Max number of props.", + desc = "Max number of wheels.", stype = "limit", - value = 20, min = 0, max = 200, default = 20, @@ -113,9 +103,8 @@ PLUGIN.Settings = { }, sbox_maxthrusters = { label = "Thrusters", - desc = "Max number of props.", + desc = "Max number of thrusters.", stype = "limit", - value = 30, min = 0, max = 200, default = 30, @@ -123,9 +112,8 @@ PLUGIN.Settings = { }, sbox_maxhoverballs = { label = "Hoverballs", - desc = "Max number of props.", + desc = "Max number of hoverballs.", stype = "limit", - value = 20, min = 0, max = 200, default = 20, @@ -133,9 +121,8 @@ PLUGIN.Settings = { }, sbox_maxbuttons = { label = "Buttons", - desc = "Max number of props.", + desc = "Max number of buttons.", stype = "limit", - value = 20, min = 0, max = 200, default = 20, @@ -143,9 +130,8 @@ PLUGIN.Settings = { }, sbox_maxemitters = { label = "Emitters", - desc = "Max number of props.", + desc = "Max number of emitters.", stype = "limit", - value = 5, min = 0, max = 200, default = 5, @@ -153,9 +139,8 @@ PLUGIN.Settings = { }, sbox_maxspawners = { label = "Spawners", - desc = "Max number of props.", + desc = "Max number of spawners.", stype = "limit", - value = 100, min = 0, max = 200, default = 100, @@ -163,9 +148,8 @@ PLUGIN.Settings = { }, sbox_maxturrets = { label = "Turrets", - desc = "Max number of props.", + desc = "Max number of turrets.", stype = "limit", - value = 100, min = 0, max = 200, default = 100, @@ -176,7 +160,6 @@ PLUGIN.Settings = { label = "Godmode", desc = "Toggle godmode globally.", stype = "bool", - value = false, default = false, isconvar = true, }, @@ -184,7 +167,6 @@ PLUGIN.Settings = { label = "Noclip", desc = "Toggle the ability to use noclip.", stype = "bool", - value = false, default = false, isconvar = true, }, @@ -192,15 +174,13 @@ PLUGIN.Settings = { label = "PvP", desc = "Toggle player vs player damage.", stype = "bool", - value = true, default = true, isconvar = true, }, sbox_weapons = { label = "Weapons", - desc = "Toggle the usage of weapons. Won't do much in DarkRP.", + desc = "Toggle the usage of weapons.\nWon't do much in DarkRP.", stype = "bool", - value = true, default = true, isconvar = true, }, @@ -208,11 +188,45 @@ PLUGIN.Settings = { label = "Keep NPC bodies", desc = "Toggle.", stype = "bool", - value = 0, 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 From 8055ebb5746eae6b2cbbdf90992191b631297633 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 31 Jan 2016 10:05:36 +0100 Subject: [PATCH 39/52] Revert "Fix evs command not being silent" This reverts commit 3c71fde9ea769aaf9a1decc040a8961cb5015991. evs commands should behave the same way the chatcommands works, no silent notify by default - players should be informed --- lua/ev_plugins/sv_consolecommands.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/ev_plugins/sv_consolecommands.lua b/lua/ev_plugins/sv_consolecommands.lua index 98a51f4..ea0f65b 100644 --- a/lua/ev_plugins/sv_consolecommands.lua +++ b/lua/ev_plugins/sv_consolecommands.lua @@ -27,6 +27,7 @@ function PLUGIN:CCommand( ply, com, cargs ) 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 = string.Left( com, 1 ) == "@" res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) evolve.SilentNotify = false From 77ab097dbc345605fa4c9a010319e6dfe919f384 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 31 Jan 2016 10:14:07 +0100 Subject: [PATCH 40/52] Changed git vON submodule to use https source to avoid ssh errors --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 319bf5337f9b4172935867220b00dbb78fe84d8b Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 31 Jan 2016 11:17:38 +0100 Subject: [PATCH 41/52] Fixed namespaces for vON and data files --- lua/ev_framework.lua | 10 +++++----- lua/ev_plugins/sh_advert3.lua | 6 +++--- lua/ev_plugins/sh_mapcycle.lua | 8 ++++---- lua/ev_plugins/sh_motd.lua | 12 ++++++------ lua/ev_plugins/sv_restriction.lua | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 93671f4..54eae63 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1245,15 +1245,15 @@ end if SERVER then function evolve:ClearSettings() - if ( file.Exists( "ev_settings.txt", "DATA" ) ) then - file.Delete( "ev_settings.txt", "DATA" ) + 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( "ev_settings.txt", "DATA" ) ) then - local loaded = von.deserialize( file.Read( "ev_settings.txt", "DATA" ) ) + 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 @@ -1270,7 +1270,7 @@ if SERVER then for k,v in pairs(evolve.settings) do loaded[k] = v.value end - file.Write( "ev_settings.txt", von.serialize(loaded) ) + file.Write( "evolve/settings.txt", evolve.von.serialize(loaded) ) end net.Receive( "EV_Settings", function( length, ply ) diff --git a/lua/ev_plugins/sh_advert3.lua b/lua/ev_plugins/sh_advert3.lua index ea70517..df4175e 100644 --- a/lua/ev_plugins/sh_advert3.lua +++ b/lua/ev_plugins/sh_advert3.lua @@ -7,15 +7,15 @@ PLUGIN.Usage = "[add;remove;list;toggle][advert id][r][g][b][interval][message]" PLUGIN.Privileges = { "Advert 3" } if (SERVER) then - local adFileName= "ev_adverts.txt" + local adFileName= "evolve/adverts.txt" local function writeToFile(data) - file.Write(adFileName, von.serialize(data)) + file.Write(adFileName, evolve.von.serialize(data)) end adverts = {} adverts.Stored = {} if (#file.Find(adFileName,"DATA") > 0) then - adverts.Stored = von.deserialize(file.Read(adFileName,"DATA")) + 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 diff --git a/lua/ev_plugins/sh_mapcycle.lua b/lua/ev_plugins/sh_mapcycle.lua index d560256..94cecc6 100644 --- a/lua/ev_plugins/sh_mapcycle.lua +++ b/lua/ev_plugins/sh_mapcycle.lua @@ -296,7 +296,7 @@ end function PLUGIN:Save() if (CLIENT) then return end - file.Write( "evolve/ev_mapcycle.txt", von.serialize( { self.Enabled, self.Interval, self.Maps } ) ) + file.Write( "evolve/mapcycle.txt", evolve.von.serialize( { self.Enabled, self.Interval, self.Maps } ) ) end ---------------------------- @@ -306,10 +306,10 @@ end function PLUGIN:Load() if (CLIENT) then return end - if (file.Exists( "evolve/ev_mapcycle.txt", "DATA")) then - local data = file.Read( "evolve/ev_mapcycle.txt", "DATA" ) + if (file.Exists( "evolve/mapcycle.txt", "DATA")) then + local data = file.Read( "evolve/mapcycle.txt", "DATA" ) if (data and data != "") then - data = von.deserialize( data ) + data = evolve.von.deserialize( data ) if (next(data)) then self.Enabled = data[1] self.Interval = data[2] diff --git a/lua/ev_plugins/sh_motd.lua b/lua/ev_plugins/sh_motd.lua index f4a474c..582dd57 100644 --- a/lua/ev_plugins/sh_motd.lua +++ b/lua/ev_plugins/sh_motd.lua @@ -1,4 +1,4 @@ --- Remember to create the ev_motd.txt in the data folder and add the contents!! +-- Remember to create the motd.txt in the data folder and add the contents!! local PLUGIN = {} PLUGIN.Title = "MOTD2" @@ -23,10 +23,10 @@ function PLUGIN:Call( ply, args ) end function MOTDPlayerInitialSpawn( ply ) - if (file.Exists("evolve_motd/ev_motd.txt", "DATA")) then + 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/ev_motd.txt", "DATA") + local tmpstr = file.Read("evolve/motd.txt", "DATA") if tmpstr then net.WriteString( tmpstr ) else @@ -38,7 +38,7 @@ function MOTDPlayerInitialSpawn( ply ) Msg("\n") Msg("====================== \n") Msg("Missing MOTD file! \n") - Msg("Make sure the file exists as: ev_motd.txt in data/evolve_motd/! \n") + Msg("Make sure the file exists as: motd.txt in data/evolve/! \n") Msg("====================== \n") Msg("\n") end @@ -55,13 +55,13 @@ function PLUGIN:OpenMotd2( ply ) end end if (SERVER) then - if (file.Exists("evolve_motd/ev_motd.txt", "DATA")) then + 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: ev_motd.txt in data/evolve_motd/! \n") + Msg("Make sure the file exists as: motd.txt in data/evolve/! \n") Msg("====================== \n") Msg("\n") end diff --git a/lua/ev_plugins/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index aeb3326..24c6263 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -188,8 +188,8 @@ function PLUGIN:Initialize() table.Add( evolve.privileges, tools ) --this table is kept so when new entities/tools are added they get added to every rank - if ( file.Exists( "ev_allentitiescache.txt", "DATA" ) ) then - evolve.allentities = von.deserialize(file.Read( "ev_allentitiescache.txt", "DATA" )) + if ( file.Exists( "evolve/allentitiescache.txt", "DATA" ) ) then + evolve.allentities = evolve.von.deserialize(file.Read( "evolve/allentitiescache.txt", "DATA" )) else evolve.allentities = {} end @@ -219,7 +219,7 @@ function PLUGIN:Initialize() end end - file.Write( "ev_allentitiescache.txt", von.serialize(evolve.allentities)) + file.Write( "evolve/allentitiescache.txt", evolve.von.serialize(evolve.allentities)) evolve:SaveRanks() end From 75adf14ad9fff3fc92d04d0ceed546523fcf3a9c Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 31 Jan 2016 11:52:21 +0100 Subject: [PATCH 42/52] Added upgrade notice to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) 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? ====================== From 1aacce8a625150779734e4dc9828248957e3545d Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 02:23:54 +0100 Subject: [PATCH 43/52] multiple Advert3 additions Added edit button to Advert3 plugin Advert's active state settable during advert creation Dialog for New and Edit are now modal Added more validation checks Moved some code to client side --- lua/ev_menu/tab_adverts3.lua | 233 +++++++++++++++++++++++----------- lua/ev_plugins/sh_advert3.lua | 23 ++-- 2 files changed, 176 insertions(+), 80 deletions(-) diff --git a/lua/ev_menu/tab_adverts3.lua b/lua/ev_menu/tab_adverts3.lua index c621028..c02b0c7 100644 --- a/lua/ev_menu/tab_adverts3.lua +++ b/lua/ev_menu/tab_adverts3.lua @@ -54,12 +54,15 @@ if (SERVER) then util.AddNetworkString("EV_Adverts3") else local NewAdPanelReg = {} - function NewAdPanelReg:Init() + 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:MakePopup() - self:SetZPos(999999) + self:SetZPos(32767) + self:DoModal(true) self.IDLabel = vgui.Create("DLabel", self) self.IDLabel:SetText("ID") @@ -137,28 +140,76 @@ else 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())) then - evolve:Notify(LocalPlayer(), evolve.colors.red, "Incorrect Time input!") - self:Remove() + 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 = true - RunConsoleCommand("ev", "advert3", "add", self.IDInput:GetValue(), newAd.Colour["r"], newAd.Colour["g"], newAd.Colour["b"], tostring(newAd.Time), newAd.Msg) + 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) @@ -172,75 +223,113 @@ function TAB:GetAdverts(ply) end --===================================================================================-- -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( 308 ) - self.AdList:AddColumn( "Active" ):SetFixedWidth( 32 ) - self.New = vgui.Create( "DButton", pnl ) - self.New:SetSize( 60, 22 ) - self.New:SetPos( self.Width - 275, pnl:GetParent():GetTall() - 53 ) - self.New:SetText( "ReSync" ) - self.New.DoClick = function() - self:Request() - end - - self.New = vgui.Create( "DButton", pnl ) - self.New:SetSize( 60, 22 ) - self.New:SetPos( self.Width - 210, pnl:GetParent():GetTall() - 53 ) - self.New:SetText( "New" ) - self.New.DoClick = function() - local newAdInput = vgui.Create("NewAdPanel") - end - - self.Tog = vgui.Create( "DButton", pnl ) - self.Tog:SetSize( 60, 22 ) - self.Tog:SetPos( self.Width - 145, pnl:GetParent():GetTall() - 53 ) - self.Tog:SetText( "Toggle" ) - self.Tog.DoClick = function() - if self.AdList:GetSelected() then - local id = self.AdList:GetSelected()[1]:GetValue(1) - end - RunConsoleCommand("ev", "advert3", "toggle", id) - adverts[id]["OnState"] = !adverts[id]["OnState"] - self.AdList:GetSelected()[1]:SetValue(5, adverts[id]["OnState"]) - end - - self.Rem = vgui.Create( "DButton", pnl ) - self.Rem:SetSize( 60, 22 ) - self.Rem:SetPos( self.Width - 80, pnl:GetParent():GetTall() - 53 ) - self.Rem:SetText( "Remove" ) - self.Rem.DoClick = function() - local id = self.AdList:GetSelected()[1]:GetValue(1) - RunConsoleCommand("ev", "advert3", "remove", id) - adverts[id] = nil - self:Update() +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 - timer.Simple(1.5, function() TAB:Request() end) -end -function TAB:Update() - 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, data.OnState); + 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 - self.AdList:SelectFirstItem() -end -function TAB:Request() - self:GetAdverts() - timer.Simple(2, function() TAB:Update() 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" ) + 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_plugins/sh_advert3.lua b/lua/ev_plugins/sh_advert3.lua index df4175e..c0dd48a 100644 --- a/lua/ev_plugins/sh_advert3.lua +++ b/lua/ev_plugins/sh_advert3.lua @@ -3,7 +3,7 @@ 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][message]" +PLUGIN.Usage = "[add;remove;list;toggle][advert id][r][g][b][interval][state][message]" PLUGIN.Privileges = { "Advert 3" } if (SERVER) then @@ -32,21 +32,27 @@ if (SERVER) then ------------------------------------------------------------------------------------ function adverts.add(info) info[1] = info[1]:lower() - if #info > 6 then - info[6] = table.concat(info, " ", 6, #info) - elseif #info < 6 then + 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 \""..adverts.Stored[info[1]].."\"." + 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[6], - ["OnState"] = true + ["Msg"] = info[7], + ["OnState"] = tobool(info[6]) } timer.Create("Advert_"..info[1], adverts.Stored[info[1]].Time, 0, function() if (#player.GetAll() > 0) then @@ -76,7 +82,7 @@ if (SERVER) then return str or "No adverts loaded." end -------------------------------------------------------------------------------------------- - function adverts.toggle(args) + 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 @@ -89,6 +95,7 @@ if (SERVER) then 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." From b5e8eea5f8d608222fe5d399d76818b930cef74d Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 03:17:13 +0100 Subject: [PATCH 44/52] Added boolean variable to serverside notify function to disable console+file logging when required (Needed to stop advert3 from spamming the logs) --- lua/ev_framework.lua | 23 +++++++++++++++-------- lua/ev_plugins/sh_advert3.lua | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 54eae63..4b72751 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -124,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 diff --git a/lua/ev_plugins/sh_advert3.lua b/lua/ev_plugins/sh_advert3.lua index c0dd48a..5d2cb0e 100644 --- a/lua/ev_plugins/sh_advert3.lua +++ b/lua/ev_plugins/sh_advert3.lua @@ -19,7 +19,7 @@ if (SERVER) then 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) + evolve:Notify(v.Colour, v.Msg, true) end end) if (v.OnState == false) then From c1df8df034e23f71077a1709bcb77cf202d5b090 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 05:10:43 +0100 Subject: [PATCH 45/52] IP bans did not load on mapchange --- lua/ev_framework.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 4b72751..5edf9bf 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -1138,7 +1138,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 From f18e347b64ece43a88ed15a67e13fb949c2c9bf7 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 05:14:55 +0100 Subject: [PATCH 46/52] load settings before loading the plugins so settings are available early --- lua/ev_cl_init.lua | 2 +- lua/ev_sv_init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/ev_cl_init.lua b/lua/ev_cl_init.lua index c7e7c52..1c151d8 100644 --- a/lua/ev_cl_init.lua +++ b/lua/ev_cl_init.lua @@ -9,6 +9,6 @@ print( "=====================================================\n" ) net.Receive( "EV_Init", function( length ) evolve.installed = true + evolve:GetSettings() evolve:LoadPlugins() - evolve:GetSettings() end ) \ No newline at end of file diff --git a/lua/ev_sv_init.lua b/lua/ev_sv_init.lua index d5f422b..aff4f41 100644 --- a/lua/ev_sv_init.lua +++ b/lua/ev_sv_init.lua @@ -6,8 +6,8 @@ print( "\n=====================================================" ) print( " Evolve 1.0 by Overv succesfully started serverside." ) print( "=====================================================\n" ) -evolve:LoadPlugins() 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 hook.Add( "PlayerSpawn", "EvolveInit", function( ply ) From b75e6bc0ff2d70a71b375c741c83b26626fdfcb7 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 05:18:48 +0100 Subject: [PATCH 47/52] Added simple blacklist for disabling the loading of some plugins during mapchange using a textfield in settings dialog Multiple plugin-filenames can be separated by comma --- lua/ev_framework.lua | 15 ++++++++++++--- lua/ev_menu/tab_settings.lua | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lua/ev_framework.lua b/lua/ev_framework.lua index 5edf9bf..f047c5e 100644 --- a/lua/ev_framework.lua +++ b/lua/ev_framework.lua @@ -237,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 diff --git a/lua/ev_menu/tab_settings.lua b/lua/ev_menu/tab_settings.lua index ab67f44..c3a85f1 100644 --- a/lua/ev_menu/tab_settings.lua +++ b/lua/ev_menu/tab_settings.lua @@ -118,6 +118,12 @@ local testsettings = { 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 = '', + }, }, }, }, From 6afbeffad1f83f13cca774a666450ac22fea863f Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 05:39:09 +0100 Subject: [PATCH 48/52] Added Divran's Ranks over time plugin it requires some config in the lua file before it can be used --- lua/ev_plugins/sv_rankovertime.lua | 103 +++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 lua/ev_plugins/sv_rankovertime.lua diff --git a/lua/ev_plugins/sv_rankovertime.lua b/lua/ev_plugins/sv_rankovertime.lua new file mode 100644 index 0000000..dcf3d36 --- /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 && #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 From 694131a3bd4c93776bd62dd8d8030319302a4bd2 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Mon, 1 Feb 2016 06:11:40 +0100 Subject: [PATCH 49/52] Fixed silent evs commands example: ev @map gm_construct same as: evs map gm_construct --- lua/ev_plugins/sv_consolecommands.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/ev_plugins/sv_consolecommands.lua b/lua/ev_plugins/sv_consolecommands.lua index ea0f65b..033c5e3 100644 --- a/lua/ev_plugins/sv_consolecommands.lua +++ b/lua/ev_plugins/sv_consolecommands.lua @@ -22,12 +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 = string.Left( com, 1 ) == "@" + evolve.SilentNotify = silentnotify res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command ) evolve.SilentNotify = false From 21b5241b2aaf88b9aad2a93b7fc9ff48c94377c1 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 7 Feb 2016 13:55:49 +0100 Subject: [PATCH 50/52] Fixed not working console output of Chatcommands plugin --- lua/ev_plugins/sh_commands.lua | 66 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 34 deletions(-) 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 From 594d822f226ebd6225c57de94e8813a7d3392d18 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sat, 20 Feb 2016 14:36:08 +0100 Subject: [PATCH 51/52] Fixed Ranks over time, rankups didn't work --- lua/ev_plugins/sv_rankovertime.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/ev_plugins/sv_rankovertime.lua b/lua/ev_plugins/sv_rankovertime.lua index dcf3d36..c2f0036 100644 --- a/lua/ev_plugins/sv_rankovertime.lua +++ b/lua/ev_plugins/sv_rankovertime.lua @@ -28,7 +28,7 @@ local function formattime( time ) end function PLUGIN:Initialize() - if(self.RankUps && #self.RankUps == 0) then return end + 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) From c6931d144af132dc19c000108e83a860249e3af4 Mon Sep 17 00:00:00 2001 From: X-Coder Date: Sun, 1 May 2016 22:24:58 +0200 Subject: [PATCH 52/52] Fixed: dropped weapons could not be picked up when carter's addon pack is installed --- lua/ev_plugins/sv_restriction.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/ev_plugins/sv_restriction.lua b/lua/ev_plugins/sv_restriction.lua index 24c6263..d02b7d1 100644 --- a/lua/ev_plugins/sv_restriction.lua +++ b/lua/ev_plugins/sv_restriction.lua @@ -117,8 +117,6 @@ function PLUGIN:PlayerCanPickupWeapon( ply, wep ) 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 - else - return true end end end