03-17-2015, 03:28 AM
mmm I have not done for shop I use a lot of items
and is configured to collect gold
put this in the file classes.php
function GetitemBalance( $cid, &$invRow, &$invCol, &$invAmount )
{
global $LC_Db; global $con_cms_pdo;
$l = substr($cid, -1);
$query = sprintf
("
SELECT
a_item_idx0,
a_item_idx1,
a_item_idx2,
a_item_idx3,
a_item_idx4,
a_count0,
a_count1,
a_count2,
a_count3,
a_count4,
a_row_idx
FROM
%s.t_inven0".$l."
WHERE
a_char_idx = :cidindex
", $LC_Db );
$dbh = $con_cms_pdo->prepare( $query );
$dbh->execute( array( ':cidindex' => $cid ));
$invRow = -1;
$invCol = -1;
$invAmount = 0;
while( $row = $dbh->fetch() )
{
$r = $row['a_row_idx'];
for( $c=0; $c<5; $c++ )
{
if( $row['a_item_idx'.$c] == 19999 )// ITEM ID
{
$invRow = $r;
$invCol = $c;
$invAmount = $row['a_count'.$c];
}
}
}
}
function DeductItem($cid, $row, $col, $amount)
{
$l = substr($cid, -1);
global $LC_Db; global $con_cms_pdo;
$query = sprintf
("
UPDATE
%s.t_inven0%d
SET
a_count%d = %s
WHERE
a_char_idx = '%s'
AND
a_row_idx = '%s'
", $LC_Db,
$l,
$col,
$amount,
$cid,
$row );
$dbh = $con_cms_pdo->prepare( $query );
$dbh->execute();
}
and then change the following line from: reborn.php
if ($clevel >= $S_rborn_level && $creborns <= $S_rborn_allow){
$Ctrl->GetGoldBalance( $cid, $row, $col, $amount );
if ($amount > $S_rborn_gold){
$dgold = $amount - $S_rborn_gold;
$query9T = sprintf("UPDATE %s.t_characters SET a_level=".$S_rborn_slevel.", a_exp=0, a_statpt_remain = (a_statpt_remain+".$S_rborn_rstats.") WHERE a_index = '".$cid."' ", $LC_Db );
$dbh9T = $con_cms_pdo->prepare( $query9T );
$dbh9T->execute();
$query10T = sprintf("UPDATE %s.t_reborn_log SET a_reborns=(a_reborns+1) WHERE a_index = '".$cid."' ", $LC_CMSDb );
$dbh10T = $con_cms_pdo->prepare( $query10T );
$dbh10T->execute();
$Ctrl->DeductGold( $cid, $row, $col, $dgold );
GetGoldBalance ----->GetItemBalance
DeductGold ------>DeductItem

