10-25-2015, 06:57 AM
The math.floor calls are necessary, Lua would round the numbers otherwise and thus breaking the format for example for length 255 (string.byte(255/256) == "\1" instead of the needed "\0"). This code should work for all string lengths up to 64K, which is the packet's maximum.