mirror of
https://github.com/CapsAdmin/pac3.git
synced 2025-03-04 03:03:01 -05:00
improved submit
improved pac2 conversion fixed selection in gmod 12 git-svn-id: http://gmodcapsadmin.googlecode.com/svn/trunk/addons/pac3@15 047d434e-d786-fb00-e516-99c5e643cd71
This commit is contained in:
parent
c6984b01d6
commit
37bd0b3b90
@ -41,11 +41,14 @@ end
|
||||
|
||||
function pac.ConvertPAC2Config(data, ent)
|
||||
local _out = {}
|
||||
|
||||
local base = pac.CreatePart("base")
|
||||
base:SetOwner(ent)
|
||||
base:SetName("pac2 outfit")
|
||||
|
||||
for bone, data in pairs(data.bones) do
|
||||
local part = pac.CreatePart("bone")
|
||||
local part = base:CreatePart("bone")
|
||||
part:SetName(bone)
|
||||
part:SetOwner(ent)
|
||||
part:SetBone(translate_bone(part, bones[bone]))
|
||||
part:SetSize(data.size)
|
||||
part:SetScale(data.scale)
|
||||
@ -55,9 +58,8 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
|
||||
for key, data in pairs(data.parts) do
|
||||
if data.sprite.Enabled then
|
||||
local part = pac.CreatePart("sprite")
|
||||
local part = base:CreatePart("sprite")
|
||||
part:SetName(data.name)
|
||||
part:SetOwner(ent)
|
||||
|
||||
if data.parent ~= "none" then
|
||||
part:SetParentName(data.parent)
|
||||
@ -76,9 +78,8 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
end
|
||||
|
||||
if data.light.Enabled then
|
||||
local part = pac.CreatePart("light")
|
||||
local part = base:CreatePart("light")
|
||||
part:SetName(data.name)
|
||||
part:SetOwner(ent)
|
||||
|
||||
if data.parent ~= "none" then
|
||||
part:SetParentName(data.parent)
|
||||
@ -92,13 +93,11 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
part:SetSize(data.light.Size)
|
||||
part:SetEyeAngles(data.eyeangles)
|
||||
part:SetWeaponClass(data.weaponclass)
|
||||
|
||||
end
|
||||
|
||||
if data.text.Enabled then
|
||||
local part = pac.CreatePart("text")
|
||||
local part = base:CreatePart("text")
|
||||
part:SetName(data.name)
|
||||
part:SetOwner(ent)
|
||||
|
||||
if data.parent ~= "none" then
|
||||
part:SetParentName(data.parent)
|
||||
@ -118,12 +117,11 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
part:SetSize(data.text.size)
|
||||
part:SetEyeAngles(data.eyeangles)
|
||||
part:SetWeaponClass(data.weaponclass)
|
||||
|
||||
end
|
||||
|
||||
if data.trail.Enabled then
|
||||
local part = pac.CreatePart("trail")
|
||||
part:SetOwner(ent)
|
||||
local part = base:CreatePart("trail")
|
||||
part:SetName(data.name .. " " .. part.ClassName)
|
||||
|
||||
part:SetStartSize(data.trail.startsize)
|
||||
part:SetColor(data.trail.color)
|
||||
@ -133,20 +131,18 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
end
|
||||
|
||||
if data.effect.Enabled then
|
||||
local part = pac.CreatePart("effect")
|
||||
part:SetOwner(ent)
|
||||
local part = base:CreatePart("effect")
|
||||
part:SetName(data.name .. " " .. part.ClassName)
|
||||
|
||||
part:SetLoop(data.effect.loop)
|
||||
part:SetRate(data.effect.rate)
|
||||
part:SetEffect(data.effect.effect)
|
||||
part:SetWeaponClass(data.weaponclass)
|
||||
|
||||
end
|
||||
|
||||
if data.color.a ~= 0 and data.size ~= 0 and data.scale ~= vector_origin then
|
||||
local part = pac.CreatePart("model")
|
||||
local part = base:CreatePart("model")
|
||||
part:SetName(data.name)
|
||||
part:SetOwner(ent)
|
||||
|
||||
part:SetWeaponClass(data.weaponclass)
|
||||
|
||||
@ -170,15 +166,16 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
part:SetEyeAngles(data.eyeangles)
|
||||
|
||||
if data.clip.Enabled then
|
||||
local part2 = pac.CreatePart("clip")
|
||||
part2:SetParent(part)
|
||||
local part2 = part:CreatePart("clip")
|
||||
part2:SetName(data.name .. " " .. part.ClassName)
|
||||
|
||||
part2:SetPosition(data.clip.angles:Forward() * data.clip.distance)
|
||||
part2:SetAngles(data.clip.angles)
|
||||
end
|
||||
|
||||
if data.animation.Enabled then
|
||||
local part2 = pac.CreatePart("animation")
|
||||
part2:SetParent(part)
|
||||
local part2 = part:CreatePart("animation")
|
||||
part2:SetName(data.name .. " " .. part.ClassName)
|
||||
part2:SetSequence(data.animation.sequence)
|
||||
part2:SetRate(data.animation.rate)
|
||||
part2:SetMin(data.animation.min)
|
||||
@ -197,10 +194,7 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
bone.size == "1"
|
||||
then continue end
|
||||
|
||||
local part2 = pac.CreatePart("bone")
|
||||
part2:SetParent(part)
|
||||
part2:SetOwner(part2:GetOwner())
|
||||
|
||||
local part2 = part:CreatePart("bone")
|
||||
part2:SetBone(translate_bone(part2, nil, key))
|
||||
|
||||
part2:SetScale(bone.scale)
|
||||
@ -212,15 +206,22 @@ function pac.ConvertPAC2Config(data, ent)
|
||||
end
|
||||
end
|
||||
|
||||
local base = pac.CreatePart("player")
|
||||
base:SetOwner(ent)
|
||||
base:SetName("player mod")
|
||||
local part = base:CreatePart("player")
|
||||
part:SetName("player mod")
|
||||
|
||||
part:SetColor(Vector(data.player_color.r, data.player_color.g, data.player_color.b))
|
||||
part:SetAlpha(data.player_color.a)
|
||||
part:SetMaterial(data.player_material)
|
||||
part:SetScale(data.overall_scale)
|
||||
part:SetDrawWeapon(data.drawwep)
|
||||
|
||||
base:SetColor(Vector(data.player_color.r, data.player_color.g, data.player_color.b))
|
||||
base:SetAlpha(data.player_color.a)
|
||||
base:SetMaterial(data.player_material)
|
||||
base:SetScale(data.overall_scale)
|
||||
base:SetDrawWeapon(data.drawwep)
|
||||
timer.Simple(1, function()
|
||||
for key, part in pairs(pac.GetParts()) do
|
||||
if not part:HasParent() then
|
||||
part:SetParentName("pac2 outfit")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return base
|
||||
end
|
||||
|
@ -14,6 +14,7 @@ function pac.CreatePart(name)
|
||||
part.Id = #pac.ActiveParts
|
||||
|
||||
part:SetName("part " .. #pac.ActiveParts)
|
||||
part:SetPlayerOwner(LocalPlayer())
|
||||
|
||||
pac.CallHook("OnPartCreated", part)
|
||||
|
||||
@ -84,6 +85,7 @@ do -- meta
|
||||
end
|
||||
|
||||
pac.GetSet(PART, "BoneIndex")
|
||||
pac.GetSet(PART, "PlayerOwner", NULL)
|
||||
pac.GetSet(PART, "Owner", NULL)
|
||||
pac.GetSet(PART, "Parent", pac.NULL)
|
||||
pac.GetSet(PART, "Tooltip")
|
||||
@ -152,8 +154,13 @@ do -- meta
|
||||
end
|
||||
end
|
||||
|
||||
do -- parts
|
||||
|
||||
do -- parenting
|
||||
function PART:CreatePart(name)
|
||||
local part = pac.CreatePart(name)
|
||||
self:AddChild(self)
|
||||
return part
|
||||
end
|
||||
|
||||
function PART:SetParent(var)
|
||||
if not var or not var:IsValid() then
|
||||
self:UnParent()
|
||||
@ -272,6 +279,13 @@ do -- meta
|
||||
|
||||
return children
|
||||
end
|
||||
|
||||
function PART:RemoveChildren()
|
||||
for key, part in pairs(self:GetChildren()) do
|
||||
part:Remove()
|
||||
end
|
||||
self.Children = {}
|
||||
end
|
||||
|
||||
function PART:GetChildByName(var)
|
||||
local parts = self:GetChildren()
|
||||
@ -375,6 +389,10 @@ do -- meta
|
||||
return self.StorableVars
|
||||
end
|
||||
|
||||
function PART:Clear()
|
||||
self:RemoveChildren()
|
||||
end
|
||||
|
||||
function PART:SetTable(tbl)
|
||||
for key, value in pairs(tbl.self) do
|
||||
if self["Set" .. key] then
|
||||
@ -437,7 +455,9 @@ do -- meta
|
||||
end
|
||||
|
||||
for key, part in pairs(self:GetChildren()) do
|
||||
part:Remove()
|
||||
if part:IsValid() then
|
||||
part:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
self:OnRemove()
|
||||
|
@ -29,7 +29,7 @@ function PART:RemoveClipPlane(id)
|
||||
end
|
||||
|
||||
function PART:GetOwner()
|
||||
return LocalPlayer()
|
||||
return self.PlayerOwner
|
||||
end
|
||||
|
||||
function PART:SetSize(var)
|
||||
|
@ -32,15 +32,20 @@ else
|
||||
end
|
||||
|
||||
function pac.SetSubmittedPart(ply, ent, tbl)
|
||||
print("received outfit from ", ply, " to set on ", ent)
|
||||
PrintTable(tbl)
|
||||
|
||||
for key, part in pairs(pac.GetParts()) do
|
||||
if part:GetOwner() == ent and part:GetName() == tbl.Name then
|
||||
if not part:HasParent() and part:GetPlayerOwner() == ply and part:GetName() == tbl.self.Name then
|
||||
part:Clear()
|
||||
part:SetOwner(ent)
|
||||
part:SetTable(tbl)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local part = pac.CreatePart(tbl.self.ClassName)
|
||||
part:SetPlayerOwner(ply)
|
||||
part:SetOwner(ent)
|
||||
part:SetTable(tbl)
|
||||
end
|
||||
|
@ -83,19 +83,9 @@ end
|
||||
|
||||
function pac.SubmitPart(data, ply)
|
||||
if net then
|
||||
local rp = player.GetAll()
|
||||
|
||||
if data.ply then
|
||||
for k,v in pairs(rp) do
|
||||
if data.ply == v then
|
||||
rp[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("pac_receive")
|
||||
net.WriteString(glon.encode(data))
|
||||
net.Send(ply or rp)
|
||||
net.Send(ply or player.GetAll())
|
||||
else
|
||||
local rp = RecipientFilter()
|
||||
rp:AddAllPlayers()
|
||||
@ -130,7 +120,7 @@ pac.AddHook("PlayerInitialSpawn")
|
||||
function pac.CheckSubmitPart(ply, data)
|
||||
local allowed, issue = true, ""
|
||||
|
||||
if CurTime() < (ply.LastPACSubmission or 0) + 0.3 then
|
||||
if (ply.LastPACSubmission or 0) > CurTime() then
|
||||
allowed, issue = false, "You must wait 1 second between submissions."
|
||||
end
|
||||
|
||||
@ -142,13 +132,14 @@ function pac.CheckSubmitPart(ply, data)
|
||||
allowed, issue = false, args[2]
|
||||
end
|
||||
|
||||
if allowed then
|
||||
if true or allowed then
|
||||
print(ply, " submitted outfit to ", data.ent)
|
||||
pac.SubmitPart(data)
|
||||
|
||||
pac.Parts[ply:EntIndex()] = pac.Parts[ply:EntIndex()] or {}
|
||||
table.insert(pac.Parts[ply:EntIndex()], data)
|
||||
|
||||
ply.LastPACSubmission = CurTime()
|
||||
ply.LastPACSubmission = CurTime() + 2
|
||||
umsg.Start("pac_submit_acknowledged", ply)
|
||||
umsg.Bool(allowed)
|
||||
umsg.String("")
|
||||
@ -162,7 +153,7 @@ function pac.CheckSubmitPart(ply, data)
|
||||
end
|
||||
|
||||
function pac.RemovePart(ply, data)
|
||||
if pac.IsAllowedToModify(ply, data.ent) then
|
||||
--if pac.IsAllowedToModify(ply, data.ent) then
|
||||
pac.Parts[ply:EntIndex()] = pac.Parts[ply:EntIndex()] or {}
|
||||
|
||||
pac.SubmitPart(data)
|
||||
@ -173,7 +164,7 @@ function pac.RemovePart(ply, data)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
--end
|
||||
end
|
||||
|
||||
local function handle_data(ply, data)
|
||||
|
@ -30,8 +30,8 @@ end
|
||||
|
||||
concommand.Add("pac_editor", function()
|
||||
pace.Panic()
|
||||
include("autorun/pac_init.lua")
|
||||
include("autorun/pace_init.lua")
|
||||
----include("autorun/pac_init.lua")
|
||||
--include("autorun/pace_init.lua")
|
||||
timer.Simple(0.1, function() pace.OpenEditor() end)
|
||||
end)
|
||||
|
||||
|
@ -165,7 +165,32 @@ end
|
||||
function pace.OnPartMenu(obj)
|
||||
local menu = DermaMenu()
|
||||
menu:SetPos(gui.MousePos())
|
||||
|
||||
if not obj:HasParent() then
|
||||
menu:AddOption("wear", function()
|
||||
pac.SubmitPart(obj:GetOwner(), obj)
|
||||
end)
|
||||
end
|
||||
|
||||
menu:AddOption("clone", function()
|
||||
obj:Clone()
|
||||
pace.RefreshTree()
|
||||
end)
|
||||
|
||||
menu:AddOption("set owner", function()
|
||||
pace.SelectEntity(function(ent)
|
||||
obj:SetOwner(ent)
|
||||
pace.SetViewEntity(ent)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
menu:AddSpacer()
|
||||
|
||||
add_parts(menu)
|
||||
|
||||
menu:AddSpacer()
|
||||
|
||||
menu:AddOption("save", function()
|
||||
pace.SavePartToFile(obj)
|
||||
CloseDermaMenus()
|
||||
@ -177,31 +202,9 @@ function pace.OnPartMenu(obj)
|
||||
CloseDermaMenus()
|
||||
end)
|
||||
|
||||
menu:AddOption("submit", function()
|
||||
pac.SubmitPart(obj:GetOwner(), obj)
|
||||
end)
|
||||
|
||||
menu:AddOption("clone", function()
|
||||
obj:Clone()
|
||||
pace.RefreshTree()
|
||||
end)
|
||||
|
||||
menu:AddSpacer()
|
||||
|
||||
add_parts(menu)
|
||||
|
||||
menu:AddSpacer()
|
||||
|
||||
menu:AddOption("owner", function()
|
||||
pace.SelectEntity(function(ent)
|
||||
obj:SetOwner(ent)
|
||||
pace.SetViewEntity(ent)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
menu:AddOption("remove", function()
|
||||
obj:Remove()
|
||||
pac.RemoveSubmittedPart(obj:GetPlayerOwner(), obj:GetOwner(), obj:GetName())
|
||||
pace.RefreshTree()
|
||||
end)
|
||||
|
||||
|
@ -29,7 +29,7 @@ end
|
||||
local R = function(event, name) if hook.GetTable()[event] and hook.GetTable()[event][name] then hook.Remove(event, name) end end
|
||||
function pace.StopSelect()
|
||||
R("GUIMousePressed", "pac_draw_select")
|
||||
R("PostDrawHUD", "pac_draw_select")
|
||||
R("HUDPaint", "pac_draw_select")
|
||||
R("HUDPaint", "pac_highlight")
|
||||
end
|
||||
|
||||
@ -45,7 +45,7 @@ function pace.SelectBone(ent, callback)
|
||||
end
|
||||
end
|
||||
|
||||
local function PostDrawHUD()
|
||||
local function HUDPaint()
|
||||
local x,y = gui.MousePos()
|
||||
local tbl = {}
|
||||
|
||||
@ -76,7 +76,7 @@ function pace.SelectBone(ent, callback)
|
||||
end
|
||||
|
||||
hook.Add("GUIMousePressed", "pac_draw_select", GUIMousePressed)
|
||||
hook.Add("PostDrawHUD", "pac_draw_select", PostDrawHUD)
|
||||
hook.Add("HUDPaint", "pac_draw_select", HUDPaint)
|
||||
end
|
||||
|
||||
function pace.SelectPart(parts, callback)
|
||||
@ -89,7 +89,7 @@ function pace.SelectPart(parts, callback)
|
||||
end
|
||||
end
|
||||
|
||||
local function PostDrawHUD()
|
||||
local function HUDPaint()
|
||||
local x,y = gui.MousePos()
|
||||
local tbl = {}
|
||||
|
||||
@ -118,7 +118,7 @@ function pace.SelectPart(parts, callback)
|
||||
end
|
||||
|
||||
hook.Add("GUIMousePressed", "pac_draw_select", GUIMousePressed)
|
||||
hook.Add("PostDrawHUD", "pac_draw_select", PostDrawHUD)
|
||||
hook.Add("HUDPaint", "pac_draw_select", HUDPaint)
|
||||
end
|
||||
|
||||
function pace.SelectEntity(callback)
|
||||
@ -131,7 +131,7 @@ function pace.SelectEntity(callback)
|
||||
end
|
||||
end
|
||||
|
||||
local function PostDrawHUD()
|
||||
local function HUDPaint()
|
||||
local x,y = gui.MousePos()
|
||||
local tbl = {}
|
||||
|
||||
@ -162,5 +162,5 @@ function pace.SelectEntity(callback)
|
||||
end
|
||||
|
||||
hook.Add("GUIMousePressed", "pac_draw_select", GUIMousePressed)
|
||||
hook.Add("PostDrawHUD", "pac_draw_select", PostDrawHUD)
|
||||
hook.Add("HUDPaint", "pac_draw_select", HUDPaint)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user