Added shop categories, mounts and outfits.

Display outfits currently only work in shop.
This commit is contained in:
Znote 2017-01-30 06:48:46 +01:00
parent be49eb98e2
commit 695cb58b04
7 changed files with 440 additions and 61 deletions

View File

@ -32,11 +32,30 @@ function onSay(cid, words, param)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
-- ORDER TYPE 6 (Mounts)
-- Not supported on TFS 0.2
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Not for TFS 0.2)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")

View File

@ -33,11 +33,41 @@ function onSay(cid, words, param)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
result.free(delete)
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
-- ORDER TYPE 6 (Mounts)
if q_type == 6 then
-- Make sure player don't already have this outfit and addon
if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function?
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
result.free(delete)
doPlayerAddMount(cid, q_itemid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")

View File

@ -43,11 +43,39 @@ function onSay(cid, words, param)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!")
end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not canPlayerWearOutfit(cid, q_itemid, q_count) then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddOutfit(cid,q_itemid,q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
-- ORDER TYPE 6 (Mounts)
if q_type == 6 then
-- Make sure player don't already have this outfit and addon
if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function?
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddMount(cid, q_itemid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")

View File

@ -29,11 +29,41 @@ function onSay(player, words, param)
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- ORDER TYPE 5 (Outfit and addon)
if q_type == 5 then
-- Make sure player don't already have this outfit and addon
if not player:hasOutfit(q_itemid, q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addOutfit(q_itemid)
player:addOutfitAddon(q_itemid, q_count)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
end
end
-- ORDER TYPE 6 (Mounts)
if q_type == 6 then
-- Make sure player don't already have this outfit and addon
if not player:hasMount(q_itemid) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addMount(q_itemid)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
end
end
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web)
-- Type 3 is for gender change (Coded on web)
-- Type 4 is for character name change (Coded on web)
-- Type 5 is for character outfit and addon (Already coded here)
-- Type 6 is for mounts (Already coded here)
-- So use type 7+ for custom stuff, like etc packages.
-- if q_type == 7 then
-- end
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have no orders.")

View File

@ -568,6 +568,17 @@
'server' => 'http://flag.znote.eu'
);
// Show outfits
$config['show_outfits'] = array(
'shop' => true,
'highscores' => false, // Not implemented yet
'characterprofile' => false, // Not implemented yet
'onlinelist' => false, // Not implemented yet
// Image server may be unreliable and only for test,
// host yourself: https://otland.net/threads/item-images-10-92.242492/
'imageServer' => 'http://outfit-images.ots.me/animatedOutfits1090/animoutfit.php'
);
// Level requirement to create guild? (Just set it to 1 to allow all levels).
$config['create_guild_level'] = 8;
@ -898,56 +909,86 @@
// sellable before auctioneer can claim character back.
);
// If useDB is false, this array list will be used for shop offers.
/*
type 1 = items
type 2 = Premium days
type 3 = Change character gender
type 4 = Change character name
type 5 = Buy outfit (put outfit id as itemid),
(put addon id as count [0 = nothing, 1 = first addon, 2 = second addon, 3 = both addons])
type 6 = Buy mount (put mount id as itemid)
type 7+ = custom coded stuff
*/
$config['shop_offers'] = array(
// offer 1
1 => array(
'type' => 1, // 1 = item id offers, 2 = premium days [itemid ignored], 3 = sex change[itemid & count ignored], 4+ = custom.
'type' => 1,
'itemid' => 2160, // item to get in-game
'count' => 5, //if type is 2, this represents premium days
'description' => "Crystal coin.", // Description shown on website
'count' => 5, // Stack number (5x itemid)
'description' => "Crystal coin", // Description shown on website
'points' => 100, // How many points this offer costs
),
// offer 2
2 => array(
'type' => 1,
'itemid' => 2392,
'count' => 1,
'description' => "Fire sword.",
'description' => "Fire sword",
'points' => 10,
),
// offer 3
3 => array(
'type' => 2,
'itemid' => 12466, // Item to display on page
'count' => 7,
'description' => "Premium membership.",
'count' => 7, // Days of premium account
'description' => "Premium membership",
'points' => 25,
),
// offer 4
4 => array(
'type' => 3,
'itemid' => 12666,
'itemid' => 12666, // Item to display on page
'count' => 3,
'description' => "Change character gender.",
'description' => "Change character gender",
'points' => 10,
),
5 => array(
'type' => 3,
'itemid' => 12666,
'count' => 0,
'description' => "Change character gender.",
'itemid' => 12666, // Item to display on page
'count' => 0, // 0 = unlimited
'description' => "Change character gender",
'points' => 20,
),
5 => array(
6 => array(
'type' => 4,
'itemid' => 12666,
'itemid' => 12666, // Item to display on page
'count' => 1,
'description' => "Change character name.",
'description' => "Change character name",
'points' => 20,
),
7 => array(
'type' => 5,
'itemid' => 132, // Outfit ID
'count' => 3, // Addon 0 = none, 1 = first, 2 = second, 3 = both
'description' => "Nobleman with both addons",
'points' => 20,
),
8 => array(
'type' => 5,
'itemid' => 140,
'count' => 3,
'description' => "Noblewoman with both addons",
'points' => 20,
),
9 => array(
'type' => 6,
'itemid' => 32, // Mount ID
'count' => 1,
'description' => "Gnarlhound mount",
'points' => 20,
),
10 => array(
'type' => 6,
'itemid' => 17,
'count' => 1,
'description' => "War horse",
'points' => 20,
),
);
?>
?>

View File

@ -653,4 +653,28 @@ div.aspectratio > iframe {
top: 0; bottom: 0; left: 0; right: 0;
width: 100%;
height: 100%;
}
/* SHOP Category style */
#categoryNavigator {
background-color: #555555;
max-width: 650px;
margin-top: 20px;
}
#categoryNavigator a {
color: white;
font-weight: bold;
padding: 10px 15px;
display: inline-block;
text-decoration: none;
border-right: 1px solid #E5E5DB;
}
#categoryNavigator a:hover {
background-color: #ad7400;
}
table.hide {
display: none;
}

