ok thx so much that work ! only 1 time
i try to add other items but world server crash. I open help section i don't understand why
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 forTo view the content, you need to sign in or registeror 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:
Project.h 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
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.
All u have to do is add
Code:#define __ADDSHOPITEM
To:
-> WorldServer/VersionCommon.h
-> Neuz/VersionCommon.h
im new here editing flyff i try this but when i click trade button from Is it didnt show the item . . can you help meI 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 forTo view the content, you need to sign in or registeror 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:
Project.h 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
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.
Any codes within client or sever logs? Otherwise check with winmerge if all defines is added and at correct places, 2nd show us ur character.txt config within that npcim new here editing flyff i try this but when i click trade button from Is it didnt show the item . . can you help me![]()