forked from Nebual/NadmodPP
Addressed issues
This commit is contained in:
parent
646d7f022c
commit
e88a2499d1
@ -6,23 +6,28 @@
|
||||
if !NADMOD then
|
||||
NADMOD = {}
|
||||
NADMOD.PropOwners = {}
|
||||
NADMOD.PropNames = {}
|
||||
NADMOD.PPConfig = {}
|
||||
NADMOD.Friends = {}
|
||||
end
|
||||
|
||||
local Props = NADMOD.PropOwners
|
||||
local PropNames = NADMOD.PropNames
|
||||
net.Receive("nadmod_propowners",function(len)
|
||||
local set = {}
|
||||
local nameMap = {}
|
||||
for i=1, net.ReadUInt(8) do
|
||||
set[i] = net.ReadString()
|
||||
nameMap[i] = net.ReadString()
|
||||
end
|
||||
for i=1, net.ReadUInt(32) do
|
||||
local id, str = net.ReadUInt(16), set[net.ReadUInt(8)]
|
||||
local id, str = net.ReadUInt(16), nameMap[net.ReadUInt(8)]
|
||||
if id==0 then break end
|
||||
if str == "-" then Props[id] = nil
|
||||
elseif str == "W" then Props[id] = "World"
|
||||
elseif str == "O" then Props[id] = "Ownerless"
|
||||
else Props[id] = str
|
||||
if str == "-" then Props[id] = nil PropNames[id] = nil
|
||||
elseif str == "W" then PropNames[id] = "World"
|
||||
elseif str == "O" then PropNames[id] = "Ownerless"
|
||||
else
|
||||
Props[id] = str
|
||||
local ply = player.GetBySteamID(str)
|
||||
PropNames[id] = ply and ply:IsValid() and ply:Nick() or "N/A"
|
||||
end
|
||||
end
|
||||
end)
|
||||
@ -44,11 +49,14 @@ function NADMOD.PlayerCanTouch(ply, ent)
|
||||
end
|
||||
|
||||
-- Ownerless props can be touched by all
|
||||
if Props[index] == "O" then return true end
|
||||
if PropNames[index] == "Ownerless" then return true end
|
||||
-- Admins can touch anyones props + world
|
||||
if NADMOD.PPConfig["adminall"] and NADMOD.IsPPAdmin(ply) then return true end
|
||||
-- Players can touch their own props and friends
|
||||
if Props[index] == ply:SteamID() then return true end
|
||||
-- Players can touch their own props
|
||||
local plySteam = ply:SteamID()
|
||||
if Props[index] == plySteam then return true end
|
||||
-- Friends can touch LocalPlayer()'s props
|
||||
if Props[index] == LocalPlayer():SteamID() and NADMOD.Friends[plySteam] then return true end
|
||||
|
||||
return false
|
||||
end
|
||||
@ -72,14 +80,7 @@ hook.Add("HUDPaint", "NADMOD.HUDPaint", function()
|
||||
if !tr.HitNonWorld then return end
|
||||
local ent = tr.Entity
|
||||
if ent:IsValid() && !ent:IsPlayer() then
|
||||
local index = ent:EntIndex()
|
||||
local text
|
||||
local owner = NADMOD.GetPropOwner(ent)
|
||||
if owner and owner:IsValid() then
|
||||
text = "Owner: " .. owner:Nick()
|
||||
else
|
||||
text = "Owner: N/A"
|
||||
end
|
||||
local text = "Owner: " .. (PropNames[ent:EntIndex()] or "N/A")
|
||||
surface.SetFont(font)
|
||||
local Width, Height = surface.GetTextSize(text)
|
||||
local boxWidth = Width + 25
|
||||
|
@ -82,26 +82,26 @@ end
|
||||
|
||||
function NADMOD.SendPropOwners(props, ply)
|
||||
net.Start("nadmod_propowners")
|
||||
local seti = 1
|
||||
local set = {}
|
||||
local nameMap = {}
|
||||
local nameMapi = 0
|
||||
local count = 0
|
||||
for k,v in pairs(props) do
|
||||
if not set[v] then
|
||||
set[v] = seti
|
||||
set[seti] = v
|
||||
seti = seti + 1
|
||||
if not nameMap[v] then
|
||||
nameMapi = nameMapi + 1
|
||||
nameMap[v] = nameMapi
|
||||
nameMap[nameMapi] = v
|
||||
end
|
||||
count = count + 1
|
||||
end
|
||||
net.WriteUInt(seti-1,8)
|
||||
for i=1, seti-1 do
|
||||
net.WriteString(set[i])
|
||||
net.WriteUInt(nameMapi,8)
|
||||
for i=1, nameMapi do
|
||||
net.WriteString(nameMap[i])
|
||||
end
|
||||
|
||||
net.WriteUInt(count,32)
|
||||
for k,v in pairs(props) do
|
||||
net.WriteUInt(k,16)
|
||||
net.WriteUInt(set[v],8)
|
||||
net.WriteUInt(nameMap[v],8)
|
||||
end
|
||||
if ply then net.Send(ply) else net.Broadcast() end
|
||||
end
|
||||
@ -109,7 +109,7 @@ end
|
||||
function NADMOD.RefreshOwners()
|
||||
if not timer.Exists("NADMOD.RefreshOwners") then
|
||||
timer.Create("NADMOD.RefreshOwners", 0, 1, function()
|
||||
NADMOD.SendPropOwners(NADMOD.PropOwnersSmall, ply)
|
||||
NADMOD.SendPropOwners(NADMOD.PropOwnersSmall)
|
||||
NADMOD.PropOwnersSmall = {}
|
||||
end)
|
||||
end
|
||||
@ -416,7 +416,7 @@ end
|
||||
function NADMOD.CleanPlayer(ply, tar)
|
||||
if IsValid(tar) and tar:IsPlayer() then
|
||||
local count = NADMOD.CleanupPlayerProps(tar:SteamID())
|
||||
NADMOD.Notify(ply:Nick().. " cleaned up " ..tar:Nick().."'s props ("..count..")")
|
||||
NADMOD.Notify((ply:IsValid() and ply:Nick() or "Console") .. " cleaned up " ..tar:Nick().."'s props ("..count..")")
|
||||
end
|
||||
end
|
||||
|
||||
@ -449,7 +449,7 @@ function NADMOD.CleanName(ply, cmd, args, fullstr)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
NADMOD.Notify(ply:Nick() .. " cleaned up " ..fullstr.."'s props ("..count..")")
|
||||
NADMOD.Notify((ply:IsValid() and ply:Nick() or "Console") .. " cleaned up " ..fullstr.."'s props ("..count..")")
|
||||
end
|
||||
concommand.Add("nadmod_cleanname",NADMOD.CleanName)
|
||||
|
||||
@ -588,7 +588,7 @@ end
|
||||
function metaent:CPPIGetOwner() return self.SPPOwner end
|
||||
function metaent:CPPISetOwner(ply) return NADMOD.PlayerMakePropOwner(ply, self) end
|
||||
function metaent:CPPICanTool(ply,mode) return NADMOD.CanTool(ply,{Entity=self},mode) != false end
|
||||
function metaent:CPPICanPhysgun(ply) return NADMOD.PlayerCanTouch(ply,self) end
|
||||
function metaent:CPPICanPhysgun(ply) return NADMOD.PlayerCanTouch(ply,self) == true end
|
||||
function metaent:CPPICanPickup(ply) return NADMOD.GravGunPickup(ply, self) != false end
|
||||
function metaent:CPPICanPunt(ply) return NADMOD.GravGunPickup(ply, self) != false end
|
||||
if E2Lib and E2Lib.replace_function then
|
||||
|
Loading…
Reference in New Issue
Block a user