• 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!

Problem with opcode

margoh

{{ user.title }}
Joined
Apr 1, 2013
Messages
806
Solutions
18
Reaction score
350
Hello,
I'm trying to get to work 'my' opcode, but it seems not working.
I have added in my module this:
Code:
function onVocationChange(player, opcode, buffer)
  local msg = InputMessage.create()
  msg:setBuffer(buffer)
  local player = g_game.getLocalPlayer()
  if not player then return end
  local vocName = msg:getData()
  player:setVocation(vocations[vocName][1])
  profileWindow:recursiveGetChildById('portraitPanel'):setImageSource(vocations[vocName][2])
end
But I get error in terminal:
Code:
ERROR: Unable to send extended opcode 1, extended opcodes are not enabled
ERROR: protected lua call failed: LUA ERROR:
/game_profile/profile.lua:193: attempt to index field '?' (a nil value)
stack traceback:
    [C]: ?
    /game_profile/profile.lua:193: in function </game_profile/profile.lua:188>

In init() and terminate() functions I have added to register and unregister code.

Also I have question: How should function in the extendedopcode.lua look like, not for this, but some basic (server side)?

I'm using latest source of TFS 1.1 and OTC 0.6.6

Hope someone can give me some tips.
Thanks in advance, margoh
 
These are the methods for InputMessage. What do you except to obtain by calling :getData anyway? You just created that message and set the buffer yourself, just use buffer directly.
Code:
g_lua.bindClassStaticFunction<InputMessage>("create", []{ return InputMessagePtr(new InputMessage); });
g_lua.bindClassMemberFunction<InputMessage>("setBuffer", &InputMessage::setBuffer);
g_lua.bindClassMemberFunction<InputMessage>("getBuffer", &InputMessage::getBuffer);
g_lua.bindClassMemberFunction<InputMessage>("skipBytes", &InputMessage::skipBytes);
g_lua.bindClassMemberFunction<InputMessage>("getU8", &InputMessage::getU8);
g_lua.bindClassMemberFunction<InputMessage>("getU16", &InputMessage::getU16);
g_lua.bindClassMemberFunction<InputMessage>("getU32", &InputMessage::getU32);
g_lua.bindClassMemberFunction<InputMessage>("getU64", &InputMessage::getU64);
g_lua.bindClassMemberFunction<InputMessage>("getString", &InputMessage::getString);
g_lua.bindClassMemberFunction<InputMessage>("peekU8", &InputMessage::peekU8);
g_lua.bindClassMemberFunction<InputMessage>("peekU16", &InputMessage::peekU16);
g_lua.bindClassMemberFunction<InputMessage>("peekU32", &InputMessage::peekU32);
g_lua.bindClassMemberFunction<InputMessage>("peekU64", &InputMessage::peekU64);
g_lua.bindClassMemberFunction<InputMessage>("decryptRsa", &InputMessage::decryptRsa);
g_lua.bindClassMemberFunction<InputMessage>("getReadSize", &InputMessage::getReadSize);
g_lua.bindClassMemberFunction<InputMessage>("getUnreadSize", &InputMessage::getUnreadSize);
g_lua.bindClassMemberFunction<InputMessage>("getMessageSize", &InputMessage::getMessageSize);
g_lua.bindClassMemberFunction<InputMessage>("eof", &InputMessage::eof);
 
Back
Top