You last visited: Today at 17:41
Advertisement
(Release) Lock item
Discussion on (Release) Lock item within the Flyff PServer Guides & Releases forum part of the Flyff Private Server category.
03/23/2020, 15:12
#1
elite*gold: 0
Join Date: Aug 2010
Posts: 98
Received Thanks: 76
(Release) Lock item
Hola
This code is used to prevent the accidental sale or deletion of objects. You can use this 'system' for a quick sale system at NPC. I saw this system on another server, I recoded it myself. Mine works by performing SHIFT + Double click. I give it for free because I think it's very useful and I would like to see it more often on the servers.
DPClient.cpp
Code:
#ifdef __LOCK_ITEM
void CDPClient::SendLockItem(DWORD dwId)
{
BEFORESENDSOLE(ar, PACKETTYPE_LOCK_ITEM, DPID_UNKNOWN);
ar << dwId;
SEND(ar, this, DPID_SERVERPLAYER);
}
#endif // __LOCK_ITEM
DPClient.h
Code:
#ifdef __LOCK_ITEM
void SendLockItem(DWORD dwId);
#endif // __LOCK_ITEM
DPSrvr.cpp
Code:
#ifdef __LOCK_ITEM
ON_MSG(PACKETTYPE_LOCK_ITEM, &CDPSrvr::OnLockItem);
#endif // __LOCK_ITEM
Code:
void CDPSrvr::OnDropItem( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
{
DWORD dwItemType;
DWORD dwItemId;
short nDropNum;
D3DXVECTOR3 vPos;
ar >> dwItemType >> dwItemId >> nDropNum >> vPos;
if( nDropNum <= 0 )
return;
CUser* pUser = g_UserMng.GetUser( dpidCache, dpidUser );
if( IsValidObj(pUser) )
{
#ifdef __LOCK_ITEM
CItemElem* pItemElem = (CItemElem*)pUser->GetItemId(dwItemId);
if (pItemElem && pItemElem->IsFlag(CItemElem::locked))
return;
#endif // __LOCK_ITEM
if( g_eLocal.GetState( EVE_DROPITEMREMOVE ) )
{
#ifndef __LOCK_ITEM
CItemElem* pItemElem = (CItemElem*)pUser->GetItemId( dwItemId );
#endif // __LOCK_ITEM
if( IsUsableItem( pItemElem ) && pUser->IsDropable( pItemElem, FALSE ) )
pUser->RemoveItem( (BYTE)dwItemId, nDropNum );
}
else
{
pUser->DropItem( (DWORD)dwItemId, nDropNum, vPos );
}
}
}
Code:
void CDPSrvr::OnSellItem( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
{
BYTE nId;
short nNum;
ar >> nId >> nNum;
if( nNum < 1 )
return;
CUser* pUser = g_UserMng.GetUser( dpidCache, dpidUser );
if( IsValidObj( pUser ) && IsValidObj( pUser->m_vtInfo.GetOther() ) )
{
if( pUser->m_vtInfo.GetOther()->IsNPC() == FALSE )
return;
if( !CNpcChecker::GetInstance()->IsCloseNpc( MMI_TRADE, pUser->GetWorld(), pUser->GetPos() ) )
return;
CItemElem* pItemElem = pUser->m_Inventory.GetAtId( nId );
#ifdef __LOCK_ITEM
if (pItemElem && pItemElem->IsFlag(CItemElem::locked))
return;
#endif // __LOCK_ITEM
if( IsUsableItem( pItemElem ) == FALSE )
return;
Code:
void CDPSrvr::OnRemoveInvenItem( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
{
DWORD dwId;
int nNum;
ar >> dwId;
ar >> nNum;
if( nNum <= 0 )
return;
CUser* pUser = g_UserMng.GetUser( dpidCache, dpidUser );
if( IsValidObj( pUser ) == FALSE )
return;
CItemElem* pItemElem = pUser->m_Inventory.GetAtId( dwId );
#ifdef __LOCK_ITEM
if (pItemElem && pItemElem->IsFlag(CItemElem::locked))
return;
#endif // __LOCK_ITEM
Code:
#ifdef __LOCK_ITEM
void CDPSrvr::OnLockItem(CAr& ar, DPID dpidCache, DPID dpidUser, LPBYTE, u_long)
{
CUser* pUser = g_UserMng.GetUser(dpidCache, dpidUser);
if (IsValidObj(pUser))
{
DWORD dwItemId;
ar >> dwItemId;
CItemElem* pItemElem = pUser->m_Inventory.GetAtId(dwItemId);
if (pItemElem)
pUser->LockItem(pItemElem, !pItemElem->IsFlag(CItemElem::locked));
}
}
#endif // __LOCK_ITEM
DPSrvr.h
Code:
#ifdef __LOCK_ITEM
void OnLockItem(CAr& ar, DPID dpidCache, DPID dpidUser, LPBYTE, u_long);
#endif // __LOCK_ITEM
User.cpp
Code:
#ifdef __LOCK_ITEM
BOOL CUser::LockItem(CItemElem* pItemElem, BOOL bLock)
{
if (IsUsableItem(pItemElem) == FALSE)
{
AddDefinedText(TID_GAME_CANNOT_POST);
return FALSE;
}
if (m_Inventory.IsEquip(pItemElem->m_dwObjId))
{
AddDefinedText(TID_GAME_CANNOT_POST);
return FALSE;
}
if (IsUsing(pItemElem))
{
AddDefinedText(TID_GAME_CANNOT_DO_USINGITEM);
return FALSE;
}
if (pItemElem->IsFlag(CItemElem::locked) == bLock)
return FALSE;
pItemElem->SetFlag(CItemElem::locked, bLock);
UpdateItem((BYTE)pItemElem->m_dwObjId, UI_FLAG, MAKELONG(pItemElem->m_dwObjIndex, pItemElem->m_byFlag));
return TRUE;
}
#endif // __LOCK_ITEM
User.h
Code:
#ifdef __LOCK_ITEM
BOOL LockItem(CItemElem* pItemElem, BOOL bLock = TRUE);
#endif // __LOCK_ITEM
Item.h and Obj.h
Code:
enum
{
expired = 0x01,
binds = 0x02,
isusing = 0x04,
#ifdef __LOCK_ITEM
locked = 0x08
#endif // __LOCK_ITEM
};
WndField.cpp
Code:
BOOL CWndInventory::OnDropIcon( LPSHORTCUT pShortcut, CPoint point )
{
CWndBase* pWndFrame = pShortcut->m_pFromWnd->GetFrameWnd();
if(pWndFrame == NULL)
return FALSE;
if( g_WndMng.GetWndBase( APP_SHOP_ ) ||
g_WndMng.GetWndBase( APP_BANK ) ||
g_WndMng.GetWndBase( APP_TRADE ) )
{
if( pWndFrame->GetWndId() == APP_INVENTORY )
{
SetForbid( TRUE );
g_WndMng.PutString( prj.GetText(TID_GAME_TRADELIMITUSING), NULL, prj.GetTextColor(TID_GAME_TRADELIMITUSING) );
return FALSE;
}
}
else if( g_WndMng.GetWndBase( APP_REPAIR ) )
{
if( pWndFrame->GetWndId() == APP_INVENTORY )
{
SetForbid( TRUE );
g_WndMng.PutString( prj.GetText(TID_GAME_REPAIR_NOTUSE), NULL, prj.GetTextColor(TID_GAME_TRADELIMITUSING) );
return FALSE;
}
}
else if( g_WndMng.GetWndBase( APP_INVENTORY ) )
{
if( pWndFrame->GetWndId() == APP_INVENTORY )
{
LPWNDCTRL lpWndCtrl1 = GetWndCtrl( WIDC_CUSTOM21 );
if( lpWndCtrl1->rect.PtInRect( point ) )
{
if( pShortcut->m_dwType == ITYPE_ITEM && pShortcut->m_dwData )
{
CItemElem* pItemElem = (CItemElem*)g_pPlayer->GetItemId( pShortcut->m_dwId );
if( !pItemElem )
return FALSE;
if(pItemElem->GetExtra() > 0)
return FALSE;
if( g_pPlayer->m_Inventory.IsEquip( pShortcut->m_dwId ) )
return FALSE;
if( g_pPlayer->IsUsing( pItemElem ) )
return FALSE;
if( pItemElem->IsUndestructable() == TRUE )
{
g_WndMng.PutString( prj.GetText( TID_GAME_ERROR_UNDESTRUCTABLE_ITEM ), NULL, prj.GetTextColor( TID_GAME_ERROR_UNDESTRUCTABLE_ITEM ) );
return FALSE;
}
#ifdef __LOCK_ITEM
if (pItemElem->IsFlag(CItemElem::locked))
{
g_WndMng.PutString(prj.GetText(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM), NULL, prj.GetTextColor(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM));
return FALSE;
}
#endif // __LOCK_ITEM
WndItemCtrl.cpp
in onDraw function :
Code:
CWndInventory* pWndInventory = (CWndInventory*)GetWndBase( APP_INVENTORY );
if( pWndInventory )
{
if( pWndInventory->m_pUpgradeItem && pItemElem )
{
if( pWndInventory->m_pUpgradeItem == pItemElem )
{
if( pWndInventory->m_dwEnchantWaitTime != 0xffffffff )
{
#if __VER >= 19
CPoint pt((x * 35) + 1, (y * 35) + 3);
#else // __VER >= 19
CPoint pt(x * 32, y * 32);
#endif // __VER >= 19
RenderEnchant( p2DRender, pt );
}
}
}
}
#ifdef __LOCK_ITEM
if (pItemElem->IsFlag(CItemElem::locked))
{
CTexture* pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ICON, "icon_LockItem.dds"), 0xffff00ff);
if (pTexture)
{
#if __VER >= 19
pTexture->Render(p2DRender, CPoint(x * 35, (y * 35) + 4), 255);
#else // __VER >= 19
pTexture->Render(p2DRender, CPoint(x * 32, (y * 32) + 4), 255);
#endif // __VER >= 19
}
}
#endif // __LOCK_ITEM
Code:
void CWndItemCtrl::OnLButtonDblClk( UINT nFlags, CPoint point )
{
if( !g_pPlayer )
return;
if( !m_pItemContainer )
return;
if( GetAsyncKeyState( VK_LCONTROL ) & 0x8000 )
return;
#ifdef __LOCK_ITEM
#if __VER >= 14 // __SMELT_SAFETY
if (!g_WndMng.m_pWndSmeltSafety && GetAsyncKeyState(VK_LSHIFT) & 0x8000)
#else // __SMELT_SAFETY
if (GetAsyncKeyState(VK_LSHIFT) & 0x8000)
#endif // __SMELT_SAFETY
{
CWndBase* pWndBase = this->GetParentWnd();
if (pWndBase)
{
CWndBase* pWndBaseTemp = pWndBase->GetParentWnd();
if (pWndBaseTemp)
{
int nParent = pWndBaseTemp->GetWndId();
if (nParent == APP_INVENTORY)
{
int nItem = HitTest(point);
if (nItem != -1)
{
CItemElem* pItemElem = GetItem(nItem);
if (pItemElem) {
g_DPlay.SendLockItem(pItemElem->m_dwObjId);
}
}
}
}
}
return;
}
#endif // __LOCK_ITEM
WndShop.cpp
Code:
{
LPCTSTR szErr = Error( "CWndShop::OnChildNotify : pItemElem==NULL %d", pItemElem->m_dwItemId );
ADDERRORMSG( szErr );
}
if( FALSE == g_pPlayer->m_Inventory.IsEquip( ( (CItemElem*)lpShortcut->m_dwData)->m_dwObjId ) )
{
#ifdef __LOCK_ITEM
if (pItemElem->IsFlag(CItemElem::locked))
{
g_WndMng.PutString(prj.GetText(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM), NULL, prj.GetTextColor(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM));
return FALSE;
}
#endif // __LOCK_ITEM
if( bWarning )
{
SAFE_DELETE( m_pWndWarning );
SAFE_DELETE( m_pWndConfirmSell );
m_pWndWarning = new CWndWarning;
m_pWndWarning->m_pItemElem = (CItemElem*)lpShortcut->m_dwData;
m_pWndWarning->m_pMover = m_pMover;
m_pWndWarning->Initialize( this, APP_WARNING );
}
WndWorld.cpp
Code:
CItemElem* pItemElem = (CItemElem*)pShortcut->m_dwData;
if( pItemElem->IsUndestructable() == TRUE )
{
g_WndMng.PutString( prj.GetText( TID_GAME_ERROR_UNDESTRUCTABLE_ITEM ), NULL, prj.GetTextColor( TID_GAME_ERROR_UNDESTRUCTABLE_ITEM ) );
return FALSE;
}
#ifdef __LOCK_ITEM
if (pItemElem->IsFlag(CItemElem::locked))
{
g_WndMng.PutString(prj.GetText(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM), NULL, prj.GetTextColor(TID_GAME_ERROR_UNDESTRUCTABLE_ITEM));
return FALSE;
}
#endif // __LOCK_ITEM
MsgHdr.h
Code:
#ifdef __LOCK_ITEM
#define PACKETTYPE_LOCK_ITEM (DWORD)0x88100267
#endif // __LOCK_ITEM
result:
03/23/2020, 20:42
#2
elite*gold: 28
Join Date: Feb 2010
Posts: 463
Received Thanks: 277
IsUsableItem isn't for dog, use it.
Call it before you use pItemElem.
03/24/2020, 01:37
#3
elite*gold: 0
Join Date: Aug 2010
Posts: 98
Received Thanks: 76
Quote:
Originally Posted by
ZeroTwo02
IsUsableItem isn't for dog, use it.
Call it before you use pItemElem.
Look at the body of the method before giving advice, disrespectfully in addition. Thanks.
03/24/2020, 07:14
#4
elite*gold: 0
Join Date: Mar 2018
Posts: 23
Received Thanks: 0
have problem with the
pItemElem->SetFlag(CItemElem::locked, bLock)
the error is
CItemElem::SetFlag function does not take 2 arguments
thank you for this release
03/24/2020, 08:28
#5
elite*gold: 0
Join Date: Jan 2020
Posts: 78
Received Thanks: 0
Thank you for posting, does this require a bank password?
03/24/2020, 10:52
#6
elite*gold: 28
Join Date: Feb 2010
Posts: 463
Received Thanks: 277
Quote:
Originally Posted by
Seigh77
have problem with the
pItemElem->SetFlag(CItemElem::locked, bLock)
the error is
CItemElem::SetFlag function does not take 2 arguments
thank you for this release
Because he change the SetFlag function to add a BOOL "bLock".
Hard to use SetFlag for "lock" and ResetFlag for remove "lock".
Quote:
Originally Posted by
sebariio
Look at the body of the method before giving advice, disrespectfully in addition. Thanks.
It is good to use IsUsableItem on the CUser::LockItem, but you have to use it also on CDPSrvr::OnLockItem.
03/24/2020, 13:39
#7
elite*gold: 0
Join Date: Aug 2010
Posts: 98
Received Thanks: 76
Quote:
Originally Posted by
Seigh77
have problem with the
pItemElem->SetFlag(CItemElem::locked, bLock)
the error is
CItemElem::SetFlag function does not take 2 arguments
thank you for this release
Code:
void SetFlag(BYTE byFlag, BOOL bEnable = TRUE) { if (bEnable) m_byFlag |= byFlag; else m_byFlag &= ~byFlag; }
03/25/2020, 10:29
#8
elite*gold: 0
Join Date: Mar 2018
Posts: 23
Received Thanks: 0
Quote:
Originally Posted by
sebariio
Code:
void SetFlag(BYTE byFlag, BOOL bEnable = TRUE) { if (bEnable) m_byFlag |= byFlag; else m_byFlag &= ~byFlag; }
can you share your icon please
thank you
03/25/2020, 10:56
#9
elite*gold: 0
Join Date: Aug 2016
Posts: 308
Received Thanks: 372
Quote:
Originally Posted by
Seigh77
can you share your icon please
thank you
There you go
Attached Files
Icon_Lock.rar
(666 Bytes, 112 views)
03/28/2020, 14:31
#10
elite*gold: 0
Join Date: Aug 2010
Posts: 98
Received Thanks: 76
Quote:
Originally Posted by
Seigh77
can you share your icon please
thank you
My icon:
07/27/2020, 20:55
#11
elite*gold: 0
Join Date: Mar 2015
Posts: 3
Received Thanks: 0
Quote:
Originally Posted by
sebariio
Code:
#ifdef __LOCK_ITEM
if (pItemElem->IsFlag(CItemElem::locked))
{
CTexture* pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ICON, "icon_LockItem.dds"), 0xffff00ff);
if (pTexture)
pTexture->Render(p2DRender, CPoint(x * 35, (y * 35) + 4), 255);
}
#endif // __LOCK_ITEM
Hey, first of all, thank you for the release,
Can u be more specific about the place of this part of code ?
04/09/2021, 20:08
#12
elite*gold: 0
Join Date: Nov 2009
Posts: 182
Received Thanks: 13
I have some error please help there !
Thankyou so much !
04/10/2021, 12:55
#13
elite*gold: 0
Join Date: Jan 2021
Posts: 29
Received Thanks: 2
Quote:
Originally Posted by
bhengot
I have some error please help there !
Thankyou so much !
for you error CItemElem::SetFlag here's the solution
void SetFlag(BYTE byFlag, BOOL bEnable = TRUE) { if (bEnable) m_byFlag |= byFlag; else m_byFlag &= ~byFlag; }
It was posted up you have to read the article.
For the error AddDefinedText identifier not found
User.cpp
Add
Above of void CUser::AddChatText ( int dwText, LPCSTR lpszFormat, ... )
Void CUser::AddDefinedText ( int dwText, LPCSTR lpszFormat, ... )
{
if( IsDelete () ) return;
TCHAR szBuffer[1024];
va_list args;
va_start ( args, lpszFormat );
int nBuf = _vsntprintf ( szBuffer, sizeof ( szBuffer ) - 1, lpszFormat, args );
va_end ( args );
if( nBuf < 0 )
return;
m_Snapshot.cb++;
m_Snapshot.ar << GetId ();
m_Snapshot.ar << SNAPSHOTTYPE_DEFINEDTEXT;
m_Snapshot.ar << dwText;
m_Snapshot.ar.WriteString ( szBuffer );
}
on User.h
Add
void AddDefinedText( int dwText, LPCSTR lpszFormat, ... );
Above of void AddChatText( int dwText, LPCSTR lpszFormat, ... );
For the Lockitem is not a member of CUser
Place this on your User.h
#ifdef __LOCK_ITEM
BOOL LockItem(CItemElem* pItemElem, BOOL bLock = TRUE);
#endif // __LOCK_ITEM
Above of
BOOL IsValid();
04/10/2021, 18:04
#14
elite*gold: 0
Join Date: Mar 2013
Posts: 205
Received Thanks: 38
Quote:
Originally Posted by
Hikari Kuina
for you error CItemElem::SetFlag here's the solution
void SetFlag(BYTE byFlag, BOOL bEnable = TRUE) { if (bEnable) m_byFlag |= byFlag; else m_byFlag &= ~byFlag; }
It was posted up you have to read the article.
For the error AddDefinedText identifier not found
User.cpp
Add
Above of void CUser::AddChatText ( int dwText, LPCSTR lpszFormat, ... )
Void CUser::AddDefinedText ( int dwText, LPCSTR lpszFormat, ... )
{
if( IsDelete () ) return;
TCHAR szBuffer[1024];
va_list args;
va_start ( args, lpszFormat );
int nBuf = _vsntprintf ( szBuffer, sizeof ( szBuffer ) - 1, lpszFormat, args );
va_end ( args );
if( nBuf < 0 )
return;
m_Snapshot.cb++;
m_Snapshot.ar << GetId ();
m_Snapshot.ar << SNAPSHOTTYPE_DEFINEDTEXT;
m_Snapshot.ar << dwText;
m_Snapshot.ar.WriteString ( szBuffer );
}
on User.h
Add
void AddDefinedText( int dwText, LPCSTR lpszFormat, ... );
Above of void AddChatText( int dwText, LPCSTR lpszFormat, ... );
For the Lockitem is not a member of CUser
Place this on your User.h
#ifdef __LOCK_ITEM
BOOL LockItem(CItemElem* pItemElem, BOOL bLock = TRUE);
#endif // __LOCK_ITEM
Above of
BOOL IsValid();
For the error AddDefinedText identifier not found
just change it to AddText
04/18/2021, 16:02
#15
elite*gold: 0
Join Date: Nov 2009
Posts: 182
Received Thanks: 13
Already Fix it guys thankyou for your reply <3
Similar Threads
[Selling] [Growtopia Lock Store] Selling Diamond Lock, World Lock and Blue Gem Lock at Eznpc
06/17/2021 - Mobile Games Trading - 7 Replies
Selling Diamond Lock, World Lock and Blue Gem Lock at Eznpc
Hello there,
Eznpc is selling Cheap and Safe Diamond Lock, World Lock and Blue Gem Lock.
Use code Cherry for 6% off.
100x World Lock = $3
1x Diamond Lock = $2.49
[Selling] [Growtopia Lock Store] selling World, Diamond & Royal lock at best prices!
09/20/2017 - Mobile Games Trading - 0 Replies
Selling Growtopia World Lock, Diamond Lock & Royal Lock!!
40x World Lock = $3 (Stock upon request)
1x Diamond Lock = $4.5 (Stock upon request)
1x Royal Lock = $15 (Stock upon request)
*Message me for more item request
Everything discussed via chat including Nickname and World Name for doing transaction.
[Release] Item lock for NewestCOServer
03/25/2010 - CO2 PServer Guides & Releases - 109 Replies
Search for;
Add above;
case 2048:
{
PacketHandling.ItemLock.Handle(GC, Data);
break;
}
5165 Item lock, and item redeem.
02/09/2010 - CO2 Private Server - 4 Replies
Anyone knows how to make the item lock and redeem items npc in 5165?
Im not too good at that stuff, and it'll be great if someone could help me. :handsdown:
Betteln an die lock mob götter S 15 lock mob
02/04/2009 - Metin2 - 1 Replies
dieser thread geht vor allen dingen an banjo aber wers sonst noch kann kann den lock mob ja auch mal updaten
also pls lock mob für s15/16
All times are GMT +2. The time now is 17:41 .