This is supposed to show a box with the time left in it, but it doesnt do anything. Not even an error.
cl_init.lua
[CODE]function ShowTimer()
Local Roundcount = (Rounds * 240)
local RoundEnd = (RealTime() + Roundcount)
if (CurTime() == RoundEnd) then
Switch()
else
draw.RoundedBox(3, 5, 5, 200, 100, Color(51, 58, 51, 255))
draw.SimpleText(RoundEnd, "ScoreboardText", ScrW() / 2, ScrH() - 63, Color(86, 104, 86, 230), ALIGN_CENTER, ALIGN_TOP)
end
end
hook.Add( "Think", "ShowTheTimer", ShowTimer)[/CODE]
init.lua
[CODE]function Switch(p, key)
if ( p:Team( )== TEAM_BARRELS ) then
p:Kill( )
p:SetTeam( TEAM_HUMANS )
p:PrintMessage(HUD_PRINTTALK,"Teams have been switched! You're now on the humans team.");
p:SprintEnable ()
p:AddFrags(1)
else
p:Kill( )
p:SetTeam( TEAM_BARRELS )
p:PrintMessage(HUD_PRINTTALK,"Teams have been switched! You're now on the barrels team.");
p:SprintDisable ()
p:AddFrags(1)
Rounds = (Rounds + 1)
end
end
[/CODE]
You cant call a serverside function like that on client
So do I just copy and paste it into shared?
[QUOTE=almost cool;21523682]So do I just copy and paste it into shared?[/QUOTE]
It doesn't work like that, client and server are completely different instances of Lua. You need to use usermessages/concommands to communicate between them.
[QUOTE=almost cool;21523682]So do I just copy and paste it into shared?[/QUOTE]
Make one timer on the the server to run the function and one timer on the client to show how long till timer on server is done
Now I tried this, and it still didnt do anything.
cl_init.lua
[CODE]function ShowTimer()
local RoundEnd = (240 - RealTime())
draw.RoundedBox(3, 5, 5, 200, 100, Color(51, 58, 51, 255))
draw.SimpleText(RoundEnd, "ScoreboardText", ScrW() / 2, ScrH() - 63, Color(86, 104, 86, 230), ALIGN_CENTER, ALIGN_TOP)
end
hook.Add( "Think", "ShowTheTimer", ShowTimer)[/CODE]
init.lua
[CODE]function Switch(p, key)
if ( p:Team( )== TEAM_BARRELS ) then
p:Kill( )
p:SetTeam( TEAM_HUMANS )
p:PrintMessage(HUD_PRINTTALK,"Teams have been switched! You're now on the humans team.");
p:SprintEnable ()
p:AddFrags(1)
else
p:Kill( )
p:SetTeam( TEAM_BARRELS )
p:PrintMessage(HUD_PRINTTALK,"Teams have been switched! You're now on the barrels team.");
p:SprintDisable ()
p:AddFrags(1)
timer.Simple( 240, Switch )
end
end [/CODE]
try this
[lua]
function ShowTimer()
local RoundEnd = 240
draw.RoundedBox(3, 5, 5, 200, 100, Color(51, 58, 51, 255))
if CurTime() + RoundEnd < CurTime() then
draw.SimpleText("Round Over", "ScoreboardText", ScrW() / 2, ScrH() - 63, Color(86, 104, 86, 230), ALIGN_CENTER, ALIGN_TOP)
else
draw.SimpleText(string.ToMinutesSeconds(CurTime() + RoundEnd - CurTime()), "ScoreboardText", ScrW() / 2, ScrH() - 63, Color(86, 104, 86, 230), ALIGN_CENTER, ALIGN_TOP)
end
end
hook.Add( "HUDPaint", "ShowTheTimer", ShowTimer)
[/lua]
Untested and wrote in quick reply but it should work
That works! thx
Sorry, you need to Log In to post a reply to this thread.