Because client can't use SetNWInt I need to know how can server read client variables
Sorry,my English is not so good
please help me
GetNWInt
Use the [url=http://wiki.garrysmod.com/page/Net_Library_Usage]Net Library[/url] to tell the server to SetNWInt, eg:
[lua]if SERVER then
util.AddNetworkString( "SetNWInt" )
net.Receive( "SetNWInt", function( len, ply ) -- ply == person who sent message
ply:SetNWInt( "MyNWInt", net.ReadInt() )
end )
end
if CLIENT then
net.Start( "SetNWInt" )
net.WriteInt( 10, 16 ) -- 16 bytes
net.SendToServer()
end[/lua]
[QUOTE=Internet1001;44951158]Use the [url=http://wiki.garrysmod.com/page/Net_Library_Usage]Net Library[/url] to tell the server to SetNWInt, eg:
[lua]if SERVER then
util.AddNetworkString( "SetNWInt" )
net.Receive( "SetNWInt", function( len, ply ) -- ply == person who sent message
ply:SetNWInt( "MyNWInt", net.ReadInt() )
end )
end
if CLIENT then
net.Start( "SetNWInt" )
net.WriteInt( 10, 16 ) -- 16 bytes
net.SendToServer()
end[/lua][/QUOTE]
why not just share variables with the server to the client and likewise, and verifying them on the server?
I don't understand what you mean, do you suggest the client SetNWInt themselves? Because in that case the server will not synchronize it.
[QUOTE=Internet1001;44951193]I don't understand what you mean, do you suggest the client SetNWInt themselves? Because in that case the server will not synchronize it.[/QUOTE]
no like, on player join, server sends a table to player
player updates table when he gets more or less of something (e.g money), then he sends the table back to the server and the server syncronizes it
The player wouldn't update money upon getting it, the server would update the client using net.Send().
Presumably if you want the player to "collect" the money, it would be an entity like in DarkRP, and when collected the server will add the money to a serverside variable (and then sync that with the client).
[QUOTE=Mors Quaedam;44951324]The player wouldn't update money upon getting it, the server would update the client using net.Send().
Presumably if you want the player to "collect" the money, it would be an entity like in DarkRP, and when collected the server will add the money to a serverside variable (and then sync that with the client).[/QUOTE]
exactly, what I meant -- thanks.
Sorry, you need to Log In to post a reply to this thread.