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

C++ OTCV8 - OTX.2 - 7.72 FreeCapacity problem.

Joined
Oct 12, 2020
Messages
45
Solutions
1
Reaction score
5
Location
Detroit, MI
OTCV8 - OTX.2 - 7.72

So this is how my cap look's, it only go's to 600'ish and then resets to a lower number. IT WILL NEVER SHOW OVER 600'ish CAP.
125cap.png

Protocolgame.cpp - On the server.
C++:
msg->put<uint16_t>(int32_t(player->getFreeCapacity() * 100));
Also tried,
C++:
msg->put<uint16_t>(int32_t(player->getFreeCapacity() * 10));
And,
C++:
msg->put<uint16_t>(int32_t(player->getFreeCapacity() * 1));
Nothing changes.

Healthinfo.lua - On the client.
Lua:
function onFreeCapacityChange(player, freeCapacity)
  capLabel:setText(tr('Cap') .. ': ' .. freeCapacity)
end

Edit: I've all so tried these fixes, 2 BUGs OTclient 7x (https://otland.net/threads/2-bugs-otclient-7x.250447/#post-2432194)
 
Last edited:
Solution
try this on inventory.lua
Lua:
function onFreeCapacityChange(player, freeCapacity)
    if not freeCapacity then
        return
    end
    if freeCapacity > 99 then
        freeCapacity = math.floor(freeCapacity * 10) / 10
    end
    if freeCapacity > 999 then
        freeCapacity = math.floor(freeCapacity)
    end
    if freeCapacity > 99999 then
        freeCapacity = math.min(9999, math.floor(freeCapacity / 1000)) .. "k"
    end
    capLabel:setText(freeCapacity * 100)
end
and this on skills.lua
Lua:
function onFreeCapacityChange(localPlayer, freeCapacity)
    setSkillValue("capacity", freeCapacity * 100)
    checkAlert("capacity", freeCapacity, localPlayer:getTotalCapacity(), 20)
end

function onTotalCapacityChange(localPlayer...
Tried this as well in Protocolgame.cpp, Nothings working.

C++:
uint16_t capacity = uint16_t(player->getFreeCapacity());
    if (capacity >= INT16_MAX)
        msg->add<uint16_t>(INT16_MAX);
    else
        msg->add<uint16_t>(capacity);

And

C++:
msg->add<uint16_t>(int32_t(player->getFreeCapacity()));
 
As I remember, on 7.72 client (official, not OTC) there was no fractional part (dot) in free capacity.
You cannot add it to 7.72 protocol, because it will limit visible capacity to 655 oz. (max. uint16 value is 65535). On newer protocol they changed capacity type to uint32 and start using fractional point.

If on server side free capacity is stored as '100 * oz.', I would try:
Code:
msg->put<uint16_t>(int32_t(player->getFreeCapacity() / 100));
and on client side:
Code:
function onFreeCapacityChange(player, freeCapacity)
  capLabel:setText(tr('Cap') .. ': ' .. freeCapacity * 100)
end
 
C++:
msg->put<uint16_t>(int32_t(player->getFreeCapacity() / 100));
Lua:
function onFreeCapacityChange(player, freeCapacity)
  capLabel:setText(tr('Cap') .. ': ' .. freeCapacity * 100)
end
I think that's the first thing I tried, I did so many things to try and fix this.
Makes my cap 0.18 for my total, (really 1800+)
I don't know what's real anymore... lol

The only way I can think of is compile the client to where it cant display the (dot) in cap, but its otcv8 so I'm thinking its 4000 bucks to fix this cap issue?
 

Attachments

Last edited:
try this on inventory.lua
Lua:
function onFreeCapacityChange(player, freeCapacity)
    if not freeCapacity then
        return
    end
    if freeCapacity > 99 then
        freeCapacity = math.floor(freeCapacity * 10) / 10
    end
    if freeCapacity > 999 then
        freeCapacity = math.floor(freeCapacity)
    end
    if freeCapacity > 99999 then
        freeCapacity = math.min(9999, math.floor(freeCapacity / 1000)) .. "k"
    end
    capLabel:setText(freeCapacity * 100)
end
and this on skills.lua
Lua:
function onFreeCapacityChange(localPlayer, freeCapacity)
    setSkillValue("capacity", freeCapacity * 100)
    checkAlert("capacity", freeCapacity, localPlayer:getTotalCapacity(), 20)
end

function onTotalCapacityChange(localPlayer, totalCapacity)
    checkAlert("capacity", localPlayer:getFreeCapacity(), totalCapacity, 20)
end
 
Last edited:
Solution
You my good sir,
Are a God among men.
try this on inventory.lua
Lua:
function onFreeCapacityChange(player, freeCapacity)
    if not freeCapacity then
        return
    end
    if freeCapacity > 99 then
        freeCapacity = math.floor(freeCapacity * 10) / 10
    end
    if freeCapacity > 999 then
        freeCapacity = math.floor(freeCapacity)
    end
    if freeCapacity > 99999 then
        freeCapacity = math.min(9999, math.floor(freeCapacity / 1000)) .. "k"
    end
    capLabel:setText(freeCapacity * 100)
end
and this on skills.lua
Lua:
function onFreeCapacityChange(localPlayer, freeCapacity)
    setSkillValue("capacity", freeCapacity * 100)
    checkAlert("capacity", freeCapacity, localPlayer:getTotalCapacity(), 20)
end

function onTotalCapacityChange(localPlayer, totalCapacity)
    checkAlert("capacity", localPlayer:getFreeCapacity(), totalCapacity, 20)
end
Thanks everyone for helping this was driving me crazy!
 
Back
Top