Big Trouble..ChangeHero function

All Helbreath Server Source Discussion here.
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Hello we've been working on a ChangeCity code that is giving me some trouble now,
the location swap is good, but the code that changes hero items is not working so fine.

Ok here it is, the code is activated with command /changecity, the requirements are 150 rep, and what it does is change player location and hero items.
The error comes up after logging out the game... this is the sequence:
- I press /changecity and it changes location, and changes hero normally (I can equip, drop, sell them as usual).
- Now when I logout the hg crashes.
- After I activate HG again and I login in the item bag appears 3 heros of the same type (3 leggings).

Here is the code:

Code: Select all

void CGame::AdminOrder_ChangeHero(int iClientH)
{
char notice[100];
int i, iSoX, iSoxH, iSoxI, iItemID, iEraseReq;
bool bGaveCape, bGaveArmor, bGaveHauberk, bGaveHelm, bGaveCap, bGaveRobe, bGaveLeggings;
 class CItem * pItem;

//initilized variables..
	pItem = NULL;
	pItem = new class CItem;
	if (pItem == NULL) return;
	bGaveCape = bGaveArmor = bGaveHauberk = bGaveHelm = bGaveCap = bGaveRobe = bGaveLeggings =  0; //sets all bools to false
	iSoxH = 0;
	iItemID = -1;
    iSoX = 0;
    //Asks for the item...identifies if the item is present into the character
  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 400: iSoX++; iItemID = 401; break; // 400   AresdenHeroCape
    	case 401: iSoX++; iItemID = 400; break; // 401   ElvineHeroCape
    	case 403: iSoX++; iItemID = 405; break; // 403   AresHeroHelm(M)
    	case 404: iSoX++; iItemID = 406; break; // 404   AresHeroHelm(W)
    	case 405: iSoX++; iItemID = 403; break; // 405   ElvHeroHelm(M)
    	case 406: iSoX++; iItemID = 404; break; // 406   ElvHeroHelm(W)
    	case 407: iSoX++; iItemID = 409; break; // 407   AresHeroCap(M)
    	case 408: iSoX++; iItemID = 410; break; // 408   AresHeroCap(W)
    	case 409: iSoX++; iItemID = 407; break; // 409   ElvHeroCap(M) 
    	case 410: iSoX++; iItemID = 408; break; // 410   ElvHeroCap(W) 
    	case 411: iSoX++; iItemID = 413; break; // 411   AresHeroArmor(M)
    	case 412: iSoX++; iItemID = 414; break; // 412   AresHeroArmor(W)
    	case 413: iSoX++; iItemID = 411; break; // 413   ElvHeroArmor(M)
    	case 414: iSoX++; iItemID = 412; break; // 414   ElvHeroArmor(W)
    	case 415: iSoX++; iItemID = 417; break; // 415   AresHeroRobe(M)
    	case 416: iSoX++; iItemID = 418; break; // 416   AresHeroRobe(W)
    	case 417: iSoX++; iItemID = 415; break; // 417   ElvHeroRobe(M)
    	case 418: iSoX++; iItemID = 416; break; // 418   ElvHeroRobe(W)
    	case 419: iSoX++; iItemID = 421; break; // 419   AresHeroHauberk(M)
    	case 420: iSoX++; iItemID = 422; break; // 420   AresHeroHauberk(W)
    	case 421: iSoX++; iItemID = 419; break; // 421   ElvHeroHauberk(M)
    	case 422: iSoX++; iItemID = 420; break; // 422   ElvHeroHauberk(W)
    	case 423: iSoX++; iItemID = 425; break; // 423   AresHeroLeggings(M)
    	case 424: iSoX++; iItemID = 426; break; // 424   AresHeroLeggings(W)
    	case 425: iSoX++; iItemID = 423; break; // 425   ElvHeroLeggings(M)
    	case 426: iSoX++; iItemID = 424; break; // 426   ElvHeroLeggings(W)
    	case 427: iSoX++; iItemID = 428; break; // 427   AresdenHeroCape+1
    	case 428: iSoX++; iItemID = 427; break; // 428   ElvineHeroCape+1
    }
    iSoxH = m_pClientList[iClientH]->m_pItemList[i]->m_sIDnum; iSoxI = i;
  	}
  	if(iSoX > 0)  //if player has any hero item...
  	{	
    //check if gave cape
    if((iSoxH == 400) | (iSoxH == 401) | (iSoxH == 427) | (iSoxH == 428))	{
      if(bGaveCape == FALSE)	{
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveCape = true;
      	}
      }
    }
    //check if gave helm
    else if((iSoxH == 403) | (iSoxH == 404) | (iSoxH == 405) | (iSoxH == 406))	{
      if(bGaveHelm == FALSE) {
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveHelm = true;
      	}
      }
    }
    //check if gave cap
    else if((iSoxH == 407) | (iSoxH == 408) | (iSoxH == 409) | (iSoxH == 410))	{
      if(bGaveCap == FALSE) {
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveCap = true;
      	}
      }
    }
    //check if gave armor
    else if((iSoxH == 411) | (iSoxH == 412) | (iSoxH == 413) | (iSoxH == 414))	{
      if(bGaveArmor == FALSE) {
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveArmor = true;
      	}
      }
    }
    //check if gave robe
    else if((iSoxH == 415) | (iSoxH == 416) | (iSoxH == 417) | (iSoxH == 418))	{
      if(bGaveRobe == FALSE) {
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveRobe = true;
      	}
      }
    }
    //check if gave hauberk
    else if((iSoxH == 419) | (iSoxH == 420) | (iSoxH == 421) | (iSoxH == 422))	{
      if(bGaveHauberk == FALSE) {
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveHauberk = true;
      	}
      }
    }
    //check if gave leggings
    else if((iSoxH == 423) | (iSoxH == 424) | (iSoxH == 425) | (iSoxH == 426))	{
    	if(bGaveLeggings == FALSE){
      	ItemDepleteHandler(iClientH, iSoxI, FALSE, FALSE);
      	if(_bInitItemAttr(pItem, iItemID) == 1)	{  	
        SendItemNotifyMsg(iClientH, DEF_NOTIFY_ITEMOBTAINED, pItem, NULL);	
        _bAddClientItemList(iClientH, pItem, &iEraseReq);
        bGaveLeggings = true;
      	}
    	}
    }
        wsprintf(notice,"Your hero items has been changed.");
        ShowClientMsg(iClientH, notice);

    }

  	} //if player has any required item
  }//end bucle for()
}
Please if anyone take a look at it it would be cool.

