From 695cb58b04618d275982d502ca25cc879df3fead Mon Sep 17 00:00:00 2001 From: Znote Date: Mon, 30 Jan 2017 06:48:46 +0100 Subject: [PATCH] Added shop categories, mounts and outfits. Display outfits currently only work in shop. --- .../talkaction shopsystem/znoteshop.lua | 27 +- .../Alternatives/znoteshop.lua | 38 ++- .../talkaction shopsystem/znoteshop.lua | 36 ++- .../talkaction shopsystem/znoteshop.lua | 38 ++- config.php | 87 ++++-- layout/css/style.css | 24 ++ shop.php | 251 ++++++++++++++++-- 7 files changed, 440 insertions(+), 61 deletions(-) diff --git a/LUA/TFS_02/talkaction shopsystem/znoteshop.lua b/LUA/TFS_02/talkaction shopsystem/znoteshop.lua index 3841348..99838f3 100644 --- a/LUA/TFS_02/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_02/talkaction shopsystem/znoteshop.lua @@ -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.") diff --git a/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua b/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua index f6d3c70..8ccf492 100644 --- a/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua +++ b/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua @@ -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.") diff --git a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua index 40a7587..480a91c 100644 --- a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua @@ -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.") diff --git a/LUA/TFS_10/talkaction shopsystem/znoteshop.lua b/LUA/TFS_10/talkaction shopsystem/znoteshop.lua index 32b24d3..b3b88bd 100644 --- a/LUA/TFS_10/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_10/talkaction shopsystem/znoteshop.lua @@ -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.") diff --git a/config.php b/config.php index a42cb16..d380918 100644 --- a/config.php +++ b/config.php @@ -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, ), ); -?> +?> \ No newline at end of file diff --git a/layout/css/style.css b/layout/css/style.css index bc8bcac..e29f6ec 100644 --- a/layout/css/style.css +++ b/layout/css/style.css @@ -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; } \ No newline at end of file diff --git a/shop.php b/shop.php index 6b0f8f7..34cea90 100644 --- a/shop.php +++ b/shop.php @@ -87,8 +87,215 @@ if ($config['shop_auction']['characterAuction']) {

Interested in buying characters? View the character auction page!

$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) ?> - +
+ ALL + ITEMS + PREMIUM + OUTFITS + MOUNTS + MISC +
+ + + +
+ + + + + + + + $offers): ?> + + + + + + + + + + +
Item:Image:Count:Points:Action:
imgx +
+ + + +
+
+ + + + + + + + + + $offers): ?> + + + + + + + + + + +
Description:Image:Duration:Points:Action:
img Days +
+ + + +
+
+ + + + + + + + + $offers): ?> + + + + + + + + + +
Description:Image:Points:Action:
img +
+ + + +
+
+ + + + + + + + + $offers): ?> + + + + + + + + + +
Description:Image:Points:Action:
img +
+ + + +
+
+ + @@ -96,27 +303,27 @@ if ($config['shop_auction']['characterAuction']) { - $offers) { - echo ''; - echo ''; - if ($config['shop']['showImage']) echo ''; - if ($offers['type'] == 2) echo ''; - else if ($offers['type'] == 3 && $offers['count'] == 0) echo ''; - else echo ''; - echo ''; - echo ''; - } - ?> + $offers): ?> + + + + + + + + + + + + +
Description: Image:Points: Action:
'. $offers['description'] .'img'. $offers['count'] .' DaysUnlimited'. $offers['count'] .'x'. $offers['points'] .''; - ?> -
- - - -
- '; - echo '
imgUnlimitedx +
+ + + +
+