Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

How to make custom shops easily (__ADDSHOPITEM)

Initiate Mage
Joined
Aug 8, 2019
Messages
23
Reaction score
6
I had a LOT of trouble trying to understand the whole "AddVendorItem( 0, IK3_SWD, 1, 15, 27, 50 );" thing and wanted to have my own custom npc for certain items, and well i finally figured it out. I couldn't find a straight answer and only scattered forum posts with dead links, so i decided to make a small tutorial for those who were in my same spot.

Adding a new npc:
I followed RynoKabbage's guide, but i found that his link for flyfftools was dead, so you can use this link for or the link in the comments on his guide.

Adding "__ADDSHOPITEM":
note:I'm assuming whoever is reading this already knows how to compile there source.

This is how i made it work, i'm not sure if there's an easier way but in the folders: accountserver, cacheserver, certifier, coreserver, databaseserver, neuz, and world server there are files named "versioncommon.h". In the first few lines you should see lines like "#define __Server", well within those you need to add "#define __ADDSHOPITEM" to each versioncommon.h in every one of those folders.

​Mover.cpp part:
now in your _COMMON folder you're going to want to open "mover.cpp". Start by searching for "#endif //__CSC_VER11_3" there should be 3 occurrences of that bit of text, the second one is the one you want to start with.

where it looks like this:
Code:
#if __VER >= 11 // __CSC_VER11_3
                }
#endif //__CSC_VER11_3

Directly under that #endif paste the code below:
Code:
#ifdef __ADDSHOPITEM
                if( pCharacter->m_venderItemAry3[i].GetSize() )
                {
                    fShop = TRUE;
                    for( int j = 0; j < pCharacter->m_venderItemAry3[i].GetSize(); j++)
                    {
                        pVendor    = (LPVENDOR_ITEM)pCharacter->m_venderItemAry3[i].GetAt(j);
                        CItemElem itemElem;
                        itemElem.m_dwItemId    = pVendor->m_dwItemId;
                        itemElem.m_nItemNum    = (short)( prj.GetItemProp( pVendor->m_dwItemId )->dwPackMax );
                        itemElem.m_nHitPoint = prj.GetItemProp( pVendor->m_dwItemId )->dwEndurance;
                        if( m_ShopInventory[i]->Add( &itemElem ) == FALSE )
                            break;
                    }
                }
#endif

it should look like
Code:
#if __VER >= 11 // __CSC_VER11_3
                }
#endif //__CSC_VER11_3
#ifdef __ADDSHOPITEM
                if( pCharacter->m_venderItemAry3[i].GetSize() )

note: the example above is just the start of the clip of code and not the whole thing.

now on the 3rd occurrence of that line your searched you're going to do the same thing you did above, right below the "#endif" you paste the code below.
Code:
#ifdef __ADDSHOPITEM
    for( int i = 0; i < MAX_VENDOR_INVENTORY_TAB; i++ )
    {
        if( pCharacter->m_venderItemAry3[i].GetSize() )
            return TRUE;
    }
#endif

Project.cpp part:

Now in your _COMMON folder you're going to want to open "Project.cpp". Start by searching for "#endif //__CSC_VER11_3" there should be 3 occurrences of that bit of text, the first one is the one you want.

Just as the mover.cpp, you need to paste the code below directly under the "#endif //__CSC_VER11_3".
Code:
#ifdef __ADDSHOPITEM
        for( j = 0; j < MAX_VENDOR_INVENTORY_TAB; j++ )
        {
            for( i = 0; i < lpCharacter->m_venderItemAry3[ j ].GetSize(); i++)
                safe_delete( (LPVENDOR_ITEM)lpCharacter->m_venderItemAry3[ j ].GetAt(i) );
        }
#endif

Now you're going to search again in "Project.cpp" for "#endif // __TELEPORTER", the second occurrence towards the middle is what you want. You'll as always post the snip of code directly under the searched term.

Code:
#ifdef __ADDSHOPITEM
            else if( script.Token == "AddShopItem" )
            {
                script.GetToken(); // (
                int nSlot = script.GetNumber(); script.GetToken(); // 
                DWORD dwId = script.GetNumber(); script.GetToken(); //
                if (script.Token == ",")
        {
            DWORD dwCost = script.GetNumber();
            script.GetToken(); // )
            ItemProp* pItem = prj.GetItemProp(dwId);
            if (pItem)
            pItem->dwCost = dwCost;
        }
                LPVENDOR_ITEM pVendorItem = new VENDOR_ITEM;
                pVendorItem->m_dwItemId = dwId;
                lpCharacter->m_venderItemAry3[ nSlot ].Add( pVendorItem );
            }
#endif
Project.h part:
Now in your _COMMON folder you're going to want to open "Project.h". Start by searching for "#endif // __TELEPORTER". There should be 1 occurrence, that's one you want.

And for the last thing you need to do, one last time, directly under the "#endif" you need to paste the code below:
Code:
#ifdef __ADDSHOPITEM    

