I think we misunderstood each other by different perception of what "order" is. What I mean by order refers to all packets sent by a client, no matter what is their content.Sekaru wrote:Assuming we have 3 players online, let's assume they all send these things:
P1 Sends: Moving, Combat, Skills
P2 Sends: Combat, Skills, Moving
P3 Sends: Skills, Moving, Combat
As you can see they all send data in a different order. How does the server know to execute the function that handles Moving if that is sent first and so on for the rest of them?
So, if I understand, you want to know how to detect the type of a message?
Well, you can do sth like this:
Code: Select all
-------CLIENT--------
message = "M" .. tostring(move)
socket:sent(message) --or whatever is the name of the function
-----------SERVER--------
message = socket:receive() --or whatever is the name of the function
if message:sub(1,1) == "M" then
--handle movement
elseif message:sub(1,1) == "C"
--handle combat
elseif message:sub(1,1) == "S"
--handle skills
end