uclip/lua/autorun/sv_uclip.lua
Nayruden 16bedb5bf0 Bringing in uclip
The only change was info.txt -> addon.txt. Also fixed an outdated email address in UPS.
2012-11-03 16:16:52 -04:00

49 lines
1.4 KiB
Lua

-- Written by Team Ulysses, http://ulyssesmod.net/
module( "Uclip", package.seeall )
if not SERVER then return end
hasCPPI = false -- Common Prop Protection Interface to check for ownership
-- We'll check status of protectors in this init
function initUclip()
hasCPPI = (type( CPPI ) == "table")
if not hasCPPI then
noProtection = true
umsg.Start( "UclipNoProtection" ) -- In case there's anyone connected right now.
umsg.End()
end
end
hook.Add( "Initialize", "UclipInitialize", initUclip )
-- Tell them there's no prop protection in the event there isn't.
function initialSpawn( ply )
if noProtection then
umsg.Start( "UclipNoProtection", ply )
umsg.End()
end
end
hook.Add( "PlayerInitialSpawn", "UclipInitialSpawn", initialSpawn )
-- This function checks the protector to see if ownership has changed from what we think it is. Notifies player for c-side prediction too.
function updateOwnership( ply, ent )
if noProtection then return end -- No point on going on
if not ent.Uclip then ent.Uclip = {} end -- Initialize table
local owns
if hasCPPI then
owns = ent:CPPICanPhysgun( ply )
end
if owns == false then -- More convienent to store as nil, takes less memory and bandwidth!
owns = nil
end
if ent.Uclip[ ply ] ~= owns then
ent.Uclip[ ply ] = owns
umsg.Start( "UclipOwnershipUpdate", ply )
umsg.Entity( ent )
umsg.Bool( owns )
umsg.End()
end
end