mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 10:49:23 +02:00
Fix #369 - Outfit offer type (5) supports 2 outfit ids.
This commit is contained in:
parent
be8b882166
commit
b65c860b66
@ -35,24 +35,37 @@ function onSay(cid, words, param)
|
||||
-- Get wheight
|
||||
local playerCap = getPlayerFreeCap(cid)
|
||||
local itemweight = getItemWeight(q_itemid, q_count)
|
||||
if playerCap >= itemweight then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
doPlayerAddItem(cid, q_itemid, q_count)
|
||||
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!")
|
||||
else
|
||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
|
||||
end
|
||||
if playerCap >= itemweight then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
doPlayerAddItem(cid, q_itemid, q_count)
|
||||
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!")
|
||||
else
|
||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
|
||||
end
|
||||
end
|
||||
-- ORDER TYPE 5 (Outfit and addon)
|
||||
if q_type == 5 then
|
||||
served = true
|
||||
-- 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!")
|
||||
|
||||
local itemid = q_itemid
|
||||
local outfits = {}
|
||||
|
||||
if itemid > 1000 then
|
||||
local first = math.floor(itemid/1000)
|
||||
table.insert(outfits, first)
|
||||
itemid = itemid - (first * 1000)
|
||||
end
|
||||
table.insert(outfits, itemid)
|
||||
|
||||
for _, outfitId in pairs(outfits) do
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not canPlayerWearOutfit(cid, outfitId, q_count) then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
doPlayerAddOutfit(cid,outfitId,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
|
||||
end
|
||||
|
||||
|
@ -48,14 +48,27 @@ function onSay(cid, words, param)
|
||||
-- ORDER TYPE 5 (Outfit and addon)
|
||||
if q_type == 5 then
|
||||
served = true
|
||||
-- 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!")
|
||||
|
||||
local itemid = q_itemid
|
||||
local outfits = {}
|
||||
|
||||
if itemid > 1000 then
|
||||
local first = math.floor(itemid/1000)
|
||||
table.insert(outfits, first)
|
||||
itemid = itemid - (first * 1000)
|
||||
end
|
||||
table.insert(outfits, itemid)
|
||||
|
||||
for _, outfitId in pairs(outfits) do
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not canPlayerWearOutfit(cid, outfitId, q_count) then
|
||||
local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
result.free(delete)
|
||||
doPlayerAddOutfit(cid,outfitId,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
|
||||
end
|
||||
|
||||
|
@ -58,13 +58,26 @@ function onSay(cid, words, param)
|
||||
-- ORDER TYPE 5 (Outfit and addon)
|
||||
if q_type == 5 then
|
||||
served = true
|
||||
-- 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!")
|
||||
|
||||
local itemid = q_itemid
|
||||
local outfits = {}
|
||||
|
||||
if itemid > 1000 then
|
||||
local first = math.floor(itemid/1000)
|
||||
table.insert(outfits, first)
|
||||
itemid = itemid - (first * 1000)
|
||||
end
|
||||
table.insert(outfits, itemid)
|
||||
|
||||
for _, outfitId in pairs(outfits) do
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not canPlayerWearOutfit(cid, outfitId, q_count) then
|
||||
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
doPlayerAddOutfit(cid,outfitId,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
|
||||
end
|
||||
|
||||
|
@ -65,16 +65,29 @@ function onThink(interval, lastExecution)
|
||||
-- ORDER TYPE 5 (Outfit and addon)
|
||||
if orderType == 5 then
|
||||
served = true
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not player:hasOutfit(orderItemId, orderCount) then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||
player:addOutfit(orderItemId)
|
||||
player:addOutfitAddon(orderItemId, orderCount)
|
||||
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
|
||||
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..orderItemId.."] with addon: ["..orderCount.."]")
|
||||
else -- Already has outfit
|
||||
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
|
||||
print("Process canceled. [".. player:getName() .."] already have outfit: ["..orderItemId.."] with addon: ["..orderCount.."].")
|
||||
|
||||
local itemid = orderItemId
|
||||
local outfits = {}
|
||||
|
||||
if itemid > 1000 then
|
||||
local first = math.floor(itemid/1000)
|
||||
table.insert(outfits, first)
|
||||
itemid = itemid - (first * 1000)
|
||||
end
|
||||
table.insert(outfits, itemid)
|
||||
|
||||
for _, outfitId in pairs(outfits) do
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not player:hasOutfit(outfitId, orderCount) then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||
player:addOutfit(outfitId)
|
||||
player:addOutfitAddon(outfitId, orderCount)
|
||||
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
|
||||
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..outfitId.."] with addon: ["..orderCount.."]")
|
||||
else -- Already has outfit
|
||||
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
|
||||
print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,14 +47,27 @@ function onSay(player, words, param)
|
||||
-- ORDER TYPE 5 (Outfit and addon)
|
||||
if q_type == 5 then
|
||||
served = true
|
||||
-- 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!")
|
||||
|
||||
local itemid = q_itemid
|
||||
local outfits = {}
|
||||
|
||||
if itemid > 1000 then
|
||||
local first = math.floor(itemid/1000)
|
||||
table.insert(outfits, first)
|
||||
itemid = itemid - (first * 1000)
|
||||
end
|
||||
table.insert(outfits, itemid)
|
||||
|
||||
for _, outfitId in pairs(outfits) do
|
||||
-- Make sure player don't already have this outfit and addon
|
||||
if not player:hasOutfit(outfitId, q_count) then
|
||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
|
||||
player:addOutfit(outfitId)
|
||||
player:addOutfitAddon(outfitId, 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
|
||||
end
|
||||
|
||||
|
13
config.php
13
config.php
@ -999,26 +999,19 @@
|
||||
),
|
||||
7 => array(
|
||||
'type' => 5,
|
||||
'itemid' => 132, // Outfit ID
|
||||
'itemid' => [132, 140], // Outfit ID
|
||||
'count' => 3, // Addon 0 = none, 1 = first, 2 = second, 3 = both
|
||||
'description' => "Nobleman with both addons",
|
||||
'description' => "Noble outfit 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(
|
||||
9 => array(
|
||||
'type' => 6,
|
||||
'itemid' => 17,
|
||||
'count' => 1,
|
||||
|
23
shop.php
23
shop.php
@ -44,6 +44,14 @@ if ($loggedin === true) {
|
||||
$verify = $data['points'];
|
||||
if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));
|
||||
|
||||
// If this is an outfit offer, convert array into an integer.
|
||||
if ($buy['type'] == 5) {
|
||||
if (is_array($buy['itemid'])) {
|
||||
if (COUNT($buy['itemid']) == 2) $buy['itemid'] = ($buy['itemid'][0] * 1000) + $buy['itemid'][1];
|
||||
else $buy['itemid'] = $buy['itemid'][0];
|
||||
}
|
||||
}
|
||||
|
||||
// Do the magic (insert into db, or change sex etc)
|
||||
// If type is 2 or 3
|
||||
if ($buy['type'] == 2) {
|
||||
@ -269,11 +277,22 @@ foreach ($shop_list as $key => $offer) {
|
||||
<td>Points:</td>
|
||||
<?php if ($loggedin === true): ?><td>Action:</td><?php endif; ?>
|
||||
</tr>
|
||||
<?php foreach ($category_outfits as $key => $offers): ?>
|
||||
<?php foreach ($category_outfits as $key => $offers):
|
||||
if (!is_array($offers['itemid'])) $offers['itemid'] = [$offers['itemid']];
|
||||
if (COUNT($offers['itemid']) > 2): ?>
|
||||
<tr class="special">
|
||||
<td colspan="2">
|
||||
<p><strong>Error:</strong> Outfit offer don't support more than 2 outfits. <?php echo COUNT($offers['itemid']); ?> configured.
|
||||
<br>[<?php echo implode(',', $offers['itemid']); ?>]</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
<td><?php foreach($offers['itemid'] as $outfitId): ?>
|
||||
<img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitId; ?>&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">
|
||||
<?php endforeach; ?></td>
|
||||
<?php endif; ?>
|
||||
<td><?php echo $offers['points']; ?></td>
|
||||
<?php if ($loggedin === true): ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user