Just a lua file which will grab a bunch of network strings and ids.
Just run it when you're on a server and will save to data/opennetfunctions inside of your garrysmod folder, with the string and id. inspiration for this
local Messages = {}
-- Method 1
local i = 1
local NetworkString = true
while NetworkString do
NetworkString = util.NetworkIDToString(i)
Messages[NetworkString] = true
i = i + 1
end
-- Method 2
for i = 1, math.huge do
local str = util.NetworkIDToString(i)
if not str then break end
Messages[str] = true
end
-- Method 3
local i = 1
local NetworkString = true
repeat
NetworkString = util.NetworkIDToString(i)
Messages[NetworkString] = true
i = i + 1
until not NetworkString
Personally I'd use the second method but all three do the same thing.
Also there's no need to use the server's IP in the created file's name, use GetHostName. It'll make it way easier to find if you join a shit ton of servers.
Originally Posted by Cyaegha
There are actually a few methods for doing this snip
Personally I'd use the second method but all three do the same thing.
Also there's no need to use the server's IP in the created file's name, use GetHostName. It'll make it way easier to find if you join a shit ton of servers.
GetHostName would always result in it not saving, so i didn't bother :/
with you saving it into a table, what does Messages[str] = true mean?
Originally Posted by ThatPurpleGuy
GetHostName would always result in it not saving, so i didn't bother :/
with you saving it into a table, what does Messages[str] = true mean?
It just makes checking if the table has the message more efficiently than using table.HasValue. With that method I can just check if the key exists by doing
Code:
if Messages["message"] then
instead of looping through the entire table to check for a value.
And to fix the GetHostName issue you could use string.gsub to replace non-alphanumeric characters.
Originally Posted by Cyaegha
There are actually a few methods for doing this
Code:
local Messages = {}
-- Method 1
local i = 1
local NetworkString = true
while NetworkString do
NetworkString = util.NetworkIDToString(i)
Messages[NetworkString] = true
i = i + 1
end
-- Method 2
for i = 1, math.huge do
local str = util.NetworkIDToString(i)
if not str then break end
Messages[str] = true
end
-- Method 3
local i = 1
local NetworkString = true
repeat
NetworkString = util.NetworkIDToString(i)
Messages[NetworkString] = true
i = i + 1
until not NetworkString
Personally I'd use the second method but all three do the same thing.
Also there's no need to use the server's IP in the created file's name, use GetHostName. It'll make it way easier to find if you join a shit ton of servers.
Code:
local Messages = {}
local i = 1
for i = 1, math.huge do
local str = util.NetworkIDToString(i)
if not str then break end
Messages[str] = true
print(str)
end
anyway to make it print only certain net messages?
Originally Posted by meme420
Code:
local Messages = {}
local i = 1
for i = 1, math.huge do
local str = util.NetworkIDToString(i)
if not str then break end
Messages[str] = true
print(str)
end
anyway to make it print only certain net messages?
search for specific string and if it matches print it
Originally Posted by 0x28
search for specific string and if it matches print it
That's good if you only have a couple messages. If you have a shit ton of messages you can put them in a table like
Code:
local tbl ={["Net message"] = true,}
then check if tbl[key] is true, you don't have to if you don't want to but it'd save you from typing
Code:
elseif msg == "string" then
a bunch of times.
dumb thread -rep it because i can
everyone here is a stupid, half-intellegent thirdworlder . i am an american who is not afraid to express his forum rights. all you mongs struggle with easy lua syntax issues and simple algorithm problems. ha ha ha, dont make me laugh. just yesterday, i programmed my reverse engineered i7 cpu to communicate back-and-fourth with me in machine code. all you nerds on UC and MPGH dont even know a lick of assembly either! hahaha. Terry Davis is a phony CIA ******. Reminder to everyone, whatever I say goes. Respect and worship the HolyC and it's covenant 640x480 resolution. Your absolution depends on it. This is a wakeup call for every wannabe hacker in this trash mobile site.