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

[HELP] Send information from server to Client (StorageValues)

samco

4x4 Developer.
Joined
Jul 3, 2007
Messages
1,077
Solutions
9
Reaction score
260
Location
Spain
Hello everyone.

Im really new to OTClient, and i want to get information from the server (The current storage value from the player), as i have a lifesteal and critchance associated to the player, and i want to show it in the Skills Bars.

I saw the code of otClient, and i realized it doesnt have a getStorageValue from the Player instance. Does anyone knows how can we reach this? Maybe through opCodes, but i dont really know how they works yet, and there is no Wiki or documentation.

Thanks in advance.

I managed to do it through some source editing at TFS and OTClient.
 
Last edited by a moderator:
I updated the sendSkills function, so it also sends two additional bytes as integers with the current storageValues.

Then i modified the protocol on the client to receive correctly those bytes, and modify the game_skills module to show them on the skills windows.

Im at work now, if you need more detail, ill try to explain better this afternoon
 
Receive opcode:
Code:
connect { ProtocolGame, { onExtendedOpcode = receive })

function receive(protocol, opcode, buffer)
     print(opcode..": ".. buffer)
end

Send opcode:
Code:
g_game.getProtocolGame():sendExtendedOpcode(opcodeNumber, buffer)
 
Did you manage to get this working?
I have a skill point system in my server and I'd like players to see how many points they have in the skill bars.
 
@calveron, send extendedopcode from the server with that value, then register it in the module.
 
Tfs 1.x in creatrescripts/extendedopcode.lua
Code:
local storageSkillPoints = getPlayerStorageValue(player, STORAGE)
player:sendExtendedOpcode(OPCODE, storageSkillPoints)

And in client module in function init
Code:
ProtocolGame.registerExtendedOpcode(OPCODE, getSkillPoints)
In function terminate
Code:
ProtocolGame.unregisterExtendedOpcode(OPCODE)

And add function
Code:
function getSkillPoints(protocol, opcode, buffer)
print(buffer)
end

I'm on the phone, so I could make some mistake, but it should look like that.
 
Tried my best, no success. I guess Im useless at these things. Feel like helping me more detailed? the storage is 62490 and the skill should just be named "Skill Points"
trying my best but can't really get it to work :p
 
What tfs? This works with TFS 1.x xd
All extendedopcode.lua should look like this:
Code:
function onExtendedOpcode(player, opcode, buffer)
    local skillPoints = getPlayerStorageValue(player, 62490)
    player:sendExtendedOpcode(52, skillPoints)
    return true
end
There could be some lines with langs, but I have deleted it.

In skills.lua, function init()
Code:
ProtocolGame.registerExtendedOpcode(52, getSkillPoints)

In same file, function terminate()
Code:
ProtocolGame.unregisterExtendedOpcode(52)

And in the same file, create function getSkillPoints
Code:
function getSkillPoints(protocol, opcode, buffer)
   print(buffer) -- it should prints how much skill points you have in terminal (ctrl+t)
end

For me that works just fine :d
 
Yeah, it works great now thanks! How do I get it to show in the skills window? Trying some stuff but no luck so far :p
 
skillsWindow:getChildById('labelName'):setText(buffer)
 
Hello,

I'm using OTClient in a server running TFS 0.3.7 or so and the Quest Log don't seems to work at all. I'm wondering if there's way to get storage values from the player so I can redo the module code and show the quests done or something like that.

Regards, Rorchak.
 
Back
Top