add sborka

This commit is contained in:
2026-03-31 10:27:04 +03:00
commit f5e5f56c84
2345 changed files with 382127 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
if not PermaProps then PermaProps = {} end
print("---------------------------------")
print("| Loading ClientSide PermaProps |")
print("---------------------------------")
for k, v in pairs(file.Find("permaprops/cl_*.lua", "LUA")) do
include("permaprops/".. v)
print("permaprops/".. v)
end
print("---------------------------------")
print("| Loading Shared PermaProps |")
print("---------------------------------")
for k, v in pairs(file.Find("permaprops/sh_*.lua", "LUA")) do
include("permaprops/".. v)
print("permaprops/".. v)
end
print("---------------------------------")

View File

@@ -0,0 +1,48 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
if not PermaProps then PermaProps = {} end
print("---------------------------------")
print("| Loading ServerSide PermaProps |")
print("---------------------------------")
for k, v in pairs(file.Find("permaprops/sv_*.lua", "LUA")) do
include("permaprops/".. v)
print("permaprops/".. v)
end
print("-----------------------------")
print("| Loading Shared PermaProps |")
print("-----------------------------")
for k, v in pairs(file.Find("permaprops/sh_*.lua", "LUA")) do
AddCSLuaFile("permaprops/".. v)
include("permaprops/".. v)
print("permaprops/".. v)
end
print("---------------------------------")
print("| Loading ClientSide PermaProps |")
print("---------------------------------")
for k, v in pairs(file.Find("permaprops/cl_*.lua", "LUA")) do
AddCSLuaFile("permaprops/".. v)
print("permaprops/".. v)
end
print("-------------------------------")

View File

@@ -0,0 +1,141 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = ""
ENT.Author = ""
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Spawnable = false
ENT.AdminOnly = false
--[[---------------------------------------------------------
Name: Initialize
-----------------------------------------------------------]]
function ENT:Initialize()
local Radius = 6
local min = Vector( 1, 1, 1 ) * Radius * -0.5
local max = Vector( 1, 1, 1 ) * Radius * 0.5
if ( SERVER ) then
self.AttachedEntity = ents.Create( "prop_dynamic" )
self.AttachedEntity:SetModel( self:GetModel() )
self.AttachedEntity:SetAngles( self:GetAngles() )
self.AttachedEntity:SetPos( self:GetPos() )
self.AttachedEntity:SetSkin( self:GetSkin() )
self.AttachedEntity:Spawn()
self.AttachedEntity:SetParent( self.Entity )
self.AttachedEntity:DrawShadow( false )
self:SetModel( "models/props_junk/watermelon01.mdl" )
self:DeleteOnRemove( self.AttachedEntity )
-- Don't use the model's physics - create a box instead
self:PhysicsInitBox( min, max )
-- Set up our physics object here
local phys = self:GetPhysicsObject()
if ( IsValid( phys ) ) then
phys:Wake()
phys:EnableGravity( false )
phys:EnableDrag( false )
end
self:DrawShadow( false )
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
else
self.GripMaterial = Material( "sprites/grip" )
-- Get the attached entity so that clientside functions like properties can interact with it
local tab = ents.FindByClassAndParent( "prop_dynamic", self )
if ( tab && IsValid( tab[ 1 ] ) ) then self.AttachedEntity = tab[ 1 ] end
end
-- Set collision bounds exactly
self:SetCollisionBounds( min, max )
end
--[[---------------------------------------------------------
Name: Draw
-----------------------------------------------------------]]
function ENT:Draw()
render.SetMaterial( self.GripMaterial )
end
--[[---------------------------------------------------------
Name: PhysicsUpdate
-----------------------------------------------------------]]
function ENT:PhysicsUpdate( physobj )
if ( CLIENT ) then return end
-- Don't do anything if the player isn't holding us
if ( !self:IsPlayerHolding() && !self:IsConstrained() ) then
physobj:SetVelocity( Vector( 0, 0, 0 ) )
physobj:Sleep()
end
end
--[[---------------------------------------------------------
Name: Called after entity 'copy'
-----------------------------------------------------------]]
function ENT:OnEntityCopyTableFinish( tab )
-- We need to store the model of the attached entity
-- Not the one we have here.
tab.Model = self.AttachedEntity:GetModel()
-- Store the attached entity's table so we can restore it after being pasted
tab.AttachedEntityInfo = table.Copy( duplicator.CopyEntTable( self.AttachedEntity ) )
tab.AttachedEntityInfo.Pos = nil -- Don't even save angles and position, we are a parented entity
tab.AttachedEntityInfo.Angle = nil
-- Do NOT store the attached entity itself in our table!
-- Otherwise, if we copy-paste the prop with the duplicator, its AttachedEntity value will point towards the original prop's attached entity instead, and that'll break stuff
tab.AttachedEntity = nil
end
--[[---------------------------------------------------------
Name: PostEntityPaste
-----------------------------------------------------------]]
function ENT:PostEntityPaste( ply )
-- Restore the attached entity using the information we've saved
if ( IsValid( self.AttachedEntity ) ) and ( self.AttachedEntityInfo ) then
-- Apply skin, bodygroups, bone manipulator, etc.
duplicator.DoGeneric( self.AttachedEntity, self.AttachedEntityInfo )
if ( self.AttachedEntityInfo.EntityMods ) then
self.AttachedEntity.EntityMods = table.Copy( self.AttachedEntityInfo.EntityMods )
duplicator.ApplyEntityModifiers( ply, self.AttachedEntity )
end
if ( self.AttachedEntityInfo.BoneMods ) then
self.AttachedEntity.BoneMods = table.Copy( self.AttachedEntityInfo.BoneMods )
duplicator.ApplyBoneModifiers( ply, self.AttachedEntity )
end
self.AttachedEntityInfo = nil
end
end

View File

@@ -0,0 +1,534 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
surface.CreateFont( "pp_font", {
font = "Arial",
size = 20,
weight = 700,
shadow = false
} )
local function pp_open_menu()
local Len = net.ReadFloat()
local Data = net.ReadData( Len )
local UnCompress = util.Decompress( Data )
local Content = util.JSONToTable( UnCompress )
local Main = vgui.Create( "DFrame" )
Main:SetSize( 600, 355 )
Main:Center()
Main:SetTitle("")
Main:SetVisible( true )
Main:SetDraggable( true )
Main:ShowCloseButton( true )
Main:MakePopup()
Main.Paint = function(self)
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color(155, 155, 155, 220) )
surface.SetDrawColor( 17, 148, 240, 255 )
surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() )
draw.RoundedBox( 0, 0, 0, self:GetWide(), 25, Color(17, 148, 240, 200) )
surface.SetDrawColor( 17, 148, 240, 255 )
surface.DrawOutlinedRect( 0, 0, self:GetWide(), 25 )
draw.DrawText( "PermaProps Config", "pp_font", 10, 2.2, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT )
end
local BSelect
local PSelect
local MainPanel = vgui.Create( "DPanel", Main )
MainPanel:SetPos( 190, 51 )
MainPanel:SetSize( 390, 275 )
MainPanel.Paint = function( self )
surface.SetDrawColor( 50, 50, 50, 200 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.DrawOutlinedRect(0, 15, self:GetWide(), 40)
end
PSelect = MainPanel
local MainLabel = vgui.Create("DLabel", MainPanel)
MainLabel:SetFont("pp_font")
MainLabel:SetPos(140, 25)
MainLabel:SetColor(Color(50, 50, 50, 255))
MainLabel:SetText("Hey ".. LocalPlayer():Nick() .." !")
MainLabel:SizeToContents()
local MainLabel2 = vgui.Create("DLabel", MainPanel)
MainLabel2:SetFont("pp_font")
MainLabel2:SetPos(80, 80)
MainLabel2:SetColor(Color(50, 50, 50, 255))
MainLabel2:SetText("There are ".. ( Content.MProps or 0 ) .." props on this map.\n\nThere are ".. ( Content.TProps or 0 ) .." props in the DB.")
MainLabel2:SizeToContents()
local RemoveMapProps = vgui.Create( "DButton", MainPanel )
RemoveMapProps:SetText( " Clear map props " )
RemoveMapProps:SetFont("pp_font")
RemoveMapProps:SetSize( 370, 30)
RemoveMapProps:SetPos( 10, 160 )
RemoveMapProps:SetTextColor( Color( 50, 50, 50, 255 ) )
RemoveMapProps.DoClick = function()
net.Start("pp_info_send")
net.WriteTable({CMD = "CLR_MAP"})
net.SendToServer()
end
RemoveMapProps.Paint = function(self)
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
local ClearMapProps = vgui.Create( "DButton", MainPanel )
ClearMapProps:SetText( " Clear map props in the DB " )
ClearMapProps:SetFont("pp_font")
ClearMapProps:SetSize( 370, 30)
ClearMapProps:SetPos( 10, 200 )
ClearMapProps:SetTextColor( Color( 50, 50, 50, 255 ) )
ClearMapProps.DoClick = function()
Derma_Query("Are you sure you want clear map props in the db ?\nYou can't undo this action !", "PermaProps 4.0", "Yes", function() net.Start("pp_info_send") net.WriteTable({CMD = "DEL_MAP"}) net.SendToServer() end, "Cancel")
end
ClearMapProps.Paint = function(self)
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
local ClearAllProps = vgui.Create( "DButton", MainPanel )
ClearAllProps:SetText( " Clear all props in the DB " )
ClearAllProps:SetFont("pp_font")
ClearAllProps:SetSize( 370, 30)
ClearAllProps:SetPos( 10, 240 )
ClearAllProps:SetTextColor( Color( 50, 50, 50, 255 ) )
ClearAllProps.DoClick = function()
Derma_Query("Are you sure you want clear all props in the db ?\nYou can't undo this action !", "PermaProps 4.0", "Yes", function() net.Start("pp_info_send") net.WriteTable({CMD = "DEL_ALL"}) net.SendToServer() end, "Cancel")
end
ClearAllProps.Paint = function(self)
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
local BMain = vgui.Create("DButton", Main)
BSelect = BMain
BMain:SetText("Main")
BMain:SetFont("pp_font")
BMain:SetSize(160, 50)
BMain:SetPos(15, 27 + 25)
BMain:SetTextColor( Color( 255, 255, 255, 255 ) )
BMain.PaintColor = Color(17, 148, 240, 100)
BMain.Paint = function(self)
draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), self.PaintColor)
surface.SetDrawColor(17, 148, 240, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
BMain.DoClick = function( self )
if BSelect then BSelect.PaintColor = Color(0, 0, 0, 0) end
BSelect = self
self.PaintColor = Color(17, 148, 240, 100)
if PSelect then PSelect:Hide() end
MainPanel:Show()
PSelect = MainPanel
end
local ConfigPanel = vgui.Create( "DPanel", Main )
ConfigPanel:SetPos( 190, 51 )
ConfigPanel:SetSize( 390, 275 )
ConfigPanel.Paint = function( self )
surface.SetDrawColor( 50, 50, 50, 200 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
end
ConfigPanel:Hide()
local CheckCustom = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckCustom:SetPos( 5, 30 )
CheckCustom:SetText( "Custom permissions" )
CheckCustom:SetValue( 0 )
CheckCustom:SizeToContents()
CheckCustom:SetTextColor( Color( 0, 0, 0, 255) )
CheckCustom:SetDisabled( true )
local GroupsList = vgui.Create( "DComboBox", ConfigPanel )
GroupsList:SetPos( 5, 5 )
GroupsList:SetSize( 125, 20 )
GroupsList:SetValue( "Select a group..." )
local CheckBox1 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox1:SetPos( 150, 10 )
CheckBox1:SetText( "Menu" )
CheckBox1:SizeToContents()
CheckBox1:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox1:SetDisabled( true )
CheckBox1.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Menu", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox2 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox2:SetPos( 150, 30 )
CheckBox2:SetText( "Edit permissions" )
CheckBox2:SizeToContents()
CheckBox2:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox2:SetDisabled( true )
CheckBox2.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Permissions", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox3 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox3:SetPos( 150, 50 )
CheckBox3:SetText( "Physgun permaprops" )
CheckBox3:SizeToContents()
CheckBox3:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox3:SetDisabled( true )
CheckBox3.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Physgun", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox4 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox4:SetPos( 150, 70 )
CheckBox4:SetText( "Tool permaprops" )
CheckBox4:SizeToContents()
CheckBox4:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox4:SetDisabled( true )
CheckBox4.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Tool", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox5 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox5:SetPos( 150, 90 )
CheckBox5:SetText( "Property permaprops" )
CheckBox5:SizeToContents()
CheckBox5:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox5:SetDisabled( true )
CheckBox5.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Property", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox6 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox6:SetPos( 150, 110 )
CheckBox6:SetText( "Save props" )
CheckBox6:SizeToContents()
CheckBox6:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox6:SetDisabled( true )
CheckBox6.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Save", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox7 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox7:SetPos( 150, 130 )
CheckBox7:SetText( "Delete permaprops" )
CheckBox7:SizeToContents()
CheckBox7:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox7:SetDisabled( true )
CheckBox7.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Delete", Name = GroupsList:GetValue()})
net.SendToServer()
end
local CheckBox8 = vgui.Create( "DCheckBoxLabel", ConfigPanel )
CheckBox8:SetPos( 150, 150 )
CheckBox8:SetText( "Update permaprops" )
CheckBox8:SizeToContents()
CheckBox8:SetTextColor( Color( 0, 0, 0, 255) )
CheckBox8:SetDisabled( true )
CheckBox8.OnChange = function(Self, Value)
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Update", Name = GroupsList:GetValue()})
net.SendToServer()
end
GroupsList.OnSelect = function( panel, index, value )
CheckCustom:SetDisabled( false )
CheckCustom:SetChecked( Content.Permissions[value].Custom )
CheckBox1:SetDisabled( !Content.Permissions[value].Custom )
CheckBox1:SetChecked( Content.Permissions[value].Menu )
CheckBox2:SetDisabled( !Content.Permissions[value].Custom )
CheckBox2:SetChecked( Content.Permissions[value].Permissions )
CheckBox3:SetDisabled( !Content.Permissions[value].Custom )
CheckBox3:SetChecked( Content.Permissions[value].Physgun )
CheckBox4:SetDisabled( !Content.Permissions[value].Custom )
CheckBox4:SetChecked( Content.Permissions[value].Tool )
CheckBox5:SetDisabled( !Content.Permissions[value].Custom )
CheckBox5:SetChecked( Content.Permissions[value].Property )
CheckBox6:SetDisabled( !Content.Permissions[value].Custom )
CheckBox6:SetChecked( Content.Permissions[value].Save )
CheckBox7:SetDisabled( !Content.Permissions[value].Custom )
CheckBox7:SetChecked( Content.Permissions[value].Delete )
CheckBox8:SetDisabled( !Content.Permissions[value].Custom )
CheckBox8:SetChecked( Content.Permissions[value].Update )
end
for k, v in pairs(Content.Permissions) do
GroupsList:AddChoice(k)
end
CheckCustom.OnChange = function(Self, Value)
CheckBox1:SetDisabled( !Value )
CheckBox2:SetDisabled( !Value )
CheckBox3:SetDisabled( !Value )
CheckBox4:SetDisabled( !Value )
CheckBox5:SetDisabled( !Value )
CheckBox6:SetDisabled( !Value )
CheckBox7:SetDisabled( !Value )
CheckBox8:SetDisabled( !Value )
net.Start("pp_info_send")
net.WriteTable({CMD = "VAR", Val = Value, Data = "Custom", Name = GroupsList:GetValue()})
net.SendToServer()
end
local BConfig = vgui.Create("DButton", Main)
BConfig:SetText("Configuration")
BConfig:SetFont("pp_font")
BConfig:SetSize(160, 50)
BConfig:SetPos(15, 71 + 55)
BConfig:SetTextColor( Color( 255, 255, 255, 255 ) )
BConfig.PaintColor = Color(0, 0, 0, 0)
BConfig.Paint = function(self)
draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), self.PaintColor)
surface.SetDrawColor(17, 148, 240, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
BConfig.DoClick = function( self )
if BSelect then BSelect.PaintColor = Color(0, 0, 0, 0) end
BSelect = self
self.PaintColor = Color(17, 148, 240, 100)
if PSelect then PSelect:Hide() end
ConfigPanel:Show()
PSelect = ConfigPanel
end
local PropsPanel = vgui.Create( "DPanel", Main )
PropsPanel:SetPos( 190, 51 )
PropsPanel:SetSize( 390, 275 )
PropsPanel.Paint = function( self )
surface.SetDrawColor( 50, 50, 50, 200 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
end
PropsPanel:Hide()
local PropsList = vgui.Create( "DListView", PropsPanel )
PropsList:SetMultiSelect( false )
PropsList:SetSize( 390, 275 )
local ColID = PropsList:AddColumn( "ID" )
local ColEnt = PropsList:AddColumn( "Entity" )
local ColMdl = PropsList:AddColumn( "Model" )
ColID:SetMinWidth(50)
ColID:SetMaxWidth(50)
PropsList.Paint = function( self )
surface.SetDrawColor(17, 148, 240, 255)
end
PropsList.OnRowRightClick = function(panel, line)
local MenuButtonOptions = DermaMenu()
MenuButtonOptions:AddOption("Draw entity", function()
if not LocalPlayer().DrawPPEnt or not istable(LocalPlayer().DrawPPEnt) then LocalPlayer().DrawPPEnt = {} end
if LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] and LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)]:IsValid() then return end
local ent = ents.CreateClientProp( Content.PropsList[PropsList:GetLine(line):GetValue(1)].Model )
ent:SetPos( Content.PropsList[PropsList:GetLine(line):GetValue(1)].Pos )
ent:SetAngles( Content.PropsList[PropsList:GetLine(line):GetValue(1)].Angle )
LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] = ent
end )
if LocalPlayer().DrawPPEnt and LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] then
MenuButtonOptions:AddOption("Stop Drawing", function()
LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)]:Remove()
LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] = nil
end )
end
if LocalPlayer().DrawPPEnt != nil and istable(LocalPlayer().DrawPPEnt) and table.Count(LocalPlayer().DrawPPEnt) > 0 then
MenuButtonOptions:AddOption("Stop Drawing All", function()
for k, v in pairs(LocalPlayer().DrawPPEnt) do
LocalPlayer().DrawPPEnt[k]:Remove()
LocalPlayer().DrawPPEnt[k] = nil
end
end )
end
MenuButtonOptions:AddOption("Remove", function()
net.Start("pp_info_send")
net.WriteTable({CMD = "DEL", Val = PropsList:GetLine(line):GetValue(1)})
net.SendToServer()
if LocalPlayer().DrawPPEnt and LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] != nil then
LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)]:Remove()
LocalPlayer().DrawPPEnt[PropsList:GetLine(line):GetValue(1)] = nil
end
PropsList:RemoveLine(line)
end )
MenuButtonOptions:Open()
end
for k, v in pairs(Content.PropsList) do
PropsList:AddLine(k, v.Class, v.Model)
end
local BProps = vgui.Create("DButton", Main)
BProps:SetText("Props List")
BProps:SetFont("pp_font")
BProps:SetSize(160, 50)
BProps:SetPos(15, 115 + 85)
BProps:SetTextColor( Color( 255, 255, 255, 255 ) )
BProps.PaintColor = Color(0, 0, 0, 0)
BProps.Paint = function(self)
draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), self.PaintColor)
surface.SetDrawColor(17, 148, 240, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
BProps.DoClick = function( self )
if BSelect then BSelect.PaintColor = Color(0, 0, 0, 0) end
BSelect = self
self.PaintColor = Color(17, 148, 240, 100)
if PSelect then PSelect:Hide() end
PropsPanel:Show()
PSelect = PropsPanel
end
local AboutPanel = vgui.Create( "DPanel", Main )
AboutPanel:SetPos( 190, 51 )
AboutPanel:SetSize( 390, 275 )
AboutPanel.Paint = function( self )
surface.SetDrawColor( 50, 50, 50, 200 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.DrawOutlinedRect(0, 15, self:GetWide(), 40)
end
AboutPanel:Hide()
local AboutLabel = vgui.Create("DLabel", AboutPanel)
AboutLabel:SetFont("pp_font")
AboutLabel:SetPos(140, 25)
AboutLabel:SetColor(Color(50, 50, 50, 255))
AboutLabel:SetText("PermaProps 4.0")
AboutLabel:SizeToContents()
local AboutLabel2 = vgui.Create("DLabel", AboutPanel)
AboutLabel2:SetFont("pp_font")
AboutLabel2:SetPos(30, 80)
AboutLabel2:SetColor(Color(50, 50, 50, 255))
AboutLabel2:SetText("Author: Malboro\n\nContributor: Entoros | ARitz Cracker\n\n\n Special thanks to all donors !")
AboutLabel2:SizeToContents()
local DonationsTxT = vgui.Create( "DButton", AboutPanel )
DonationsTxT:SetText( " Donate " )
DonationsTxT:SetFont("pp_font")
DonationsTxT:SetSize( 370, 30)
DonationsTxT:SetPos( 10, 240 )
DonationsTxT:SetTextColor( Color( 50, 50, 50, 255 ) )
DonationsTxT.DoClick = function() gui.OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CJ5EUHFAQ7NLN") end
DonationsTxT.Paint = function(self)
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
local BAbout = vgui.Create("DButton", Main)
BAbout:SetText("About")
BAbout:SetFont("pp_font")
BAbout:SetSize(160, 50)
BAbout:SetPos(15, 159 + 115)
BAbout:SetTextColor( Color( 255, 255, 255, 255 ) )
BAbout.PaintColor = Color(0, 0, 0, 0)
BAbout.Paint = function(self)
draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), self.PaintColor)
surface.SetDrawColor(17, 148, 240, 255)
surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
end
BAbout.DoClick = function( self )
if BSelect then BSelect.PaintColor = Color(0, 0, 0, 0) end
BSelect = self
self.PaintColor = Color(17, 148, 240, 100)
if PSelect then PSelect:Hide() end
AboutPanel:Show()
PSelect = AboutPanel
end
if !file.Exists("permaprops_donate.txt", "DATA") then
Derma_Query("Please don't Forget to Donate", "PermaProps 4.0", "Donate", function() gui.OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CJ5EUHFAQ7NLN") end, "Cancel", function() file.Write("permaprops_donate.txt") end)
end
end
net.Receive("pp_open_menu", pp_open_menu)

View File

@@ -0,0 +1,312 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
if not PermaProps then PermaProps = {} end
function PermaProps.PPGetEntTable( ent )
if !ent or !ent:IsValid() then return false end
local content = {}
content.Class = ent:GetClass()
content.Pos = ent:GetPos()
content.Angle = ent:GetAngles()
content.Model = ent:GetModel()
content.Skin = ent:GetSkin()
//content.Mins, content.Maxs = ent:GetCollisionBounds()
content.ColGroup = ent:GetCollisionGroup()
content.Name = ent:GetName()
content.ModelScale = ent:GetModelScale()
content.Color = ent:GetColor()
content.Material = ent:GetMaterial()
content.Solid = ent:GetSolid()
if PermaProps.SpecialENTSSave[ent:GetClass()] != nil and isfunction(PermaProps.SpecialENTSSave[ent:GetClass()]) then
local othercontent = PermaProps.SpecialENTSSave[ent:GetClass()](ent)
if not othercontent then return false end
if othercontent != nil and istable(othercontent) then
table.Merge(content, othercontent)
end
end
if ( ent.GetNetworkVars ) then
content.DT = ent:GetNetworkVars()
end
local sm = ent:GetMaterials()
if ( sm and istable(sm) ) then
for k, v in pairs( sm ) do
if ( ent:GetSubMaterial( k )) then
content.SubMat = content.SubMat or {}
content.SubMat[ k ] = ent:GetSubMaterial( k )
end
end
end
local bg = ent:GetBodyGroups()
if ( bg ) then
for k, v in pairs( bg ) do
if ( ent:GetBodygroup( v.id ) > 0 ) then
content.BodyG = content.BodyG or {}
content.BodyG[ v.id ] = ent:GetBodygroup( v.id )
end
end
end
if ent:GetPhysicsObject() and ent:GetPhysicsObject():IsValid() then
content.Frozen = !ent:GetPhysicsObject():IsMoveable()
end
if content.Class == "prop_dynamic" then
content.Class = "prop_physics"
end
--content.Table = PermaProps.UselessContent( ent:GetTable() )
return content
end
function PermaProps.PPEntityFromTable( data, id )
if not id or not isnumber(id) then return false end
if data.Class == "prop_physics" and data.Frozen then
data.Class = "prop_dynamic" -- Can reduce lags
end
local ent = ents.Create(data.Class)
if !ent then return false end
if !ent:IsVehicle() then if !ent:IsValid() then return false end end
ent:SetPos( data.Pos or Vector(0, 0, 0) )
ent:SetAngles( data.Angle or Angle(0, 0, 0) )
ent:SetModel( data.Model or "models/error.mdl" )
ent:SetSkin( data.Skin or 0 )
//ent:SetCollisionBounds( ( data.Mins or 0 ), ( data.Maxs or 0 ) )
ent:SetCollisionGroup( data.ColGroup or 0 )
ent:SetName( data.Name or "" )
ent:SetModelScale( data.ModelScale or 1 )
ent:SetMaterial( data.Material or "" )
ent:SetSolid( data.Solid or 6 )
if PermaProps.SpecialENTSSpawn[data.Class] != nil and isfunction(PermaProps.SpecialENTSSpawn[data.Class]) then
PermaProps.SpecialENTSSpawn[data.Class](ent, data.Other)
else
ent:Spawn()
end
ent:SetRenderMode( RENDERMODE_TRANSALPHA )
ent:SetColor( data.Color or Color(255, 255, 255, 255) )
if data.EntityMods != nil and istable(data.EntityMods) then -- OLD DATA
if data.EntityMods.material then
ent:SetMaterial( data.EntityMods.material["MaterialOverride"] or "")
end
if data.EntityMods.colour then
ent:SetColor( data.EntityMods.colour.Color or Color(255, 255, 255, 255))
end
end
if data.DT then
for k, v in pairs( data.DT ) do
if ( data.DT[ k ] == nil ) then continue end
if !isfunction(ent[ "Set" .. k ]) then continue end
ent[ "Set" .. k ]( ent, data.DT[ k ] )
end
end
if data.BodyG then
for k, v in pairs( data.BodyG ) do
ent:SetBodygroup( k, v )
end
end
if data.SubMat then
for k, v in pairs( data.SubMat ) do
if type(k) != "number" or type(v) == "string" then continue end
ent:SetSubMaterial( k, v )
end
end
if data.Frozen != nil then
local phys = ent:GetPhysicsObject()
if phys and phys:IsValid() then
phys:EnableMotion(!data.Frozen)
end
end
/*if data.Table then
table.Merge(ent:GetTable(), data.Table)
end*/
ent.PermaProps_ID = id
ent.PermaProps = true
// For all idiots who don't know how to config FPP, FUCK YOU
function ent:CanTool( ply, trace, tool )
if IsValid(trace.Entity) and trace.Entity.PermaProps then
if tool == "permaprops" then
return true
end
return PermaProps.HasPermission( ply, "Tool")
end
end
return ent
end
function PermaProps.ReloadPermaProps()
for k, v in pairs( ents.GetAll() ) do
if v.PermaProps == true then
v:Remove()
end
end
local content = PermaProps.SQL.Query( "SELECT * FROM permaprops WHERE map = ".. sql.SQLStr(game.GetMap()) .. ";" )
if not content or content == nil then return end
for k, v in pairs( content ) do
local data = util.JSONToTable(v.content)
local e = PermaProps.PPEntityFromTable(data, tonumber(v.id))
if !e or !e:IsValid() then continue end
end
end
hook.Add("InitPostEntity", "InitializePermaProps", PermaProps.ReloadPermaProps)
hook.Add("PostCleanupMap", "WhenCleanUpPermaProps", PermaProps.ReloadPermaProps) -- #MOMO
timer.Simple(5, function() PermaProps.ReloadPermaProps() end) -- When the hook isn't call ...
function PermaProps.SparksEffect( ent )
local effectdata = EffectData()
effectdata:SetOrigin(ent:GetPos())
effectdata:SetMagnitude(2.5)
effectdata:SetScale(2)
effectdata:SetRadius(3)
util.Effect("Sparks", effectdata, true, true)
end
function PermaProps.IsUserGroup( ply, name )
if not ply:IsValid() then return false end
return ply:GetNetworkedString("UserGroup") == name
end
function PermaProps.IsAdmin( ply )
if ( PermaProps.IsUserGroup(ply, "superadmin") or false ) then return true end
if ( PermaProps.IsUserGroup(ply, "admin") or false ) then return true end
return false
end
function PermaProps.IsSuperAdmin( ply )
return ( PermaProps.IsUserGroup(ply, "superadmin") or false )
end
function PermaProps.UselessContent( tbl )
local function SortFcn( tbl2 )
for k, v in pairs( tbl2 ) do
if isfunction( v ) or isentity( v ) then
tbl2[k] = nil
elseif istable( v ) then
SortFcn( v )
end
end
return tbl2
end
for k, v in pairs( tbl ) do
if isfunction( v ) or isentity( v ) then
tbl[k] = nil
elseif istable( v ) then
SortFcn( v )
end
end
return tbl
end

View File

@@ -0,0 +1,185 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
util.AddNetworkString("pp_open_menu")
util.AddNetworkString("pp_info_send")
local function PermissionLoad()
if not PermaProps then PermaProps = {} end
if not PermaProps.Permissions then PermaProps.Permissions = {} end
PermaProps.Permissions["owner"] = { Physgun = true, Tool = true, Property = true, Save = true, Delete = true, Update = true, Menu = true, Permissions = true, Inherits = "admin", Custom = true }
-- PermaProps.Permissions["curator"] = { Physgun = true, Tool = true, Property = true, Save = true, Delete = true, Update = true, Menu = true, Permissions = true, Inherits = "admin", Custom = true }
-- PermaProps.Permissions["spec admin"] = { Physgun = true, Tool = true, Property = true, Save = true, Delete = true, Update = true, Menu = true, Permissions = true, Inherits = "admin", Custom = true }
PermaProps.Permissions["admin"] = { Physgun = false, Tool = false, Property = false, Save = true, Delete = true, Update = true, Menu = true, Permissions = true, Inherits = "user", Custom = true }
-- PermaProps.Permissions["user"] = { Physgun = false, Tool = false, Property = false, Save = false, Delete = false, Update = false, Menu = false, Permissions = false, Inherits = "user", Custom = true }
if CAMI then
for k, v in pairs(CAMI.GetUsergroups()) do
if k == "superadmin" or k == "admin" or k == "user" then continue end
PermaProps.Permissions[k] = { Physgun = false, Tool = false, Property = false, Save = false, Delete = false, Update = false, Menu = false, Permissions = false, Inherits = v.Inherits, Custom = false }
end
end
if file.Exists( "permaprops_config.txt", "DATA" ) then
file.Delete( "permaprops_config.txt" )
end
if file.Exists( "permaprops_permissions.txt", "DATA" ) then
local content = file.Read("permaprops_permissions.txt", "DATA")
local tablecontent = util.JSONToTable( content )
for k, v in pairs(tablecontent) do
if PermaProps.Permissions[k] == nil then
tablecontent[k] = nil
end
end
table.Merge(PermaProps.Permissions, ( tablecontent or {} ))
end
end
PermissionLoad()
local function PermissionSave()
file.Write( "permaprops_permissions.txt", util.TableToJSON(PermaProps.Permissions) )
end
local function pp_open_menu( ply )
if !PermaProps.HasPermission( ply, "Menu") then ply:ChatPrint("Access denied !") return end
local SendTable = {}
local Data_PropsList = sql.Query( "SELECT * FROM permaprops WHERE map = ".. sql.SQLStr(game.GetMap()) .. ";" )
if Data_PropsList and #Data_PropsList < 200 then
for k, v in pairs( Data_PropsList ) do
local data = util.JSONToTable(v.content)
SendTable[v.id] = {Model = data.Model, Class = data.Class, Pos = data.Pos, Angle = data.Angle}
end
elseif Data_PropsList and #Data_PropsList > 200 then -- Too much props dude :'(
for i = 1, 199 do
local data = util.JSONToTable(Data_PropsList[i].content)
SendTable[Data_PropsList[i].id] = {Model = data.Model, Class = data.Class, Pos = data.Pos, Angle = data.Angle}
end
end
local Content = {}
Content.MProps = tonumber(sql.QueryValue("SELECT COUNT(*) FROM permaprops WHERE map = ".. sql.SQLStr(game.GetMap()) .. ";"))
Content.TProps = tonumber(sql.QueryValue("SELECT COUNT(*) FROM permaprops;"))
Content.PropsList = SendTable
Content.Permissions = PermaProps.Permissions
local Data = util.TableToJSON( Content )
local Compressed = util.Compress( Data )
net.Start( "pp_open_menu" )
net.WriteFloat( Compressed:len() )
net.WriteData( Compressed, Compressed:len() )
net.Send( ply )
end
concommand.Add("pp_cfg_open", pp_open_menu)
local function pp_info_send( um, ply )
if !PermaProps.HasPermission( ply, "Menu") then ply:ChatPrint("Access denied !") return end
local Content = net.ReadTable()
if Content["CMD"] == "DEL" then
Content["Val"] = tonumber(Content["Val"])
if Content["Val"] != nil and Content["Val"] <= 0 then return end
sql.Query("DELETE FROM permaprops WHERE id = ".. sql.SQLStr(Content["Val"]) .. ";")
for k, v in pairs(ents.GetAll()) do
if v.PermaProps_ID == Content["Val"] then
ply:ChatPrint("You erased " .. v:GetClass() .. " with a model of " .. v:GetModel() .. " from the database.")
v:Remove()
break
end
end
elseif Content["CMD"] == "VAR" then
if PermaProps.Permissions[Content["Name"]] == nil or PermaProps.Permissions[Content["Name"]][Content["Data"]] == nil then return end
if !isbool(Content["Val"]) then return end
if Content["Name"] == "superadmin" and ( Content["Data"] == "Custom" or Content["Data"] == "Permissions" or Content["Data"] == "Menu" ) then return end
if !PermaProps.HasPermission( ply, "Permissions") then ply:ChatPrint("Access denied !") return end
PermaProps.Permissions[Content["Name"]][Content["Data"]] = Content["Val"]
PermissionSave()
elseif Content["CMD"] == "DEL_MAP" then
sql.Query( "DELETE FROM permaprops WHERE map = ".. sql.SQLStr(game.GetMap()) .. ";" )
PermaProps.ReloadPermaProps()
ply:ChatPrint("You erased all props from the map !")
elseif Content["CMD"] == "DEL_ALL" then
sql.Query( "DELETE FROM permaprops;" )
PermaProps.ReloadPermaProps()
ply:ChatPrint("You erased all props !")
elseif Content["CMD"] == "CLR_MAP" then
for k, v in pairs( ents.GetAll() ) do
if v.PermaProps == true then
v:Remove()
end
end
ply:ChatPrint("You have removed all props !")
end
end
net.Receive("pp_info_send", pp_info_send)

View File

@@ -0,0 +1,66 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
Thanks to ARitz Cracker for this part
*/
function PermaProps.HasPermission( ply, name )
if !PermaProps or !PermaProps.Permissions or !PermaProps.Permissions[ply:GetUserGroup()] then return false end
if PermaProps.Permissions[ply:GetUserGroup()].Custom == false and PermaProps.Permissions[ply:GetUserGroup()].Inherits and PermaProps.Permissions[PermaProps.Permissions[ply:GetUserGroup()].Inherits] then
return PermaProps.Permissions[PermaProps.Permissions[ply:GetUserGroup()].Inherits][name]
end
return PermaProps.Permissions[ply:GetUserGroup()][name]
end
local function PermaPropsPhys( ply, ent, phys )
if ent.PermaProps then
return PermaProps.HasPermission( ply, "Physgun")
end
end
hook.Add("PhysgunPickup", "PermaPropsPhys", PermaPropsPhys)
hook.Add( "CanPlayerUnfreeze", "PermaPropsUnfreeze", PermaPropsPhys) -- Prevents people from pressing RELOAD on the physgun
local function PermaPropsTool( ply, tr, tool )
if IsValid(tr.Entity) and tr.Entity.PermaProps then
if tool == "permaprops" then
return true
end
return PermaProps.HasPermission( ply, "Tool")
end
end
hook.Add( "CanTool", "PermaPropsTool", PermaPropsTool)
local function PermaPropsProperty( ply, property, ent )
if IsValid(ent) and ent.PermaProps and tool ~= "permaprops" then
return PermaProps.HasPermission( ply, "Property")
end
end
hook.Add( "CanProperty", "PermaPropsProperty", PermaPropsProperty)
timer.Simple(5, function() hook.Remove("CanTool", "textScreensPreventTools") end) -- Fuck OFF
timer.Simple(5, function() hook.Remove("CanTool", "textscreenpreventtools") end)

View File

@@ -0,0 +1,345 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
if not PermaProps then PermaProps = {} end
PermaProps.SpecialENTSSpawn = {}
PermaProps.SpecialENTSSpawn["gmod_lamp"] = function( ent, data)
ent:SetFlashlightTexture( data["Texture"] )
ent:SetLightFOV( data["fov"] )
ent:SetColor( Color( data["r"], data["g"], data["b"], 255 ) )
ent:SetDistance( data["distance"] )
ent:SetBrightness( data["brightness"] )
ent:Switch( true )
ent:Spawn()
ent.Texture = data["Texture"]
ent.KeyDown = data["KeyDown"]
ent.fov = data["fov"]
ent.distance = data["distance"]
ent.r = data["r"]
ent.g = data["g"]
ent.b = data["b"]
ent.brightness = data["brightness"]
return true
end
PermaProps.SpecialENTSSpawn["prop_vehicle_jeep"] = function( ent, data)
if ( ent:GetModel() == "models/buggy.mdl" ) then ent:SetKeyValue( "vehiclescript", "scripts/vehicles/jeep_test.txt" ) end
if ( ent:GetModel() == "models/vehicle.mdl" ) then ent:SetKeyValue( "vehiclescript", "scripts/vehicles/jalopy.txt" ) end
if ( data["VehicleTable"] && data["VehicleTable"].KeyValues ) then
for k, v in pairs( data["VehicleTable"].KeyValues ) do
ent:SetKeyValue( k, v )
end
end
ent:Spawn()
ent:Activate()
ent:SetVehicleClass( data["VehicleName"] )
ent.VehicleName = data["VehicleName"]
ent.VehicleTable = data["VehicleTable"]
ent.ClassOverride = data["Class"]
return true
end
PermaProps.SpecialENTSSpawn["prop_vehicle_jeep_old"] = PermaProps.SpecialENTSSpawn["prop_vehicle_jeep"]
PermaProps.SpecialENTSSpawn["prop_vehicle_airboat"] = PermaProps.SpecialENTSSpawn["prop_vehicle_jeep"]
PermaProps.SpecialENTSSpawn["prop_vehicle_prisoner_pod"] = PermaProps.SpecialENTSSpawn["prop_vehicle_jeep"]
PermaProps.SpecialENTSSpawn["prop_ragdoll"] = function( ent, data )
if !data or !istable( data ) then return end
ent:Spawn()
ent:Activate()
if data["Bones"] then
for objectid, objectdata in pairs( data["Bones"] ) do
local Phys = ent:GetPhysicsObjectNum( objectid )
if !IsValid( Phys ) then continue end
if ( isvector( objectdata.Pos ) && isangle( objectdata.Angle ) ) then
local pos, ang = LocalToWorld( objectdata.Pos, objectdata.Angle, Vector(0, 0, 0), Angle(0, 0, 0) )
Phys:SetPos( pos )
Phys:SetAngles( ang )
Phys:Wake()
if objectdata.Frozen then
Phys:EnableMotion( false )
end
end
end
end
if data["BoneManip"] and ent:IsValid() then
for k, v in pairs( data["BoneManip"] ) do
if ( v.s ) then ent:ManipulateBoneScale( k, v.s ) end
if ( v.a ) then ent:ManipulateBoneAngles( k, v.a ) end
if ( v.p ) then ent:ManipulateBonePosition( k, v.p ) end
end
end
if data["Flex"] and ent:IsValid() then
for k, v in pairs( data["Flex"] ) do
ent:SetFlexWeight( k, v )
end
if ( Scale ) then
ent:SetFlexScale( Scale )
end
end
return true
end
PermaProps.SpecialENTSSpawn["sammyservers_textscreen"] = function( ent, data )
if !data or !istable( data ) then return end
ent:Spawn()
ent:Activate()
if data["Lines"] then
for k, v in pairs(data["Lines"] or {}) do
ent:SetLine(k, v.text, Color(v.color.r, v.color.g, v.color.b, v.color.a), v.size, v.font)
end
end
return true
end
PermaProps.SpecialENTSSpawn["NPC"] = function( ent, data )
if data and istable( data ) then
if data["Equipment"] then
local valid = false
for _, v in pairs( list.Get( "NPCUsableWeapons" ) ) do
if v.class == data["Equipment"] then valid = true break end
end
if ( data["Equipment"] && data["Equipment"] != "none" && valid ) then
ent:SetKeyValue( "additionalequipment", data["Equipment"] )
ent.Equipment = data["Equipment"]
end
end
end
ent:Spawn()
ent:Activate()
return true
end
if list.Get( "NPC" ) and istable(list.Get( "NPC" )) then
for k, v in pairs(list.Get( "NPC" )) do
PermaProps.SpecialENTSSpawn[k] = PermaProps.SpecialENTSSpawn["NPC"]
end
end
PermaProps.SpecialENTSSpawn["item_ammo_crate"] = function( ent, data )
if data and istable(data) and data["type"] then
ent.type = data["type"]
ent:SetKeyValue( "AmmoType", math.Clamp( data["type"], 0, 9 ) )
end
ent:Spawn()
ent:Activate()
return true
end
PermaProps.SpecialENTSSave = {}
PermaProps.SpecialENTSSave["gmod_lamp"] = function( ent )
local content = {}
content.Other = {}
content.Other["Texture"] = ent.Texture
content.Other["KeyDown"] = ent.KeyDown
content.Other["fov"] = ent.fov
content.Other["distance"] = ent.distance
content.Other["r"] = ent.r
content.Other["g"] = ent.g
content.Other["b"] = ent.b
content.Other["brightness"] = ent.brightness
return content
end
PermaProps.SpecialENTSSave["prop_vehicle_jeep"] = function( ent )
if not ent.VehicleTable then return false end
local content = {}
content.Other = {}
content.Other["VehicleName"] = ent.VehicleName
content.Other["VehicleTable"] = ent.VehicleTable
content.Other["ClassOverride"] = ent.ClassOverride
return content
end
PermaProps.SpecialENTSSave["prop_vehicle_jeep_old"] = PermaProps.SpecialENTSSave["prop_vehicle_jeep"]
PermaProps.SpecialENTSSave["prop_vehicle_airboat"] = PermaProps.SpecialENTSSave["prop_vehicle_jeep"]
PermaProps.SpecialENTSSave["prop_vehicle_prisoner_pod"] = PermaProps.SpecialENTSSave["prop_vehicle_jeep"]
PermaProps.SpecialENTSSave["prop_ragdoll"] = function( ent )
local content = {}
content.Other = {}
content.Other["Bones"] = {}
local num = ent:GetPhysicsObjectCount()
for objectid = 0, num - 1 do
local obj = ent:GetPhysicsObjectNum( objectid )
if ( !obj:IsValid() ) then continue end
content.Other["Bones"][ objectid ] = {}
content.Other["Bones"][ objectid ].Pos = obj:GetPos()
content.Other["Bones"][ objectid ].Angle = obj:GetAngles()
content.Other["Bones"][ objectid ].Frozen = !obj:IsMoveable()
if ( obj:IsAsleep() ) then content.Other["Bones"][ objectid ].Sleep = true end
content.Other["Bones"][ objectid ].Pos, content.Other["Bones"][ objectid ].Angle = WorldToLocal( content.Other["Bones"][ objectid ].Pos, content.Other["Bones"][ objectid ].Angle, Vector( 0, 0, 0 ), Angle( 0, 0, 0 ) )
end
if ( ent:HasBoneManipulations() ) then
content.Other["BoneManip"] = {}
for i = 0, ent:GetBoneCount() do
local t = {}
local s = ent:GetManipulateBoneScale( i )
local a = ent:GetManipulateBoneAngles( i )
local p = ent:GetManipulateBonePosition( i )
if ( s != Vector( 1, 1, 1 ) ) then t[ 's' ] = s end -- scale
if ( a != Angle( 0, 0, 0 ) ) then t[ 'a' ] = a end -- angle
if ( p != Vector( 0, 0, 0 ) ) then t[ 'p' ] = p end -- position
if ( table.Count( t ) > 0 ) then
content.Other["BoneManip"][ i ] = t
end
end
end
content.Other["FlexScale"] = ent:GetFlexScale()
for i = 0, ent:GetFlexNum() do
local w = ent:GetFlexWeight( i )
if ( w != 0 ) then
content.Other["Flex"] = content.Other["Flex"] or {}
content.Other["Flex"][ i ] = w
end
end
return content
end
PermaProps.SpecialENTSSave["sammyservers_textscreen"] = function( ent )
local content = {}
content.Other = {}
content.Other["Lines"] = ent.lines or {}
return content
end
PermaProps.SpecialENTSSave["prop_effect"] = function( ent )
local content = {}
content.Class = "pp_prop_effect"
content.Model = ent.AttachedEntity:GetModel()
return content
end
PermaProps.SpecialENTSSave["pp_prop_effect"] = PermaProps.SpecialENTSSave["prop_effect"]
PermaProps.SpecialENTSSave["NPC"] = function( ent )
if !ent.Equipment then return {} end
local content = {}
content.Other = {}
content.Other["Equipment"] = ent.Equipment
return content
end
if list.Get( "NPC" ) and istable(list.Get( "NPC" )) then
for k, v in pairs(list.Get( "NPC" )) do
PermaProps.SpecialENTSSave[k] = PermaProps.SpecialENTSSave["NPC"]
end
end
PermaProps.SpecialENTSSave["item_ammo_crate"] = function( ent )
local content = {}
content.Other = {}
content.Other["type"] = ent.type
return content
end

View File

@@ -0,0 +1,30 @@
/*
____ _ _ ____ __ __ _ _
/ ___|___ __| | ___ __| | | __ ) _ _ | \/ | __ _| | |__ ___ _ __ ___
| | / _ \ / _` |/ _ \/ _` | | _ \| | | | | |\/| |/ _` | | '_ \ / _ \| '__/ _ \
| |__| (_) | (_| | __/ (_| | | |_) | |_| | | | | | (_| | | |_) | (_) | | | (_) |
\____\___/ \__,_|\___|\__,_| |____/ \__, | |_| |_|\__,_|_|_.__/ \___/|_| \___/
|___/
*/
sql.Query("CREATE TABLE IF NOT EXISTS permaprops('id' INTEGER NOT NULL, 'map' TEXT NOT NULL, 'content' TEXT NOT NULL, PRIMARY KEY('id'));")
if not PermaProps then PermaProps = {} end
PermaProps.SQL = {}
/* NOT WORKS AT THE MOMENT
PermaProps.SQL.MySQL = false
PermaProps.SQL.Host = "127.0.0.1"
PermaProps.SQL.Username = "username"
PermaProps.SQL.Password = "password"
PermaProps.SQL.Database_name = "PermaProps"
PermaProps.SQL.Database_port = 3306
PermaProps.SQL.Preferred_module = "mysqloo"
*/
function PermaProps.SQL.Query( data )
return sql.Query( data )
end

View File

@@ -0,0 +1,156 @@
/*
PermaProps
Created by Entoros, June 2010
Facepunch: http://www.facepunch.com/member.php?u=180808
Modified By Malboro 28 / 12 / 2012
Ideas:
Make permaprops cleanup-able
Errors:
Errors on die
Remake:
By Malboro the 28/12/2012
*/
TOOL.Category = "Props Tool"
TOOL.Name = "PermaProps"
TOOL.Command = nil
TOOL.ConfigName = ""
if CLIENT then
language.Add("Tool.permaprops.name", "PermaProps")
language.Add("Tool.permaprops.desc", "Save a props permanently")
language.Add("Tool.permaprops.0", "LeftClick: Add RightClick: Remove Reload: Update")
surface.CreateFont("PermaPropsToolScreenFont", { font = "Arial", size = 40, weight = 1000, antialias = true, additive = false })
surface.CreateFont("PermaPropsToolScreenSubFont", { font = "Arial", size = 30, weight = 1000, antialias = true, additive = false })
end
function TOOL:LeftClick(trace)
if CLIENT then return true end
local ent = trace.Entity
local ply = self:GetOwner()
if not PermaProps then ply:ChatPrint( "ERROR: Lib not found" ) return end
if !PermaProps.HasPermission( ply, "Save") then return end
if not ent:IsValid() then ply:ChatPrint( "That is not a valid entity !" ) return end
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
if ent.PermaProps then ply:ChatPrint( "That entity is already permanent !" ) return end
local content = PermaProps.PPGetEntTable(ent)
if not content then return end
local max = tonumber(sql.QueryValue("SELECT MAX(id) FROM permaprops;"))
if not max then max = 1 else max = max + 1 end
local new_ent = PermaProps.PPEntityFromTable(content, max)
if !new_ent or !new_ent:IsValid() then return end
PermaProps.SparksEffect( ent )
PermaProps.SQL.Query("INSERT INTO permaprops (id, map, content) VALUES(NULL, ".. sql.SQLStr(game.GetMap()) ..", ".. sql.SQLStr(util.TableToJSON(content)) ..");")
ply:ChatPrint("You saved " .. ent:GetClass() .. " with model ".. ent:GetModel() .. " to the database.")
ent:Remove()
return true
end
function TOOL:RightClick(trace)
if CLIENT then return true end
local ent = trace.Entity
local ply = self:GetOwner()
if not PermaProps then ply:ChatPrint( "ERROR: Lib not found" ) return end
if !PermaProps.HasPermission( ply, "Delete") then return end
if not ent:IsValid() then ply:ChatPrint( "That is not a valid entity !" ) return end
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
if not ent.PermaProps then ply:ChatPrint( "That is not a PermaProp !" ) return end
if not ent.PermaProps_ID then ply:ChatPrint( "ERROR: ID not found" ) return end
PermaProps.SQL.Query("DELETE FROM permaprops WHERE id = ".. ent.PermaProps_ID ..";")
ply:ChatPrint("You erased " .. ent:GetClass() .. " with a model of " .. ent:GetModel() .. " from the database.")
ent:Remove()
return true
end
function TOOL:Reload(trace)
if CLIENT then return true end
if not PermaProps then self:GetOwner():ChatPrint( "ERROR: Lib not found" ) return end
if (not trace.Entity:IsValid() and PermaProps.HasPermission( self:GetOwner(), "Update")) then self:GetOwner():ChatPrint( "You have reload all PermaProps !" ) PermaProps.ReloadPermaProps() return false end
if trace.Entity.PermaProps then
local ent = trace.Entity
local ply = self:GetOwner()
if !PermaProps.HasPermission( ply, "Update") then return end
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
local content = PermaProps.PPGetEntTable(ent)
if not content then return end
PermaProps.SQL.Query("UPDATE permaprops set content = ".. sql.SQLStr(util.TableToJSON(content)) .." WHERE id = ".. ent.PermaProps_ID .." AND map = ".. sql.SQLStr(game.GetMap()) .. ";")
local new_ent = PermaProps.PPEntityFromTable(content, ent.PermaProps_ID)
if !new_ent or !new_ent:IsValid() then return end
PermaProps.SparksEffect( ent )
ply:ChatPrint("You updated the " .. ent:GetClass() .. " in the database.")
ent:Remove()
else
return false
end
return true
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header",{Text = "PermaProps", Description = "PermaProps\n\nSaves entities across map changes\n"})
panel:AddControl("Button",{Label = "Open Configuration Menu", Command = "pp_cfg_open"})
end
function TOOL:DrawToolScreen(width, height)
if SERVER then return end
surface.SetDrawColor(17, 148, 240, 255)
surface.DrawRect(0, 0, 256, 256)
surface.SetFont("PermaPropsToolScreenFont")
local w, h = surface.GetTextSize(" ")
surface.SetFont("PermaPropsToolScreenSubFont")
local w2, h2 = surface.GetTextSize(" ")
draw.SimpleText("PermaProps", "PermaPropsToolScreenFont", 128, 100, Color(224, 224, 224, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(17, 148, 240, 255), 4)
draw.SimpleText("By Malboro", "PermaPropsToolScreenSubFont", 128, 128 + (h + h2) / 2 - 4, Color(224, 224, 224, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(17, 148, 240, 255), 4)
end