Skip to content

Commit

Permalink
* Usefull things
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Feb 8, 2025
1 parent f1b0de8 commit 9c25d87
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
31 changes: 31 additions & 0 deletions data/scripts/talkactions/player/buy_backpack.lua
Original file line number Diff line number Diff line change
@@ -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()
21 changes: 21 additions & 0 deletions data/scripts/talkactions/player/food.lua
Original file line number Diff line number Diff line change
@@ -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()
30 changes: 30 additions & 0 deletions data/scripts/talkactions/player/frags.lua
Original file line number Diff line number Diff line change
@@ -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()
26 changes: 26 additions & 0 deletions data/scripts/talkactions/player/promotion.lua
Original file line number Diff line number Diff line change
@@ -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()
17 changes: 17 additions & 0 deletions data/scripts/talkactions/player/shared.lua
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 9c25d87

Please sign in to comment.