CPtrArray m_venderItemAry3[4];

#endif

When you're done with those parts above you'll need to compile your source, and then you're done!

Adding items:

note:At this point you should have a compiled source with the code provided, and a npc you'd like to add an item to a shop.


You need to make your way to your resource folder in your server folder. Open your "character.inc" file and follow along.

This is the config for the npc "Is"

Code:
MaFl_Is{
    setting
    {
        AddMenu( MMI_DIALOG );
        AddMenu( MMI_TRADE  );
        AddVendorItem( 0, IK3_MASK, -1, 1, 2, 100 );
        SetImage
        (
        IDS_CHARACTER_INC_000064
        );
        m_szDialog= "MaFl_Is.txt";
    }
    SetName
    (
    IDS_CHARACTER_INC_000065
    );
    AddVendorSlot( 0,
    IDS_CHARACTER_INC_000066
    );
}

the snip of code you need to add items now is "AddShopItem( 0, PUT_ITEM_ID_HERE );".

You place it where you see "AddVendorItem( 0, IK3_MASK, -1, 1, 2, 100 );"

Once you've done all of that, you'll need to use merge.exe to get new res files and put them in your client folder for the shops to load.

Of course you put the id of the item you want where it tells you to, and the 0 is the vender slot number. You can find item id's in the file "propItem.txt". Some things can't be sold and you'll have to go through your "propItem.txt" with the id you found and change the shopable value to 1. You also go into that file to change prices.

Edit:
Looking around i found a snip of code that lets you change the price of the item in the character.inc, but it's a little wonky and it only lets you change the price once. So two different shops with the addshopitem line and a price change, they'd both have the price of the first query. "AddShopItem( 0, PUT_ITEM_ID_HERE, X);" The X is where the price goes, you don't have to have it in your line, only if you want to change the price for said item.


Hope this helps anyone honestly.
 
Last edited:
Initiate Mage
Joined
May 11, 2014
Messages
11
Reaction score
0
Is this for custom currency or just a tut on how to add items in npcs?
If it's the latter, it's actually pretty easy. Just edit the item rarity.
No need to complicate things.
If not, then :/
 
Initiate Mage
Joined
Aug 8, 2019
Messages
23
Reaction score
6
Is this for custom currency or just a tut on how to add items in npcs?
If it's the latter, it's actually pretty easy. Just edit the item rarity.
No need to complicate things.
If not, then :/
Well, some people just can't figure out how to get it to work with item rarity, and when this code is implemented you don't need to edit anything, you just put the vendor slot and the id and it's done.
 
Inactive
Joined
Jan 20, 2009
Messages
1,015
Reaction score
1,830
Well thought out and nicely written.

Community here needs a bit more of this tbh.
 
Initiate Mage
Joined
Sep 28, 2014
Messages
17
Reaction score
0
So I copied everything you did step by step, compiled with no errors. Went into my resource and into the character.inc file. I went scrolled down till I found the npc is and decided to place the item"II_SYS_SYS_SCR_BXMKNT120SET" which can also be found in the Npc Wafor which I think means that the item is already shopable. I save the file and merge the resource. Get the res files into the client and start the server then go in game. However, I don't see the item which I have tried to add. Why is that? Pic below for the character.inc code

 
Inactive
Joined
Jan 20, 2009
Messages
1,015
Reaction score
1,830
So I copied everything you did step by step, compiled with no errors. Went into my resource and into the character.inc file. I went scrolled down till I found the npc is and decided to place the item"II_SYS_SYS_SCR_BXMKNT120SET" which can also be found in the Npc Wafor which I think means that the item is already shopable. I save the file and merge the resource. Get the res files into the client and start the server then go in game. However, I don't see the item which I have tried to add. Why is that? Pic below for the character.inc code


Send a pm with your discord and when i get home from work ill try to help you.
 
Skilled Illusionist
Joined
May 11, 2011
Messages
316
Reaction score
28
First thank you for this.

An importend thing i want to know is: How to setup the Shop NPC with male or female Fashion?
For the female Fashion it wont work. Anyone have a fix?
 
Initiate Mage
Joined
Mar 8, 2020
Messages
29
Reaction score
8
I compiled successfully like this, but type in incAddShopItem (0, II_SYS_SYS_SCR_BXMKNT120SET, 100);This item does not appear in the NPC store.The data file has been updated.
 
Initiate Mage
Joined
Jan 31, 2021
Messages
12
Reaction score
2
I Have the same problem...


AddShopItem( 0, II_SYS_SYS_SCR_SUPERLEADERPARTY );
 
Initiate Mage
Joined
Jan 31, 2021
Messages
12
Reaction score
2
Thanks for the Answer.

Where i found all the Addshopitem and vendort update codes?

Only the Mover.pp, Project.cpp, Project.h ?
 
Initiate Mage
Joined
Jan 31, 2021
Messages
12
Reaction score
2
The AsFlyff source have a VersionCommon.h and ServerCommon.h file in _Common Folder.

