[Req]Help with item trade with npcs

Submit your code requests, and if you are good at coding come help others with their requests.
Post Reply
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Hello, I'm having trouble making a code to trade items with npc's, I want to get something like this:

RedBall--> Get a Zemstone
GreenBall--> Get a Wand
Etc...

In a npc, I have tryied few times but I can only make it work with only one item required, but when I try with more balls it doesn't work.

Here is the code:

Code: Select all

//req
	for (i = 0; i < DEF_MAXITEMS; i++)
  {
  	if (m_pClientList[iClientH]->m_pItemList[i] != NULL) 
  	{

    if(iRequiredItem == m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum)
    {
    	i = iSoxH;
    	
    }
  	}
  }
Oh and iRequiredItem was initialized as iRequiredItem = -1;
<a href='http://imageshack.us' target='_blank'><img src='http://img224.imageshack.us/img224/2738/screenqu8.jpg' border='0' alt='user posted image' /></a><br>drajwer draw<br><a href='index.php?showtopic=7299' target='_blank'>index.php?showtopic=7299</a>
juanduran
noob
Posts: 19
Joined: Sat Dec 04, 2004 1:21 am

Post by juanduran »

Code: Select all

//define variable
int iSoxI;

//scans items
for (i = 0; i < DEF_MAXITEMS; i++) {
  	if (m_pClientList[iClientH]->m_pItemList[i] != NULL) 
  	{
    switch (m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum) 
    {
    case 651: iSoX++; iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i; break;
    case 652: iSoX++; iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i; break;
    case 653: iSoX++; iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i; break;
    case 654: iSoX++; iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i; break;
    case 655: iSoX++; iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i; break;
    }
  	}
}
then you req the ball as... if(iSoxH == iRequiredItemm)...

good luck :)
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Thanks, worked fine.
<a href='http://imageshack.us' target='_blank'><img src='http://img224.imageshack.us/img224/2738/screenqu8.jpg' border='0' alt='user posted image' /></a><br>drajwer draw<br><a href='index.php?showtopic=7299' target='_blank'>index.php?showtopic=7299</a>
Post Reply