Displaying number of traitors at the beginning of the round
2 replies, posted
I tried to create my own script to show the number of traitors at the beginning of the round. The script prints into everyones chat but every round it says there are only 0 traitors. I have placed this script in the lua/autorun/ folder as i'm unsure if it should go into the server folder.
[CODE]traitors = 0;
local function printTraitors()
timer.Create( "printingTraitors", 3, 1, printHelper )
end
function printHelper()
if CLIENT then
if (traitors == 1) then
chat.AddText(Color(255,150,0), "There is 1 Traitor this Round!!!")
chat.PlaySound()
else
chat.AddText(Color(255,150,0), "There are " .. traitors .. " Traitors this Round!!!")
chat.PlaySound()
end
end
WW
end
hook.Add("TTTBeginRound", "printTraitors", printTraitors)
hook.Add("TTTBeginRound", "printTraitors1", function()
for k, ply in pairs( player.GetAll() ) do
if ( ply:IsRole(ROLE_TRAITOR) ) then
traitors = (traitors + 1) end
end
end)
[/CODE]
if ply:GetRole() == ROLE_TRAITOR then
ply:IsTraitor() works perfectly for me.
Just use this:
[lua]hook.Add( "TTTBeginRound", "NameTraitors", function()
local traitors = 0
for k, v in pairs( player.GetAll() ) do
if v:IsTraitor() then traitors = traitors +1 end
end
timer.Simple( 3, function()
for k, v in pairs( player.GetAll() ) do
v:ChatPrint( traitors == 1 and "There is 1 Traitor this round." or "There are "..traitors.." Traitors this round." )
v:SendLua( "chat.PlaySound()" )
end
end )
end )[/lua]
Sorry, you need to Log In to post a reply to this thread.