What are ways to get some sort of unique id of a server in a addon.
One example for a server-sided solution would be the ip.
Does someone know other solutions that work either on client or on server? It is not necessary for the code to work on both sides.
[QUOTE=Fruitwesp;52143978][url]https://wiki.garrysmod.com/page/Steam_Game_Server_Accounts[/url][/QUOTE]
I don't want to set an id for my server, I want to get an id (not necessarily this one) in a lua addon
[QUOTE=Grunzwanzling;52144008]I don't want to set an id for my server, I want to get an id (not necessarily this one) in a lua addon[/QUOTE]
You could base64 encode variables like the ip, port, system OS, etc.
[url]http://wiki.garrysmod.com/page/util/Base64Encode[/url]
[QUOTE=Fruitwesp;52144019]You could base64 encode variables like the ip, port, system OS, etc.
[url]http://wiki.garrysmod.com/page/util/Base64Encode[/url][/QUOTE]
I had something like this in mind but how do I get those constants?
I would hash them to make the result pseudo-random.
You could use a UUID v4, which would make it be the same for a server whether it be moved or ip changed. You can see an implementation of it in wiremod [URL="https://github.com/wiremod/wire/blob/master/lua/wire/wireshared.lua#L373-L408"]here[/URL].
[QUOTE=Fruitwesp;52144098][url]http://wiki.garrysmod.com/page/game/GetIPAddress[/url]
[url]http://wiki.garrysmod.com/page/Category:system[/url][/QUOTE]
Thank you, but most of the functions only work clientside and can't be used for servers
[editline]25th April 2017[/editline]
[QUOTE=bigdogmat;52144147]You could use a UUID v4, which would make it be the same for a server whether it be moved or ip changed. You can see an implementation of it in wiremod [URL="https://github.com/wiremod/wire/blob/master/lua/wire/wireshared.lua#L373-L408"]here[/URL].[/QUOTE]
Aren't cookies stored on the client? They would stay the same on the client when thy switch servers but they can't identify the server. Or am I wrong?
[QUOTE=Grunzwanzling;52148242]Thank you, but most of the functions only work clientside and can't be used for servers[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/GetIPAddress]game.GetIPAddress[/url] and the `system.Is*` functions all work on the server afaik, if you want the information on the client just network it.
Though I'd still recommend a UUIDv4 for this.
[editline]25th April 2017[/editline]
[QUOTE=Grunzwanzling;52148242]
[editline]25th April 2017[/editline]
Aren't cookies stored on the client? They would stay the same on the client when thy switch servers but they can't identify the server. Or am I wrong?[/QUOTE]
They're stored in the state they're saved in. That's why in that code it networks it to the client.
Sorry, you need to Log In to post a reply to this thread.