i miss both of this files completly in this files.

So i musst copy this and create this files new? because there are a lot of stuff in there, that are not in the server...


EDIT: it works! Thank you.
 
Last edited:
Initiate Mage
Joined
May 15, 2021
Messages
10
Reaction score
1
Hi, I know this thread was posted a while back. I'm just new into this and just want to learn from scratch so I would really understand how everything communicate.

So I have a newb question, I found the versioncommon.h in each folder however I cant find the #define _server on NEUZ folder only #define _mainserver
are those 2 the same? if not where I can put the #define _ADDSHOPITEM? should I add #define _server manually then #define __ADDSHOPITEM afterwards?

I would really appreciate anyone that can answer my stupid questions. Thanks :)
 
Inactive
Joined
Jan 20, 2009
Messages
1,015
Reaction score
1,830
Hi, I know this thread was posted a while back. I'm just new into this and just want to learn from scratch so I would really understand how everything communicate.

So I have a newb question, I found the versioncommon.h in each folder however I cant find the #define _server on NEUZ folder only #define _mainserver
are those 2 the same? if not where I can put the #define _ADDSHOPITEM? should I add #define _server manually then #define __ADDSHOPITEM afterwards?

I would really appreciate anyone that can answer my stupid questions. Thanks :)

All u have to do is add

Code:
#define __ADDSHOPITEM

To:
-> WorldServer/VersionCommon.h
-> Neuz/VersionCommon.h
 
Initiate Mage
Joined
May 15, 2021
Messages
10
Reaction score
1
All u have to do is add

Code:
#define __ADDSHOPITEM

To:
-> WorldServer/VersionCommon.h
-> Neuz/VersionCommon.h

Thank you for your response, sir.
So before I read this message I ended up leaving the Neuz and compile it, but I get this error "
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums


I know that the fix is clearly written in the error message and been searching the internet for the fix but can't see any. btw, I'm using visual studio 2019.

PS: I'm adding the code #define __ADDSHOPITEM upon writing this message and will try again :)
 
Initiate Mage
Joined
May 15, 2021
Messages
10
Reaction score
1
Hi, I know this thread was posted a while back. I'm just new into this and just want to learn from scratch so I would really understand how everything communicate.

So I have a newb question, I found the versioncommon.h in each folder however I cant find the #define _server on NEUZ folder only #define _mainserver
are those 2 the same? if not where I can put the #define _ADDSHOPITEM? should I add #define _server manually then #define __ADDSHOPITEM afterwards?

I would really appreciate anyone that can answer my stupid questions. Thanks :)

All u have to do is add

Code:
#define __ADDSHOPITEM

To:
-> WorldServer/VersionCommon.h
-> Neuz/VersionCommon.h

Thank you for your help, sir.
So before I read your reply I ended up leaving to add the code: #define __ADDSHOPITEM on Neuz and follow all the steps provided, however upon compiling I got this error C1189
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums


PS: I'm adding the code: #define __ADDSHOPITEM on Neuz right now and will try to recompile it.
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums




Update: I have already added the code: #define __ADDSHOPITEM to all necessary folders but I'm still getting these errors
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums


LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums

I know that the fix is already given in the error list but I just don't know how to do it. I've been searching the internet to check some tuts on how but just can't find it. btw, I'm using a visual studio 2019 with cuvvies clean repack v3.1 on windows 10 pro. I don't know if it matters tho.

If someone have spare time to answer another newb question, it is much appreciated. :)
 
Last edited:
Inactive
Joined
Jan 20, 2009
Messages
1,015
Reaction score
1,830
Thank you for your help, sir.
So before I read your reply I ended up leaving to add the code: #define __ADDSHOPITEM on Neuz and follow all the steps provided, however upon compiling I got this error C1189
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums


PS: I'm adding the code: #define __ADDSHOPITEM on Neuz right now and will try to recompile it.
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums




Update: I have already added the code: #define __ADDSHOPITEM to all necessary folders but I'm still getting these errors
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums
LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums


LonesomeNoob - How to make custom shops easily (__ADDSHOPITEM) - RaGEZONE Forums

I know that the fix is already given in the error list but I just don't know how to do it. I've been searching the internet to check some tuts on how but just can't find it. btw, I'm using a visual studio 2019 with cuvvies clean repack v3.1 on windows 10 pro. I don't know if it matters tho.

If someone have spare time to answer another newb question, it is much appreciated. :)

Why would you be using VS2003 files on VS2019 when these exist: https://forum.ragezone.com/f457/vs19-v15-tested-1170442/
Along with this guide: [FULL SETUP GUIDE] Ketchup VS2019 files - RaGEZONE - MMO development community

The issue is clearly your using an outdated source on a newer compiler. You either need to switch to what i posted above or completely upgrade the source from VS03 to VS19 manually lol.
 
Back
Top