• 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++ help me understand about recvbyte?

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
I am currently using the OTG Premium Version, the Prey Wildcart system has not been implemented and I am trying to implement it, however I am having a hard time understanding about these bytes, here's what I'm analyzing.

Using OTG 1.3 Premium Version with client 12.40

Modules.xml
XML:
 <!-- Prey System -->
    <module type="recvbyte" byte="235" script="prey_system/prey.lua" />
    <module type="recvbyte" byte="237" script="prey_system/prey.lua" />

Callback:
Lua:
player:preyAction(msg)

Data msg:
C++:
userdata: 0x04707c58

Function
Lua:
    local slot = msg:getByte()  
    local action = msg:getByte()
    print(slot)
    if not slot then
        return self:sendErrorDialog("Sorry, there was an issue, please relog-in.")
    end

    -- Verify whether the slot is unlocked
    --print(self:getPreyUnlocked(slot))
    if (self:getPreyUnlocked(slot) ~= 2) then
        return self:sendErrorDialog("Sorry, you don't have this slot unlocked yet.")
    end

Source
C++:
int LuaScriptInterface::luaPlayerGetPreyUnlocked(lua_State* L)
{
    // player:getPreyUnlocked(slot)
    Player* player = getUserdata<Player>(L, 1);
    uint16_t slot = getNumber<uint16_t>(L, 2);
    std::cout << slot << std::endl;
    if (player) {
        lua_pushnumber(L, player->getPreyUnlocked(slot));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

0 (ZERO) is always returning me, why?

1597266619722.png
1597266631887.png
 
Back
Top