251
shop.php
View File

@ -87,8 +87,215 @@ if ($config['shop_auction']['characterAuction']) {
<p>Interested in buying characters? View the <a href="auctionChar.php">character auction page!</a></p>
<?php
}
$outfitsIds = array(136,137,138,139,140,141,142,147,148,149,150,155,156,157,158,252,269,270,279,288,324,336,366,431,433,464,466,471,513,514,542,128,129,130,131,132,133,134,143,144,145,146,151,152,153,154,251,268,273,278,289,325,335,367,430,432,463,465,472,512,516,541);
$category_items = array();
$category_premium = array();
$category_outfits = array();
$category_mounts = array();
$category_misc = array();
foreach ($shop_list as $key => $offer) {
switch ($offer['type']) {
case 1:
$category_items[$key] = $offer;
break;
case 2:
$category_premium[$key] = $offer;
break;
case 3:
$category_misc[$key] = $offer;
break;
case 4:
$category_misc[$key] = $offer;
break;
case 5:
$category_outfits[$key] = $offer;
break;
case 6:
$category_mounts[$key] = $offer;
break;
default:
$category_misc[$key] = $offer;
break;
}
}
// Render a bunch of tables (one for each category)
?>
<table>
<div id="categoryNavigator">
<a class="nav_link" href="#all">ALL</a>
<a class="nav_link" href="#cat_itemids">ITEMS</a>
<a class="nav_link" href="#cat_premium">PREMIUM</a>
<a class="nav_link" href="#cat_outfits">OUTFITS</a>
<a class="nav_link" href="#cat_mounts">MOUNTS</a>
<a class="nav_link" href="#cat_misc">MISC</a>
</div>
<script type="text/javascript">
function domReady () {
var links = document.getElementsByClassName("nav_link");
for (var i=0; i < links.length; i++) {
links[i].addEventListener('click', function(e){
e.preventDefault();
// Hide all tables
for (var x=0; x < links.length; x++) {
var hash = links[x].hash.substr(1);
if (hash != 'all') {
var table = document.getElementById(hash);
if (table.classList.contains("show")) {
table.classList.remove("show");
table.classList.add("hide");
}
}
}
// Display only the one we selected
var hash = this.hash.substr(1);
if (hash != 'all') {
var target = document.getElementById(hash);
if (target.classList.contains('hide')) {
target.classList.remove("hide");
target.classList.add("show");
}
} else { // We clicked to show all tables
// Show all tables
for (var x=0; x < links.length; x++) {
var hash = links[x].hash.substr(1);
if (hash != 'all') {
var table = document.getElementById(hash);
if (table.classList.contains("hide")) {
table.classList.remove("hide");
table.classList.add("show");
}
}
}
}
});
}
}
// Mozilla, Opera, Webkit
if ( document.addEventListener ) {
document.addEventListener( "DOMContentLoaded", function(){
document.removeEventListener( "DOMContentLoaded", arguments.callee, false);
domReady();
}, false );
// If IE event model is used
} else if ( document.attachEvent ) {
// ensure firing before onload
document.attachEvent("onreadystatechange", function(){
if ( document.readyState === "complete" ) {
document.detachEvent( "onreadystatechange", arguments.callee );
domReady();
}
});
}
</script>
<!-- ITEMIDS -->
<table class="show" id="cat_itemids">
<tr class="yellow">
<td>Item:</td>
<?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
<td>Count:</td>
<td>Points:</td>
<td>Action:</td>
</tr>
<?php foreach ($category_items as $key => $offers): ?>
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['count']; ?>x</td>
<td><?php echo $offers['points']; ?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- PREMIUM DURATION -->
<table class="show" id="cat_premium">
<tr class="yellow">
<td>Description:</td>
<?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
<td>Duration:</td>
<td>Points:</td>
<td>Action:</td>
</tr>
<?php foreach ($category_premium as $key => $offers): ?>
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['count']; ?> Days</td>
<td><?php echo $offers['points']; ?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- OUTFITS -->
<table class="show" id="cat_outfits">
<tr class="yellow">
<td>Description:</td>
<?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
<td>Points:</td>
<td>Action:</td>
</tr>
<?php foreach ($category_outfits as $key => $offers): ?>
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['show_outfits']['shop']):?>
<td><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $offers['itemid']; ?>&addons=<?php echo $offers['count']; ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['points']; ?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- MOUNTS -->
<table class="show" id="cat_mounts">
<tr class="yellow">
<td>Description:</td>
<?php if ($config['show_outfits']['shop']) { ?><td>Image:</td><?php } ?>
<td>Points:</td>
<td>Action:</td>
</tr>
<?php foreach ($category_mounts as $key => $offers): ?>
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitsIds[rand(0,count($outfitsIds)-1)]; ?>&addons=<?php echo rand(1, 3); ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>&mount=<?php echo $offers['itemid']; ?>&direction=2" alt="img"></td>
<?php endif; ?>
<td><?php echo $offers['points']; ?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- MISCELLANEOUS -->
<table class="show" id="cat_misc">
<tr class="yellow">
<td>Description:</td>
<?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
@ -96,27 +303,27 @@ if ($config['shop_auction']['characterAuction']) {
<td>Points:</td>
<td>Action:</td>
</tr>
<?php
foreach ($shop_list as $key => $offers) {
echo '<tr class="special">';
echo '<td>'. $offers['description'] .'</td>';
if ($config['shop']['showImage']) echo '<td><img src="http://'. $config['shop']['imageServer'] .'/'. $offers['itemid'] .'.'. $config['shop']['imageType'] .'" alt="img"></td>';
if ($offers['type'] == 2) echo '<td>'. $offers['count'] .' Days</td>';
else if ($offers['type'] == 3 && $offers['count'] == 0) echo '<td>Unlimited</td>';
else echo '<td>'. $offers['count'] .'x</td>';
echo '<td>'. $offers['points'] .'</td>';
echo '<td>';
?>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
<?php
echo '</td>';
echo '</tr>';
}
?>
<?php foreach ($category_misc as $key => $offers): ?>
<tr class="special">
<td><?php echo $offers['description']; ?></td>
<?php if ($config['shop']['showImage']):?>
<td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
<?php endif;
if ($offers['count'] === 0): ?>
<td>Unlimited</td>
<?php else: ?>
<td><?php echo $offers['count']; ?>x</td>
<?php endif; ?>
<td><?php echo $offers['points']; ?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
<input type="hidden" name="session" value="<?php echo time(); ?>">
<input type="submit" value=" PURCHASE " class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php if ($shop['enableShopConfirmation']) { ?>