For servers that have single blessings available, it should calculate what blessings are first missing, then have a price per blessing@Xedoxo
Make sure to use his script its cleaner and better
Just in case if you ever make it possible to get one bless only, his script will avoid problems later
local config = {
pricePerBlessing = 1000,
maxBlessings = 5
}
function onUse(player, item, fromPos, target, toPos, isHotkey)
local inactive = {}
for i = 1, config.maxBlessings do
if not player:hasBlessing(i) then
table.insert(inactive, i)
end
end
if next(inactive) == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You already...
local money = 1000
local blessings = {1, 2, 3, 4, 5}
function onUse(player, item, fromPos, target, toPos, isHotkey)
if not player then
return true
end
for i = 1, #blessings do
if player:hasBlessing(blessings[i]) then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You alredy got all blessings')
return true
end
end
if player:removeMoney(money) then
for i = 1, #blessings do
player:addBlessing(blessings[i])
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You received all blessings')
end
end
return true
end
If the player only has blessing 1, but not 2, 3, 4 and 5 it will still say they have all blessings...LUA:local money = 1000 local blessings = {1, 2, 3, 4, 5} function onUse(player, item, fromPos, target, toPos, isHotkey) if not player then return true end for i = 1, #blessings do if player:hasBlessing(blessings[i]) then player:sendTextMessage(MESSAGE_INFO_DESCR, 'You alredy got all blessings') return true end end if player:removeMoney(money) then for i = 1, #blessings do player:addBlessing(blessings[i]) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You received all blessings') end end return true end
Try this, not tested
If the player only has blessing 1, but not 2, 3, 4 and 5 it will still say they have all blessings...
If the player only has blessing 1, but not 2, 3, 4 and 5 it will still say they have all blessings...
In that case, use this:There no will be any other option to buy bless, so nobody will have 1 bless or something. Just 0 or all.
Going to test it and i'll back here with info.
local config = {
price = 1000,
maxBlessings = 5
}
function onUse(player, item, fromPos, target, toPos, isHotkey)
if player:hasBlessing(1) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have all blessings")
return true
end
if not player:removeMoney(config.price) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have enough money")
return true
end
for i = 1, config.maxBlessings do
if not player:hasBlessing(i) then
player:addBlessing(i)
end
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You received all blessings")
return true
end
For servers that have single blessings available, it should calculate what blessings are first missing, then have a price per blessing@Xedoxo
Make sure to use his script its cleaner and better
Just in case if you ever make it possible to get one bless only, his script will avoid problems later
local config = {
pricePerBlessing = 1000,
maxBlessings = 5
}
function onUse(player, item, fromPos, target, toPos, isHotkey)
local inactive = {}
for i = 1, config.maxBlessings do
if not player:hasBlessing(i) then
table.insert(inactive, i)
end
end
if next(inactive) == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have all blessings")
return true
end
if not player:removeMoney(config.pricePerBlessing * #inactive) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have enough money")
return true
end
for _, blessingId in ipairs(inactive) do
player:addBlessing(blessingId)
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You received all blessings")
return true
end