Drawing a square above every player in a table for nut script plugin
0 replies, posted
So here is the situation right now. I'm trying to create a squad system for nut script that will allow players to join squads. When a player is in a squad, a little green square will pop up above their head for their squad mates. What I'm trying to do with the script below is have a square pop up above players in the table alfa that will appear for everyone through the walls. But when I run the command, it doesn't paint a square over their heads. I just want to know what to know how to fix it. It works if I replace the table alfa with players.GetAll() in the HUDPaint hook, so I can't understand why this isn't working.
[code]
alfa = {}
if CLIENT then
hook.Add( "HUDPaint", "3d_camera_example", function()
local ang = EyeAngles()
local newang = Angle(ang.x + 90, ang.y, ang.z)
cam.Start3D()
for id, ply in pairs( alfa ) do
local pos = ply:GetPos()
local newpos = Vector(pos.x, pos.y, pos.z + 80)
cam.Start3D2D( newpos, newang, 1 )
surface.SetDrawColor( Color( 100, 255, 100, 255 ) )
surface.DrawOutlinedRect( 0, 0, 4, 4 )
cam.End3D2D()
end
cam.End3D()
end )
end
nut.command.add("squad", {
onRun = function(client, arguments)
if table.HasValue(alfa, client) then
for k, v in pairs(alfa) do
if v == client then
table.remove(alfa, k)
client:notify("You have left the squad.")
end
end
elseif !table.HasValue(alfa, client) then
table.Add(alfa, {k = client})
client:notify("You have joined a squad.")
end
end
})
[/code]
Sorry, you need to Log In to post a reply to this thread.