Hey there Mootie, I've got a code which allow everyone to use /awaken command and I need to complete the code so it will stop people from using that command(function) during trades/mail/shops as it might cause scams/exploits (IMO) this is the code:
BOOL TextCmd_GenRandomOption( CScanner & s )
{
#ifdef __WORLDSERVER
CUser* pUser = (CUser*)s.dwValue;
#ifndef __TAB_INVENTORY
CItemElem* pItemElem = pUser->m_Inventory.GetAt( 0 );
#else
DWORD dwObjId = s.GetNumber();
CItemElem* pItemElem = pUser->m_Inventory.GetAtId( dwObjId );
#endif // __TAB_INVENTORY
if( pItemElem ){
int nRandomOptionKind = g_xRandomOptionProperty->GetRandomOptionKind( pItemElem );
if( nRandomOptionKind >= 0 ){
if(pUser->HasActivatedSystemPet() && pItemElem->GetProp()->dwItemKind3 == IK3_EGG || pUser->HasActivatedEatPet() && pItemElem->GetProp()->dwItemKind3 == IK3_PET ){
pUser->AddText( "Put your pet back into your inventory." );
}else{
if( pUser->GetGold() >= 1 ){
g_xRandomOptionProperty->InitializeRandomOption( pItemElem->GetRandomOptItemIdPtr() );
g_xRandomOptionProperty->GenRandomOption( pItemElem->GetRandomOptItemIdPtr(), nRandomOptionKind, pItemElem->GetProp()->dwParts );
pUser->UpdateItemEx( (BYTE)( pItemElem->m_dwObjId ), UI_RANDOMOPTITEMID, pItemElem->GetRandomOptItemId() );
pUser->AddGold( 0 );
//pUser->AddText( "Dir wurden 100.000 Penya für das Erwecken abgezogen." );
}else{
pUser->AddText( "You need to have at least 1 Penya in order to awaken this item." );
}
}
}else{
pUser->AddText ( "Either your pet is not level C or your item doesn't fit the awaken scroll meetings." );
}
}
#endif // __WORLDSERVER
#if defined(__CLIENT) && defined ( __TAB_INVENTORY)
if( g_WndMng.m_pWndUpgradeBase == NULL )
{
SAFE_DELETE( g_WndMng.m_pWndUpgradeBase );
g_WndMng.m_pWndUpgradeBase = new CWndUpgradeBase;
g_WndMng.m_pWndUpgradeBase->Initialize( &g_WndMng, APP_TEST );
return FALSE;
}
if( g_WndMng.m_pWndUpgradeBase )
{
if( g_WndMng.m_pWndUpgradeBase->m_pItemElem[0] )
{
DWORD dwObjId = g_WndMng.m_pWndUpgradeBase->m_pItemElem[0]->m_dwObjId;
char szSkillLevel[MAX_PATH];
sprintf( szSkillLevel, "/awaken %d", dwObjId);
s.SetProg( szSkillLevel );
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
#endif // __TAB_INVENTORY
return TRUE;
}
what I do (think) I realize by myself is that this states whether it should allow to awaken or not:
if so, idk what I should put in to block it from trades/shops/mails but might be something like HasactivatedTrade / HasActivatedShop / HasActivatedMailif(pUser->HasActivatedSystemPet() && pItemElem->GetProp()->dwItemKind3 == IK3_EGG || pUser->HasActivatedEatPet() && pItemElem->GetProp()->dwItemKind3 == IK3_PET ){
pUser->AddText( "Put your pet back into your inventory." );
please know that you're not only helping me to fix it but you're also helping me to increase my general knowledge in this kind of stuff, so any reply is very appreciated, thanks!
EDIT:
got into this situation:
or thisCWndShop* pWndShop = (CWndShop*)g_WndMng.GetWndBase( APP_SHOP_ );
if( pWndShop )
pWndShop->Destroy();
CWndTrade* pWndTrade = (CWndTrade*)g_WndMng.GetWndBase( APP_TRADE );
if( pWndTrade )
pWndTrade->Destroy();
BOOL TextCmd_GenRandomOption( CScanner & s )
{
#ifdef __WORLDSERVER
CUser* pUser = (CUser*)s.dwValue;
#ifndef __TAB_INVENTORY
CItemElem* pItemElem = pUser->m_Inventory.GetAt( 0 );
#else
DWORD dwObjId = s.GetNumber();
CItemElem* pItemElem = pUser->m_Inventory.GetAtId( dwObjId );
#endif // __TAB_INVENTORY
if( pItemElem ){
int nRandomOptionKind = g_xRandomOptionProperty->GetRandomOptionKind( pItemElem );
if( nRandomOptionKind >= 0 ){
CWndShop* pWndShop = (CWndShop*)g_WndMng.GetWndBase( APP_SHOP_ );
if( pWndShop )
pWndShop->Destroy();
CWndTrade* pWndTrade = (CWndTrade*)g_WndMng.GetWndBase( APP_TRADE );
if( pWndTrade )
pWndTrade->Destroy();
CWndConfirmTrade* pWndConfirmTrade = (CWndConfirmTrade*)g_WndMng.GetApplet( APP_CONFIRM_TRADE );
if( pWndConfirmTrade )
pWndConfirmTrade->Destroy();
CWndTradeConfirm* pWndTradeConfirm = (CWndTradeConfirm*)g_WndMng.GetWndBase( APP_TRADE_CONFIRM );
if( pWndTradeConfirm )
pWndTradeConfirm->Destroy();
SAFE_DELETE( g_WndMng.m_pWndTradeGold );
g_pPlayer->OnTradeRemoveUser();
g_pPlayer->m_vtInfo.SetOther( NULL );
if(pUser->HasActivatedSystemPet() && pItemElem->GetProp()->dwItemKind3 == IK3_EGG || pUser->HasActivatedEatPet() && pItemElem->GetProp()->dwItemKind3 == IK3_PET )
{
pUser->AddText( "Deactivate your pet." );
}
else
{
if( pUser->GetGold() >= 1 )
{
g_xRandomOptionProperty->InitializeRandomOption( pItemElem->GetRandomOptItemIdPtr() );
g_xRandomOptionProperty->GenRandomOption( pItemElem->GetRandomOptItemIdPtr(), nRandomOptionKind, pItemElem->GetProp()->dwParts );
pUser->UpdateItemEx( (BYTE)( pItemElem->m_dwObjId ), UI_RANDOMOPTITEMID, pItemElem->GetRandomOptItemId() );
pUser->AddGold( 0 );
//pUser->AddText( "Dir wurden 100.000 Penya für das Erwecken abgezogen." );
}
else
{
pUser->AddText( "You need to have at least 1 Penya in order to awaken this item." );
}
}
}else{
pUser->AddText ( "Either your pet is not level C or your item doesn't suit the requirments of the scroll." );
}
}
#endif // __WORLDSERVER
it doesn't work tho...







