diff --git a/data/scripts/talkactions/player/buy_backpack.lua b/data/scripts/talkactions/player/buy_backpack.lua new file mode 100644 index 00000000..3b61dfdc --- /dev/null +++ b/data/scripts/talkactions/player/buy_backpack.lua @@ -0,0 +1,31 @@ +local backpack = TalkAction("!bp") + +local itemConfig = { + price = 20, + itemId = 2854 +} + +function backpack.onSay(player, words, param) + local exhaustGroup = "talkactions" + local exhaustTime = 2 + + if player:getExhaustion(exhaustGroup) > 0 then + player:sendCancelMessage("You are exhausted. Please wait before using this command again.") + return true + end + + if player:removeMoneyBank(itemConfig.price) then + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + player:addItem(itemConfig.itemId, 1) + player:sendTextMessage(MESSAGE_LOOK, "You have bought a backpack!") + player:setExhaustion(exhaustGroup, exhaustTime) + else + player:getPosition():sendMagicEffect(CONST_ME_POFF) + player:sendCancelMessage("You do not have enough money.") + end + + return true +end + +backpack:groupType("normal") +backpack:register() diff --git a/data/scripts/talkactions/player/food.lua b/data/scripts/talkactions/player/food.lua new file mode 100644 index 00000000..b90c1793 --- /dev/null +++ b/data/scripts/talkactions/player/food.lua @@ -0,0 +1,21 @@ +local food = TalkAction("!food") + +local config = { + price = 1000, + itemId = 3731, + quantity = 100 +} + +function food.onSay(player, words, param) + if player:removeMoneyBank(config.price) then + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + player:addItem(config.itemId, config.quantity) + player:sendTextMessage(MESSAGE_LOOK, string.format("You bought %d food for %d gold!", config.quantity, config.price)) + else + player:getPosition():sendMagicEffect(CONST_ME_POFF) + player:sendCancelMessage(string.format("You need at least %d gold coins.", config.price)) + end +end + +food:groupType("normal") +food:register() diff --git a/data/scripts/talkactions/player/frags.lua b/data/scripts/talkactions/player/frags.lua new file mode 100644 index 00000000..4241bb37 --- /dev/null +++ b/data/scripts/talkactions/player/frags.lua @@ -0,0 +1,30 @@ +local frags = TalkAction("!frags") + +function frags.onSay(player, words, param) + local fragTime = configManager.getNumber(configKeys.FRAG_TIME) + local skullTime = player:getSkullTime() + local fragsList = player:getKills() + local totalFrags = 0 + + for fragIndex, fragTable in pairs(fragsList) do + for subKey, subValue in pairs(fragTable) do + if subKey == 1 then + local resultName = + db.storeQuery("SELECT `name` FROM `players` WHERE `id` = " .. db.escapeString(subValue)) + local name = Result.getString(resultName, "name") + totalFrags = totalFrags + 1 + elseif subKey == 2 then + local formattedDate = os.date("%d %b %Y, %H:%M:%S", subValue) + elseif subKey == 3 then + else + end + end + end + + player:sendTextMessage(MESSAGE_LOOK, "You have " .. totalFrags .. " unjustified kills.") + return false +end + +frags:separator(" ") +frags:groupType("normal") +frags:register() diff --git a/data/scripts/talkactions/player/promotion.lua b/data/scripts/talkactions/player/promotion.lua new file mode 100644 index 00000000..b925c5cf --- /dev/null +++ b/data/scripts/talkactions/player/promotion.lua @@ -0,0 +1,26 @@ +local promotion = TalkAction("!promotion") + +local config = { + requiredLevel = 20, + cost = 20000 +} + +function promotion.onSay(player, words, param) + local promotion = player:getVocation():getPromotion() + if player:isPromoted() then + player:sendCancelMessage("You are already promoted!") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + elseif player:getLevel() < config.requiredLevel then + player:sendCancelMessage("Sorry, you need level " .. config.requiredLevel .. " to be promoted.") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + elseif not player:removeMoneyBank(config.cost) then + player:sendCancelMessage(string.format("You need at least %d gold coins to have a promotion.", config.price)) + player:getPosition():sendMagicEffect(CONST_ME_POFF) + else + player:sendTextMessage(MESSAGE_LOOK, "You received a promotion!") + player:setVocation(promotion) + player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE) + end +end +promotion:groupType("normal") +promotion:register() diff --git a/data/scripts/talkactions/player/shared.lua b/data/scripts/talkactions/player/shared.lua new file mode 100644 index 00000000..6784f784 --- /dev/null +++ b/data/scripts/talkactions/player/shared.lua @@ -0,0 +1,17 @@ +local shared = TalkAction("!shared") + +function shared.onSay(player, words, param) + if player then + local text = '-- Party Info -- \n\n' + text = text .. '-----------\n' + text = text .. 'Min Level: ' .. math.ceil((player:getLevel() * 2) / 3) .. ' \n' + text = text .. 'Max Level: ' .. math.ceil((player:getLevel() * player:getLevel()) / ((player:getLevel() * 2) / 3)) .. ' \n' + text = text .. '-----------\n' + player:showTextDialog(34266, text) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + end + return false +end + +shared:groupType("normal") +shared:register()