add shop event

This commit is contained in:
Amberstone 2024-10-23 13:53:31 +09:00
parent da6ee6a29a
commit 6a248db26c
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
3 changed files with 34 additions and 3 deletions

View file

@ -3,8 +3,11 @@
* @var string|int $sh_id * @var string|int $sh_id
*/ */
include_once "./_common.php"; include_once "./_common.php";
$item = sql_fetch("SELECT * FROM {$g5['shop_table']} shop, {$g5['item_table']} item WHERE shop.it_id = item.it_id AND shop.sh_id = '{$sh_id}'");
$item = sql_fetch("select * from {$g5['shop_table']} shop, {$g5['item_table']} item where shop.it_id = item.it_id and shop.sh_id = '{$sh_id}'"); if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax.before", $sh_id);
}
if ($item['sh_id']) { if ($item['sh_id']) {
@ -32,6 +35,10 @@ if ($item['sh_id']) {
} }
} }
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax.before", $item);
}
if (defined('G5_THEME_PATH') && is_file(G5_THEME_PATH . "/shop/shop.item.skin.php")) { if (defined('G5_THEME_PATH') && is_file(G5_THEME_PATH . "/shop/shop.item.skin.php")) {
include G5_THEME_PATH . "/shop/shop.item.skin.php"; include G5_THEME_PATH . "/shop/shop.item.skin.php";
} else { } else {

View file

@ -4,9 +4,13 @@
*/ */
include_once "./_common.php"; include_once "./_common.php";
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax_update.before");
}
if ($character['ch_id'] && $character['ch_state'] == '승인') { if ($character['ch_id'] && $character['ch_state'] == '승인') {
$msg = ""; $msg = "";
$item = sql_fetch("select * from {$g5['shop_table']} shop, {$g5['item_table']} item where shop.it_id = item.it_id and shop.sh_id = '{$sh_id}'"); $item = sql_fetch("SELECT * FROM {$g5['shop_table']} shop, {$g5['item_table']} item WHERE shop.it_id = item.it_id AND shop.sh_id = '{$sh_id}'");
if ($item['sh_id']) { if ($item['sh_id']) {
// 구매 가능한 아이템인지 체크한다. // 구매 가능한 아이템인지 체크한다.
@ -57,7 +61,7 @@ if ($character['ch_id'] && $character['ch_state'] == '승인') {
if ($in['cnt'] < $item['sh_has_item_count']) { if ($in['cnt'] < $item['sh_has_item_count']) {
// 필요 아이템 미소유 // 필요 아이템 미소유
$has_item_name = get_item_name($item['sh_has_item']); $has_item_name = Item::getName($item['sh_has_item']);
$msg .= $has_item_name . j($has_item_name, '이') . " " . $item['sh_has_item_count'] . "개 있어야 살 수 있습니다.<br />"; $msg .= $has_item_name . j($has_item_name, '이') . " " . $item['sh_has_item_count'] . "개 있어야 살 수 있습니다.<br />";
$is_able_buy = false; $is_able_buy = false;
} else if ($item['sh_use_has_item']) { } else if ($item['sh_use_has_item']) {
@ -121,6 +125,11 @@ if ($character['ch_id'] && $character['ch_state'] == '승인') {
} }
if ($is_able_buy) { if ($is_able_buy) {
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax_update.buyitem_before");
}
Item::giveItem($character['ch_id'], $item['it_id'], $item, 1, "구매", true); Item::giveItem($character['ch_id'], $item['it_id'], $item, 1, "구매", true);
if ($use_point) { if ($use_point) {
@ -151,6 +160,10 @@ if ($character['ch_id'] && $character['ch_state'] == '승인') {
sql_query("delete from {$g5['title_has_table']} where hi_id = '{$use_has_title}'"); sql_query("delete from {$g5['title_has_table']} where hi_id = '{$use_has_title}'");
} }
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax_update.buyitem_after", $use_point, $use_exp_point, $use_inventory_item, $use_inventory_item_count);
}
$msg = "" . $item['it_name'] . " 》 구매 되었습니다."; $msg = "" . $item['it_name'] . " 》 구매 되었습니다.";
} }
} }
@ -163,3 +176,7 @@ if (defined('G5_THEME_PATH') && is_file(G5_THEME_PATH . "/shop/shop.result.skin.
} else { } else {
include G5_PATH . "/shop/skin/shop.result.skin.php"; include G5_PATH . "/shop/skin/shop.result.skin.php";
} }
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop_ajax_update.after");
}

View file

@ -3,6 +3,10 @@ include_once './_common.php';
$g5['title'] = "상점"; $g5['title'] = "상점";
include_once './_head.php'; include_once './_head.php';
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop.before");
}
$shop_cate = explode("||", $config['cf_shop_category']); $shop_cate = explode("||", $config['cf_shop_category']);
if (isset($shop_cate)) { if (isset($shop_cate)) {
@ -148,3 +152,6 @@ function ajax_shop_link_url(url, obj_id) {
<?php <?php
include_once './_tail.php'; include_once './_tail.php';
if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
EventHandler::triggerEvent("amber.shop.after");
}