Yo, trying to send packets from server to otclient but i get nothing at all when im checking TFS(TFS 1.3) console, nor ctrl+t on otclient.
I have added json to server(TFS 1.3) & client. Was there anything source-related needed as well? I've been checking multiple threads so far without success.
Code from server side: (Yes it prints "we trying", but nothing else)
Code in client:
I have added json to server(TFS 1.3) & client. Was there anything source-related needed as well? I've been checking multiple threads so far without success.
Code from server side: (Yes it prints "we trying", but nothing else)
Lua:
function CountdownText(time, character, endText)
local player = Player(character)
local insideADungeon = 42999
if not player then return false end
if player:getStorageValue(insideADungeon) >= 1 then
local response = {
foo = "Hello",
bar = "World"
}
print("we trying")
player:sendExtendedOpcode(110, json.encode(response))
if time > 0 then
local minutes = string.format("%02.f", math.floor(time/60))
local seconds = string.format("%02.f", math.floor(time - minutes*60))
player:sendTextMessage(MESSAGE_STATUS_SMALL, "[You have " .. minutes .. "m and " .. seconds .. "s left!]")
addEvent(CountdownText, 1 * 1000, time - 1, player:getId(), endText)
if time == 30 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! You only have 30 seconds left!!")
end
else
CountdownText(endText)
player:teleportTo({x = 1025, y = 1010, z = 7})
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You didnt succeed, try again.")
end
end
end
Code in client:
Lua:
function init()
ProtocolGame.registerExtendedOpcode(110, onExtendedOpcode)
end
function terminate()
ProtocolGame.unregisterExtendedOpcode(110, onExtendedOpcode)
end
function sendMyCode()
local myData = {
a = "string",
b = 123,
c = {
x = "string in table",
y = 456
}
}
local protocolGame = g_game.getProtocolGame()
if protocolGame then
protocolGame.sendExtendedOpCode(110, json.encode(myData))
end
end
function onExtendedOpcode(protocol, code, buffer)
local json_status, json_data =
pcall(
function()
return json.decode(buffer)
end
)
if not json_status then
g_logger.error("[My Module] JSON error: " .. json_data)
return false
end
print("alo?")
print(json_data.foo)
print(json_data.bar)
end
Last edited: