[Tutorial] Move all items to Global Inventory - Source code Part

☆Dying Dawn☆
Joined
Jan 30, 2012
Messages
969
Reaction score
735
This is the Client Source Part to Move all items to Global Inventory!
Q:What is this?
A:
GW0tAfT - [Tutorial] Move all items to Global Inventory - Source code Part - RaGEZONE Forums

Lets start!
In FrontEndWarZ.CPP
AFTER THIS
Code:
gfxMovie.RegisterEventHandler("eventMarketplaceActive", MAKE_CALLBACK(eventMarketplaceActive));

ADD THIS
Code:
gfxMovie.RegisterEventHandler("eventMoveAllItems", MAKE_CALLBACK(eventMoveAllItems));

AFTER THIS FUNCTION
Code:
void FrontendWarZ::OnDonateToServerSuccess()

ADD THIS ENTERY ONE
Code:
void FrontendWarZ::eventMoveAllItems(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount)
{
    //move all items from backpack to inventory
    const wiCharDataFull& slot = gUserProfile.ProfileData.ArmorySlots[gUserProfile.SelectedCharID];
    if(!(slot.GameFlags & wiCharDataFull::GAMEFLAG_NearPostBox))
        return;

    int itemsToMove = 0;
    for(int i=8; i < slot.BackpackSize; ++i)
    {
        const wiInventoryItem& wi = slot.Items[i];
        if(wi.itemID > 0)
        {
            itemsToMove++;
        }
    }

    if(itemsToMove)
    {
        if((gUserProfile.ProfileData.NumItems + itemsToMove) > wiUserProfile::INVENTORY_SIZE_LIMIT)
        {
            Scaleform::GFx::Value vars[3];
            vars[0].SetString(gLangMngr.getString("InGameUI_ErrorMsg_NoInventorySpace"));
            vars[1].SetBoolean(true);
            vars[2].SetString("$ERROR");
            gfxMovie.Invoke("_root.api.showInfoMsg", vars, 3);
            return;
        }
    }
    else
    {
        return;
    }

    Scaleform::GFx::Value var[2];
    var[0].SetString(gLangMngr.getString("OneMomentPlease"));
    var[1].SetBoolean(false);
    gfxMovie.Invoke("_root.api.showInfoMsg", var, 2);

    StartAsyncOperation(&FrontendWarZ::as_MoveAllItemsThread, &FrontendWarZ::OnMoveAllItemsSucessfully);
}

unsigned int WINAPI FrontendWarZ::as_MoveAllItemsThread(void* in_data)
{
    r3dThreadAutoInstallCrashHelper crashHelper;
    FrontendWarZ* This = (FrontendWarZ*)in_data;
    
    This->DelayServerRequest();

    int BackpackSlot = 0;
    int Quantity = 0;
    int apiCode = 0;
    const wiCharDataFull& slot = gUserProfile.ProfileData.ArmorySlots[gUserProfile.SelectedCharID];
    for(int i=8; i < slot.BackpackSize; ++i)
    {
        const wiInventoryItem& wi = slot.Items[i];
        if(wi.itemID > 0)
        {
            BackpackSlot = i;
            Quantity = wi.quantity;
            apiCode = gUserProfile.ApiBackpackToInventory(BackpackSlot, Quantity);
        }
    }

    if(apiCode != 0)
    {
        if(apiCode == 7)
        {
            This->SetAsyncError(0, gLangMngr.getString("GameSessionHasNotClosedYet"));
        }
        else if(apiCode == 9)
        {
            This->SetAsyncError(0, gLangMngr.getString("InGameUI_ErrorMsg_NoInventorySpace"));
        }
        else if(apiCode == 6)
        {
            return 1;
        }
        else
        {
            This->SetAsyncError(apiCode, gLangMngr.getString("BackpackToInventoryFail"));
        }
        return 0;
    }

    return 1;
}

void FrontendWarZ::OnMoveAllItemsSucessfully()
{
    Scaleform::GFx::Value var[8];
    gfxMovie.Invoke("_root.api.clearBackpack", "");
    int    slot = gUserProfile.SelectedCharID;

    addBackpackItems(gUserProfile.ProfileData.ArmorySlots[slot], slot);

    updateInventoryAndSkillItems();

    updateSurvivorTotalWeight(slot);

    gfxMovie.Invoke("_root.api.hideInfoMsg", "");
    gfxMovie.Invoke("_root.api.backpackToInventorySuccess", "");
    return;
}

IN FrontEndWarZ.h
AFTER THIS
Code:
void eventOpenURL(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount);

ADD THIS
Code:
void eventMoveAllItems(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount);
AFTER THIS
Code:
void        OnRequestGCTransactionSuccess();

ADD THIS
Code:
static unsigned int WINAPI as_MoveAllItemsThread(void* in_data);
void        OnMoveAllItemsSucessfully();

FLASH PART
BY @
lukasccb​
 
Last edited:
Hello, I'm sorry to disturb you.
I am a zombie war GM of China, and I am now because of technical problems, face many problems.
I hope to cooperate with you to create a perfect zombie war.
In our country, the zombie war market is very wide, now domestic server on a piece of only about seven or eight.
Please think about it.
I'm sorry my English.
 
Back