player:GetInfo() not working right?

Ok, so I have this hook on InitialSpawn:

[lua]
hook.Add( “PlayerInitialSpawn”, “Derp”, function( pl )
print( pl:GetInfo( “currentvar” ) )
end )
[/lua]

And the client has the console variable “currentvar” set on join already, so that’s not a problem.

Here’s the problem:

Output: “”

It ouputs a blank string until I refresh the con var on the client. I tried making the client set the console variable through lua, but it still does nothing until you actually type it out in console yourself.

Any idea why this would be happening?

Can you post the code where you create the ConVar and the code where you set it please.

Well I used this code:

SERVER-SIDE
[lua]
hook.Add( “PlayerInitialSpawn”, “Derp”, function( pl )
timer.Simple( 1, function()
umsg.Start( “Var”, pl )
umsg.End()
end )

timer.Simple( 3, function()
	print( pl:GetInfo( "currentvar" ) )  
end )

end )
[/lua]

CLIENT-SIDE
[lua]
usermessage.Hook( “Var”, function( um )
RunConsoleCommand( “currentvar”, GetConVar( “currentvar” ):GetString() )
end )
[/lua]

So you’re setting the convar to the value of the convar.

Yes, to refresh it, but it’s not refreshing it. :confused:

Did you mean this?

**[G.CreateClientConVar

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.CreateClientConVar)**

Oh, well yes, I’ve already done that and it’s already set to something when I join. I made sure by typing in “currentvar” in my console before joining the server and it was set to “yes.” But when I get in the server it says it is “”

Why are you even doing that? There is no point at all…

Yes there is. For what I’m doing there is.

What are you even trying to do? We can’t help unless you tell us.