Hi, i wanted with this code for ttt to make traitors see their team through walls with an aura on their bodies. I do not get whats wrong on this code, could you tell me?
[CODE]local traidores = {}
hook.Add("TTTBeginRound", "Tplayer", function()
local i = 0
if CLIENT and LocalPlayer():GetRole() == ROLE_TRAITOR then
for k,v in pairs(player.GetAll()) do
if v:GetRole() == ROLE_TRAITOR then
traidores[i] = v
i = i+1
end
end
end
end)
hook.Add( "PreDrawHalos", "AddHalos", function()
if GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():GetRole() == ROLE_TRAITOR then
timer.Simple(4,function()
halo.Add( traidores, Color( 255, 0, 0 ), 5, 5, 2 )
end)
end
end )[/CODE]
traidores seems to be null when the round starts :(
Try using [URL="https://wiki.garrysmod.com/page/table/insert"]table.insert()[/URL] and see if that changes anything.
table.insert() worked! Thank you :)
It's because you're mixing realms. Scrap the clientside only:
[code]local traidores = {}
hook.Add("TTTBeginRound", "Tplayer", function()
local players = player.GetAll()
local player = NULL
for i = 0, #players
player = players[i]
if ( IsValid( player ) and player:GetRole() == ROLE_TRAITOR ) then
traidores[ #traidores + 1 ] = player
end
end
end)[/code]
Sorry, you need to Log In to post a reply to this thread.