So I'm using this script [CODE]util.AddNetworkString( 'GoToSpec' )
util.AddNetworkString( 'ReturnFromSpec' )
function SpecCommand( ply, text, public )
if ( string.sub(text, 1, 5) == "!spec" ) then
if ply:GetInfoNum( "ttt_spectator_mode", 0 ) == 0 then
net.Start ( 'GoToSpec' )
net.Send ( ply )
else
net.Start ( 'ReturnFromSpec' )
net.Send ( ply )
end
return("")
end
end
hook.Add( "PlayerSay", "SpecCommand", SpecCommand )[/CODE]
For some reason ply:GetInfoNum can't get the ttt_spectator_mode value and always returns 0.
I've tried using other ConVars (sv_cheats, cl_clock_correction) and they don't work either.
You can't use it server side to get a client side ConVar...
[editline]18th July 2015[/editline]
Fixed.
I just got the ConVar client-side
Serverside code:
[CODE]util.AddNetworkString( 'speccommandstring' )
function SpecCommand( ply, text, public )
if ( string.sub(text, 1, 5) == "!spec" ) then
net.Start ( 'speccommandstring' )
net.Send ( ply )
end
return("")
end
hook.Add( "PlayerSay", "SpecCommand", SpecCommand )[/CODE]
Clientside code:
[CODE]function CommandSpec()
if GetConVar("ttt_spectator_mode"):GetInt() == 0 then
LocalPlayer():ConCommand( "ttt_spectator_mode 1" )
LocalPlayer():ChatPrint( "You are now spectating!" )
else
LocalPlayer():ConCommand( "ttt_spectator_mode 0" )
LocalPlayer():ChatPrint( "You are no longer spectating!" )
end
end
net.Receive( 'speccommandstring', CommandSpec )[/CODE]
Sorry, you need to Log In to post a reply to this thread.