mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 11:19:22 +02:00
#24 TFS 1.0: Fixed bug allowing a player to auction and buy unlimited houses.
- Added player level restriction, configure in config.php - Configure if houses require premium - Configure allowed houses each player - Players can upgrade their house pledge on a house without increasing last_bid.
This commit is contained in:
parent
e240992845
commit
5e0170a264
15
config.php
15
config.php
@ -71,7 +71,10 @@
|
||||
'HouseListDefaultTown' => 1, // Default town id to display when visting house list page page.
|
||||
'minimumBidSQM' => 200, // minimum bid cost on auction (per SQM)
|
||||
'auctionPeriod' => 24 * 60 * 60, // 24 hours auction time.
|
||||
);
|
||||
'housesPerPlayer' => 1,
|
||||
'requirePremium' => false,
|
||||
'levelToBuyHouse' => 8,
|
||||
);
|
||||
|
||||
// Leave on black square in map and player should get teleported to their selected town.
|
||||
// If chars get buggy set this position to a beginner location to force players there.
|
||||
@ -128,12 +131,12 @@
|
||||
$config['nvForceTown'] = 0; // Force a town to no vocation even though he selected something else? 0 = no, 1 = yes.
|
||||
$config['nvTown'] = 0; // Town id to force no vocations to get to, if nvForceTown is 1.
|
||||
|
||||
// Minimum allowed character name letters. Etc 4 letters: "Kåre".
|
||||
// Minimum allowed character name letters. Etc 4 letters: "Kåre".
|
||||
$config['minL'] = 4;
|
||||
// Maximum allowed character name letters. Etc 20 letters: "Bobkåreolesofiesberg"
|
||||
// Maximum allowed character name letters. Etc 20 letters: "Bobkåreolesofiesberg"
|
||||
$config['maxL'] = 20;
|
||||
|
||||
// Maximum allowed character name words. Etc 2 words = "Bob Kåre", 3 words: "Bob Arne Kåre" as max char name words.
|
||||
// Maximum allowed character name words. Etc 2 words = "Bob Kåre", 3 words: "Bob Arne Kåre" as max char name words.
|
||||
$config['maxW'] = 2;
|
||||
|
||||
// -------------- \\
|
||||
@ -226,7 +229,7 @@
|
||||
// IMPORTANT! Write a character name(that exist) that will represent website bans!
|
||||
// Or remember to create character "God Website" character exist.
|
||||
// If you don't do this, bann from admin panel won't work properly.
|
||||
$config['website_char'] = 'God Website';
|
||||
$config['website_char'] = 'Luxitur';
|
||||
|
||||
//----------------\\
|
||||
// ADVANCED STUFF \\
|
||||
@ -418,7 +421,7 @@
|
||||
'enableShopConfirmation' => true, // Verify that user wants to buy with popup
|
||||
'useDB' => false, // Fetch offers from database, or the below config array
|
||||
'showImage' => true,
|
||||
'imageServer' => 'items.halfaway.net',
|
||||
'imageServer' => 'items.znote.eu',
|
||||
'imageType' => 'gif',
|
||||
);
|
||||
|
||||
|
95
house.php
95
house.php
@ -19,42 +19,67 @@ if ($house !== false && $config['TFSVersion'] === 'TFS_10') {
|
||||
if ($bid_amount !== false && $bid_char !== false) {
|
||||
$bid_char = (int)$bid_char;
|
||||
$bid_amount = (int)$bid_amount;
|
||||
|
||||
$player = mysql_select_single("SELECT `id`, `name`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
|
||||
// Can player afford this bid?
|
||||
if ($player['balance'] > $bid_amount) {
|
||||
// Is bid higher than previous bid?
|
||||
if ($bid_amount > $house['bid']) {
|
||||
// Is bid higher than lowest bid?
|
||||
if ($bid_amount > $minbid) {
|
||||
$lastbid = $house['bid'] + 1;
|
||||
|
||||
// Has bid already started?
|
||||
if ($house['bid_end'] > 0) {
|
||||
if ($house['bid_end'] > time()) {
|
||||
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
$player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
|
||||
// Does player have or need premium?
|
||||
$premstatus = $config['houseConfig']['requirePremium'];
|
||||
if ($premstatus) {
|
||||
$premstatus = mysql_select_single("SELECT `premdays` FROM `accounts` WHERE `id`='".$player['account_id']."' LIMIT 1;");
|
||||
$premstatus = ($premstatus['premdays'] > 0) ? true : false;
|
||||
} else $premstatus = true;
|
||||
if ($premstatus) {
|
||||
// Can player have or bid on more houses?
|
||||
$pHouseCount = mysql_select_single("SELECT COUNT('id') AS `value` FROM `houses` WHERE ((`highest_bidder`='$bid_char' AND `owner`='$bid_char') OR (`highest_bidder`='$bid_char') OR (`owner`='$bid_char')) AND `id`!='".$house['id']."' LIMIT 1;");
|
||||
if ($pHouseCount['value'] < $config['houseConfig']['housesPerPlayer']) {
|
||||
// Is character level high enough?
|
||||
if ($player['level'] >= $config['houseConfig']['levelToBuyHouse']) {
|
||||
// Can player afford this bid?
|
||||
if ($player['balance'] > $bid_amount) {
|
||||
// Is bid higher than previous bid?
|
||||
if ($bid_amount > $house['bid']) {
|
||||
// Is bid higher than lowest bid?
|
||||
if ($bid_amount > $minbid) {
|
||||
// Should only apply to external players, allowing a player to up his pledge without
|
||||
// being forced to pay his full previous bid.
|
||||
if ($house['highest_bidder'] != $player['id']) $lastbid = $house['bid'] + 1;
|
||||
else {
|
||||
$lastbid = $house['last_bid'];
|
||||
echo "<b><font color='green'>You have raised the house pledge to ".$bid_amount."gp!</font></b><br>";
|
||||
}
|
||||
// Has bid already started?
|
||||
if ($house['bid_end'] > 0) {
|
||||
if ($house['bid_end'] > time()) {
|
||||
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
}
|
||||
} else {
|
||||
$lastbid = $minbid + 1;
|
||||
$bidend = time() + $config['houseConfig']['auctionPeriod'];
|
||||
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
}
|
||||
echo "<b><font color='green'>You have the highest bid on this house!</font></b>";
|
||||
} else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>";
|
||||
} else {
|
||||
// Check if current bid is higher than last_bid
|
||||
if ($bid_amount > $house['last_bid']) {
|
||||
// Should only apply to external players, allowing a player to up his pledge without
|
||||
// being forced to pay his full previous bid.
|
||||
if ($house['highest_bidder'] != $player['id']) {
|
||||
$lastbid = $bid_amount + 1;
|
||||
mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>";
|
||||
} else {
|
||||
echo "<b><font color='orange'>You already have a higher pledge on this house.</font></b>";
|
||||
}
|
||||
} else {
|
||||
echo "<b><font color='red'>Too low bid amount, someone else has a higher bid active.</font></b>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lastbid = $minbid + 1;
|
||||
$bidend = time() + $config['houseConfig']['auctionPeriod'];
|
||||
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
}
|
||||
echo "<b><font color='green'>You have the highest bid on this house!</font></b>";
|
||||
} else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>";
|
||||
} else {
|
||||
// Check if current bid is higher than last_bid
|
||||
if ($bid_amount > $house['last_bid']) {
|
||||
$lastbid = $bid_amount + 1;
|
||||
mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
|
||||
$house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
|
||||
echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>";
|
||||
} else {
|
||||
echo "<b><font color='red'>Too low bid amount, someone else has a higher bid active.</font></b>";
|
||||
}
|
||||
}
|
||||
} else echo "<b><font color='red'>You don't have enough money to bid this high.</font></b>";
|
||||
} else echo "<b><font color='red'>You don't have enough money to bid this high.</font></b>";
|
||||
} else echo "<b><font color='red'>Your character is to low level, must be higher level than ", $config['houseConfig']['levelToBuyHouse']-1 ," to buy a house.</font></b>";
|
||||
} else echo "<b><font color='red'>You cannot have more houses.</font></b>";
|
||||
} else echo "<b><font color='red'>You need premium account to purchase houses.</font></b>";
|
||||
}
|
||||
|
||||
// HTML structure and logic
|
||||
|
Loading…
x
Reference in New Issue
Block a user