
Originally Posted by
JottaJr
Ok , i have a question .
Based on this command we can create items too ????
Change the creator for exemple " itemtable->ItemTableID " ... ?
I was coded this method for "@createitem [item ID]", but you must sure your item ID you was enter is valid or your client can be crash
Code:
void CClientSession::CreateItemById(unsigned int uiTblidx)
{
CGameServer * app = (CGameServer*) NtlSfxGetApp();
CNtlPacket packet4(sizeof(sGU_ITEM_PICK_RES));
sGU_ITEM_PICK_RES * res4 = (sGU_ITEM_PICK_RES*)packet4.GetPacketData();
res4->itemTblidx = uiTblidx;
res4->wOpCode = GU_ITEM_PICK_RES;
res4->wResultCode = GAME_SUCCESS;
int ItemPos = 0;
app->db->prepare("SELECT * FROM items WHERE owner_ID = ? AND place=1 ORDER BY pos ASC");
app->db->setInt(1, this->plr->pcProfile->charId);
app->db->execute();
int k = 0;
while (app->db->fetch())
{
if (app->db->getInt("pos") < NTL_MAX_ITEM_SLOT)
ItemPos = app->db->getInt("pos") + 1;
else
ItemPos = app->db->getInt("pos");
k++;
}
app->db->prepare("CALL BuyItemFromShop (?,?,?,?,?, @Unique_iID)");
app->db->setInt(1, uiTblidx);
app->db->setInt(2, this->plr->pcProfile->charId);
app->db->setInt(3, ItemPos);
app->db->setInt(4, 1);
app->db->setInt(5, 100);
app->db->execute();
app->db->execute("SELECT @Unique_iID");
app->db->fetch();
CNtlPacket packet2(sizeof(sGU_ITEM_CREATE));
sGU_ITEM_CREATE * res2 = (sGU_ITEM_CREATE *)packet2.GetPacketData();
res2->bIsNew = true;
res2->wOpCode = GU_ITEM_CREATE;
res2->handle = app->db->getInt( @Unique_iID");
res2->sItemData.charId = this->GetavatarHandle();
res2->sItemData.itemNo = uiTblidx;
res2->sItemData.byStackcount = 1;
res2->sItemData.itemId = app->db->getInt( @Unique_iID");
res2->sItemData.byPlace = 1;
res2->sItemData.byPosition = ItemPos;
res2->sItemData.byCurrentDurability = 100;
res2->sItemData.byRank = 1;
packet2.SetPacketLen(sizeof(sGU_ITEM_CREATE));
packet4.SetPacketLen(sizeof(sGU_ITEM_PICK_RES));
g_pApp->Send(this->GetHandle(), &packet2);
g_pApp->Send(this->GetHandle(), &packet4);
}