PD: It's only the change hero part, else noobs would copy :o
<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>
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

good code... hope someone help you solve the problem ;)
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
juanduran
noob
Posts: 19
Joined: Sat Dec 04, 2004 1:21 am

Post by juanduran »

good code :D ... if that code doesn't work... i think u need close the loop... with a return; and u need count hero items into the character... See u
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Didn't work :unsure:
Damn it I have tryied many times and I still can't make it work
<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>
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

halp!!
<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>
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

halp halp :ph34r:
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
Crossfade
Loyal fan
Posts: 354
Joined: Sun Mar 20, 2005 5:55 pm

Post by Crossfade »

Tafka12 wrote: halp halp :ph34r:
run for the hills!
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

faggots
<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>
juggalo2
Spamtastic
Posts: 1144
Joined: Sun Jul 17, 2005 5:28 pm

Post by juggalo2 »

Blizaga wrote: faggots
lol true lol funny


i might fix it when im baked latetr on
<img src='http://lifeplaysu420.com/unknow/nightsign.png' border='0' alt='user posted image' /><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Wanna make money for surfing the net sing up at <br><a href='http://www.cashfiesta.com/php/join.php? ... yprivitera' target='_blank'>cash fiesta</a><br>its all free hey why ntot make money while fucking around on the computer<br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daryl
Regular
Posts: 74
Joined: Thu Dec 16, 2004 1:54 am

Post by Daryl »

Ill take a look at the code this weekend... During the holidays
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

thanks! if u need full code pm me
<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>
Daryl
Regular
Posts: 74
Joined: Thu Dec 16, 2004 1:54 am

Post by Daryl »

Go ahead and PM me full details..

include your full current source for it in a txt

Explain what it does when you run it.. (saves me some time)
and tell me what you want it to do when done.




and ill jump on it this weekend
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Done
<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>
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

Weekend passed :(
<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>
omar_omiez
Loyal fan
Posts: 235
Joined: Mon Jul 12, 2004 9:36 am

Post by omar_omiez »

did u get it fixed? if not i'll try to help. been a long time since i coded any hb stuff haha.
- Tbone<br><a href="http://cyborg.namedecoder.com"><br><img src="http://cyborg.namedecoder.com/webimages ... ng"<br></a>
Post Reply