• Send some variables by server to client side
    3 replies, posted
Hello. Excuse me for any grammatical errors. I have a function in server-side and I want to put a notification, but I can put the notification only in client side, so I have to send some variable by the function in the server-side to the client-side: Example: (Server) [CODE] hook.Add("AServerSideHook", "example", function() --I can use this hook only serverside local number = 10 if ply:Alive then number = number + 20 else number = number - 5 end end [/CODE] Now I want to use the code "notification.AddLegacy" to warn the player that his number is 30 or 5 but notification.AddLegacy works only client-side [CODE] function notification() notification.AddLegacy( "Hey your number value is "..number.." !", NOTIFY_UNDO, 4 ) end [/CODE] I think that I have to use something like net.write, but I don't know how to use it. Someone can help me? Thank you!
Basically, you need to use the [URL="http://wiki.garrysmod.com/page/Category:net"]net library[/URL]. First you need to use [URL="http://wiki.garrysmod.com/page/util/AddNetworkString"]util.AddNetworkString[/URL]. Then use [URL="http://wiki.garrysmod.com/page/net/Start"]net.Start[/URL], [URL="http://wiki.garrysmod.com/page/net/WriteInt"]net.WriteInt[/URL], and [URL="http://wiki.garrysmod.com/page/net/Send"]net.Send[/URL]. On the client side, use [URL="http://wiki.garrysmod.com/page/net/Receive"]net.Receive[/URL] to and [URL="http://wiki.garrysmod.com/page/net/ReadInt"]net.ReadInt[/URL] to receive the variable
[url]https://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=JasonMan34;50993598]Basically, you need to use the [URL="http://wiki.garrysmod.com/page/Category:net"]net library[/URL]. First you need to use [URL="http://wiki.garrysmod.com/page/util/AddNetworkString"]util.AddNetworkString[/URL]. Then use [URL="http://wiki.garrysmod.com/page/net/Start"]net.Start[/URL], [URL="http://wiki.garrysmod.com/page/net/WriteInt"]net.WriteInt[/URL], and [URL="http://wiki.garrysmod.com/page/net/Send"]net.Send[/URL]. On the client side, use [URL="http://wiki.garrysmod.com/page/net/Receive"]net.Receive[/URL] to and [URL="http://wiki.garrysmod.com/page/net/ReadInt"]net.ReadInt[/URL] to receive the variable[/QUOTE] Thank you!
Sorry, you need to Log In to post a reply to this thread.