Files
TravianZ/Templates/Plus/9.tpl
T
novgorodschi catalin 0934806e8d Refactor all PLUS System
Refactor PLUS System + Fix some bugs
2026-05-20 10:57:02 +03:00

43 lines
1.8 KiB
Smarty

<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: 8.tpl ##
## Description: Wood Plus ##
## Made by: alq0rsan ##
## Improved by: evader ##
## Refactor by: Shadow ##
## ##
#################################################################################
if($session->sit == 0) {
$uid = (int)$session->uid;
$now = time();
$cost = 5;
// UPDATE atomic: scade gold DOAR dacă ai, și prelungește b1 într-o singură operație
$sql = "UPDATE ".TB_PREFIX."users
SET gold = gold - $cost,
b1 = IF(b1 > $now, b1 + ".PLUS_PRODUCTION.", $now + ".PLUS_PRODUCTION.")
WHERE id = '$uid' AND gold >= $cost";
mysqli_query($database->dblink, $sql) or die(mysqli_error($database->dblink));
if(mysqli_affected_rows($database->dblink) == 1) {
// succes - actualizează sesiunea instant (nu mai aștepți cache-ul de 10 sec)
$session->gold -= $cost;
// log
mysqli_query($database->dblink, "INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Lumber')") or die(mysqli_error($database->dblink));
// invalidează cache v9
if(method_exists($database, 'clearUserCache')) {
$database->clearUserCache($uid);
}
}
}
header("Location: plus.php?id=3");
exit;
?>