Jump to content
Sign in to follow this  
GustavoHMA

Create CheckBagSlotItem(role, itemid, slotid)

Recommended Posts

inline int lua_GetItemQuantity(lua_State *pLS) {
    bool bSuccess = true;
    int nParaNum = lua_gettop(pLS);
    if (nParaNum != 1) {
        bSuccess = false;
        goto End;
    }
    SItemGrid *pSItem = (SItemGrid*)lua_touserdata(pLS, 1);
    if (!pSItem) {
        bSuccess = false;
        goto End;
    }
End:
    if (bSuccess)
        lua_pushnumber(pLS, pSItem->sNum);
    else
        lua_pushnumber(pLS, 0);

    return 1;
}

If C++ injection, would need to know the structures and mem layout of SItemGrid.

Then, I think with asm it is abit easier.

  • Like 1

kong.png

a2.png

Share this post


Link to post
Share on other sites
2 hours ago, KONG said:

If C++ injection, would need to know the structures and mem layout of SItemGrid.

 

How can I make these structures for version 1.36?

Edited by GustavoHMA

Share this post


Link to post
Share on other sites

1.36

SItemGrid.h

typedef struct SItemGrid {
    short dontCare;
    short sNum;
} SItemGrid;

LuaAddy:

static int(*lua_gettop)(lua_State *L) = (int(*)(lua_State *L))0x00576FD0;
static void*(*lua_touserdata)(lua_State *L, int) = (void* (*)(lua_State *L, int))0x005775F0;
static void(*lua_pushnil)(lua_State *L) = (void(*)(lua_State *L))0x005776D0;

+ Register the Lua function

+ Compile and Inject

 

Usage:

local item = GetChaItem(role, 2, slot) -- -1 < slot < 48
local itemQty = GetItemQuantity(item)
  • Like 1

kong.png

a2.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...