Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tDrawPlayers = {}
- local uDrawPlayers = 0
- function AddDrawPlayer(pPlayer)
- -- Only increment if the player isn't already in the table
- if (not tDrawPlayers[pPlayer]) then
- uDrawPlayers = uDrawPlayers + 1
- tDrawPlayers[uDrawPlayers] = pPlayer -- Store in array for quick iteration
- tDrawPlayers[pPlayer] = uDrawPlayers -- Store in hash for quick lookup
- end
- end
- function RemoveDrawPlayer(pPlayer)
- local uIndex = tDrawPlayers[pPlayer]
- if (uIndex ~= nil) then
- -- If we removed the tail, just do a normal removal
- if (uIndex == uDrawPlayers) then
- tDrawPlayers[pPlayer] = nil
- tDrawPlayers[uIndex] = nil
- -- If we removed a player in the middle of the array
- -- fill the hole with the tail
- else
- local pLastPlayer = tDrawPlayers[uDrawPlayers]
- tDrawPlayers[uIndex] = pLastPlayer
- tDrawPlayers[pLastPlayer] = uIndex -- Update the index in the hash entry
- tDrawPlayers[uDrawPlayers] = nil
- end
- uDrawPlayers = uDrawPlayers - 1
- end
- end
- local bDontDrawPlayers = false
- -- Don't draw any of our targetted players between PreRender and PostRender
- hook.Add("PreRender", "foo", function()
- bDontDrawPlayers = true
- end)
- hook.Add("PrePlayerDraw", "foo", function(pPlayer)
- if (bDontDrawPlayers and tDrawPlayers[pPlayer] ~= nil) then
- return true
- end
- end)
- hook.Add("PostRender", "foo", function()
- bDontDrawPlayers = false
- if (uDrawPlayers ~= 0) then
- cam.Start3D()
- for i = 1, uDrawPlayers do
- tDrawPlayers[uDrawPlayers]:DrawModel()
- end
- cam.End3D()
- end
- -- Leave the skip-draw bool as false so any player rendering outside of the standard render context aren't blocked
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement