fixed player part being overridden by other player parts

you should now be able to see existing outfits when you join
set owner updates on server


git-svn-id: http://gmodcapsadmin.googlecode.com/svn/trunk/addons/pac3@47 047d434e-d786-fb00-e516-99c5e643cd71
This commit is contained in:
CapsAdmin 2012-06-08 01:45:29 +00:00
parent b61a290a33
commit 64806d2ec6
4 changed files with 37 additions and 30 deletions

View File

@ -3,7 +3,6 @@ function pac.PrePlayerDraw(ply)
for key, part in pairs(pac.GetParts()) do
if
part.ClassName ~= "player" and
not part:IsHidden() and
not part.Screenspace and
not part.Translucent and
@ -11,15 +10,6 @@ function pac.PrePlayerDraw(ply)
not part:HasParent()
then
part:Draw("OnDraw")
end
end
for key, part in pairs(pac.GetParts()) do
if
part.ClassName == "player" and
not part:IsHidden() and
part:GetOwner() == ply
then
part:Draw("PrePlayerDraw")
end
end
@ -31,7 +21,6 @@ function pac.PostPlayerDraw(ply)
for key, part in pairs(pac.GetParts()) do
if
part.ClassName ~= "player" and
not part:IsHidden() and
not part.Screenspace and
not part.Translucent and
@ -39,16 +28,7 @@ function pac.PostPlayerDraw(ply)
not part:HasParent()
then
part:Draw("OnDraw")
end
end
for key, part in pairs(pac.GetParts()) do
if
part.ClassName == "player" and
not part:IsHidden() and
part:GetOwner() == ply
then
part:Draw("PostPlayerDraw")
part:Draw("PostPlayerDraw")
end
end
end

View File

@ -71,6 +71,16 @@ function pac.SubmitRemove(ent, name)
end
end
function pac.SubmitOwner(a, b, name)
if net then
net.Start("pac_submit")
net.WriteString(glon.encode({a = a, b = b, part = name}))
net.SendToServer()
else
datastream.StreamToServer("pac_submit", {a = a, b = b, part = name})
end
end
function pac.Notify(allowed, reason)
if allowed then
chat.AddText(Color(255,255,0), "[PAC3] ", Color(0,255,0), "Your config has been applied.")

View File

@ -14,7 +14,7 @@ do -- hook helpers
local args = {pcall(func, ...)}
if not args[1] then
ErrorNoHalt(args[2] .. "\n")
table.insert(pac.Errors, args[2])
--table.insert(pac.Errors, args[2])
end
table.remove(args, 1)
return unpack(args)
@ -101,15 +101,12 @@ end
function pac.PlayerInitialSpawn(ply)
timer.Simple(1, function()
if ply:IsPlayer() then
for ent, data in pairs(pac.Parts) do
for ent, outfits in pairs(pac.Parts) do
if Entity(ent):IsValid() then
local data = data[#data]
if data then
local ent = data.ent or NULL
for key, outfit in pairs(outfits) do
local ent = outfit.ent or NULL
if ent:IsValid() then
local part = data[#data].part
pac.SubmitPart({ent = ent, part = part}, ply)
pac.SubmitPart(outfit, ply)
end
end
end
@ -171,10 +168,29 @@ function pac.RemovePart(ply, data)
--end
end
function pac.SetOwnerPart(ply, data)
print(ply, " is changing owner ", data.part)
--if pac.IsAllowedToModify(ply, data.ent) then
pac.Parts[ply:EntIndex()] = pac.Parts[ply:EntIndex()] or {}
for key, _data in pairs(pac.Parts[ply:EntIndex()]) do
if _data.part.self.Name == data.part then
_data.ent = data.b
pac.SubmitPart({ply = ply, ent = data.a, part = data.part})
pac.SubmitPart(_data)
break
end
end
--end
end
local function handle_data(ply, data)
if IsValid(data.ent) then
data.ply = ply
if type(data.part) == "table" then
if IsEntity(data.a) and data.a:IsValid() and IsEntity(data.b) and data.b:IsValid() then
pac.SetOwnerPart(ply, data)
elseif type(data.part) == "table" then
pac.CheckSubmitPart(ply, data)
elseif type(data.part) == "string" then
pac.RemovePart(ply, data)

View File

@ -177,6 +177,7 @@ function pace.OnPartMenu(obj)
menu:AddOption(L"set owner", function()
pace.SelectEntity(function(ent)
pac.SubmitOwner(obj:GetOwner(), ent, obj:GetName())
obj:SetOwner(ent)
pace.SetViewEntity(ent)
end)