From my understanding, network vars only update ents in there PVS?
So If I set a network var on a player (server-side) and another player (outside the set players PVS) calls GetNWInit (client-side) to grab that set variable on the other player. He won't be able to retrieve it?
(I'm trying to allow other players to see other players saved information when they have there crosshair over them)
Also, is there any downside in querying the SQLLite server alot instead of Set/Get networked vars?
Yes setting a NetworkedVar clientside will only set it for that client. Unless these values are constantly changing, consider using Usermessages. [b][url=http://wiki.garrysmod.com/?title=Entity.SetNetworkedVar]Entity.SetNetworkedVar [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [b][url=http://wiki.garrysmod.com/?title=Umsg.Start]Umsg.Start [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
How often are you running queries from the SQLite db?
[QUOTE=Chuteuk;35216378]Yes setting a NetworkedVar clientside will only set it for that client. Unless these values are constantly changing, consider using Usermessages. [b][url=http://wiki.garrysmod.com/?title=Entity.SetNetworkedVar]Entity.SetNetworkedVar [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [b][url=http://wiki.garrysmod.com/?title=Umsg.Start]Umsg.Start [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
How often are you running queries from the SQLite db?[/QUOTE]
Well, inside HUDPaint, I do a trace that checks for players you are viewing. So it would be alot.
But i'm setting the network var server side. But would like to RETRIEVE it client-side, but it could be any player. Hard for me to explain
pseudoish code that shows what i'm trying todo.
[lua]
#if CLIENT
function GM:HUDPaint()
// do trace
// run TracedPlayer:GetNWInit("whatwhat")
end function
#end
#if SERVER
function setvar()
// set SomePlayer:SetNWInit("whatwhat") = 10
end function
#end
[/lua]
So currently I load information from the SQL server, into a network var (server-side) for a specific player.
Then I would like a DIFFERENT player to be able to retrieve that information. (client-side)
[QUOTE=Drak_Thing;35218943]Well, inside HUDPaint, I do a trace that checks for players you are viewing. So it would be alot.
-snip-[/QUOTE]
I am not sure of the actual code solution to this, but I would just like to point out that you should avoid hitting that database so often - avoid it at all costs. I think a possible solution would be to load all of the values you want to access into a table stored on the server (not in the database, but in a LUA table of some kind). And then when you need to retrieve the values for a given player, look up the respective table from your serverside variable instead of actually hitting the database.
Does that make sense?
I hope this helps!
Sorry, you need to Log In to post a reply to this thread.