• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Understanding opcodes

poe6man3

Member
Joined
Aug 6, 2020
Messages
87
Solutions
1
Reaction score
12

In this thread shadowsong writed stupp about opcodes and i understand most of it but i struggle with how to find packets that not already in use and how to write them could anybody help me out ?
 
Solution
how to find packets that not already in use
When you register OPCode (even Extended) that is already in use, you will be notified in client Terminal (CTRL + T) about this.

As to how to use them is very simple.
Server is using Player:sendExtendedOpcode(opcode_number, string_type_data) to send data.
To receive data from the server you will have to use
Lua:
ProtocolGame.registerExtendedOpcode(opcode_number, function_to_execute) -- register
ProtocolGame.unregisterExtendedOpcode(opcode_number, function_to_execute) -- unregister, quiet important

function function_to_execute(protocol, opcode, buffer)
    -- protocol - GameProtocol (same as g_game.getProtocolGame())
    -- opcode - opcode_number (first argument in...
how to find packets that not already in use
When you register OPCode (even Extended) that is already in use, you will be notified in client Terminal (CTRL + T) about this.

As to how to use them is very simple.
Server is using Player:sendExtendedOpcode(opcode_number, string_type_data) to send data.
To receive data from the server you will have to use
Lua:
ProtocolGame.registerExtendedOpcode(opcode_number, function_to_execute) -- register
ProtocolGame.unregisterExtendedOpcode(opcode_number, function_to_execute) -- unregister, quiet important

function function_to_execute(protocol, opcode, buffer)
    -- protocol - GameProtocol (same as g_game.getProtocolGame())
    -- opcode - opcode_number (first argument in registerExtendedOpcode)
    -- buffer - string type data from the server
end
I'd recommend using JSON lib to send and receive data because you can only send String. Here is a quick tutorial on how to work with that [TUTORIAL MODS]- Creating Modules with Extended Opcode (https://otland.net/threads/tutorial-mods-creating-modules-with-extended-opcode.270062/#post-2603502).
 
Last edited:
Solution
Thank u, probably last question
Lua:
packet:addByte(0x32) -- Extended Opcode (0x32 = 50 (in dec))
packet:addByte(0x0A) -- The Opcode of this Request (0x0A = 10 (in dec))

(0x32) how is that written cause i dont really get it is that hex or what cause i guess i cant write here just 50 or 10 etc.
 
Thank u, probably last question
Lua:
packet:addByte(0x32) -- Extended Opcode (0x32 = 50 (in dec))
packet:addByte(0x0A) -- The Opcode of this Request (0x0A = 10 (in dec))

(0x32) how is that written cause i dont really get it is that hex or what cause i guess i cant write here just 50 or 10 etc.
Why are you using normal OPCodes instead of Extended?
 
Back
Top