Lava Titan
Developer
hey there, I created this few months ago and now that I was reviewing it I had the idea to add amount of items given instead of give just 1
i wanted to give for example 100 cc instead of just 1 but the way I created it only allows to give 1
how can I make it work with like
this is the script atm:
P.S: Sorry for the script being so big, I'm still trying to figure out a way to create outside functions to make it simple
i wanted to give for example 100 cc instead of just 1 but the way I created it only allows to give 1
how can I make it work with like
Code:
local veryLucky = {{2160, 50}, {2160, 100}}
this is the script atm:
Code:
local unlucky = {2148, 2152}
local lucky = {2152, 2160}
local veryLucky = {2160, 2152}
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
if not player:isPlayer() then
return true
end
if player:getExhaustion(1000) <= 0 then
player:setExhaustion(1000, 2)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You're exhausted for: "..player:getExhaustion(1000).." seconds.")
end
if player:isPzLocked() then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You can't use this item while in combat.")
return true
end
if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You can't use this item while in combat.")
return true
end
if player:getItemCount(item:getId()) <= 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Pickup this item before use it.")
return true
end
if item:getActionId() == 2222 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "This item does not belong to you.")
return true
end
local capacity = player:getCapacity()
local chance = math.random(1,100)
local broadcast = "Congratulations to "..player:getName().." for winning a "..ItemType(rewards3):getName().."."
-- storages
local unlucky_storage = STORAGE_UNLUCKY
local lucky_storage = STORAGE_LUCKY
local veryLucky_storage = STORAGE_VERY_LUCKY
local storage = STORAGE_MAGIC_BOX_COUNTER
local global_storage = GLOBALSTORAGE_MAGIC_BOX_COUNTER
-- rewards
local rewards3 = veryLucky[math.random(1, #veryLucky)]
local rewards2 = lucky[math.random(1, #lucky)]
local rewards1 = unlucky[math.random(1, #unlucky)]
-- Lottery
if chance == 100 and capacity > 200 then
-- texts
player:say(""..player:getName().." rolled a "..chance..".", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations you won "..ItemType(rewards3):getArticle().." "..ItemType(rewards3):getName().."!!!")
Game.broadcastMessage(broadcast, MESSAGE_STATUS_WARNING)
print(""..player:getName().." rolled "..chance.." and won "..ItemType(rewards3):getArticle().." "..ItemType(rewards3):getName()..".")
--logs
logItemUsage(player:getId(), item:getId(), 'data/logs/items/magic_box.log') -- TODO
-- storages
player:setStorageValue(veryLucky_storage, (player:getStorageValue(veryLucky_storage) or 0) + 1)
player:setStorageValue(storage, (player:getStorageValue(storage) or 0) + 1)
Game.setStorageValue(global_storage, (Game.getStorageValue(global_storage) or 0) + 1)
--actions
player:addItem(rewards3, 1)
player:getPosition():sendMagicEffect(74)
item:remove(1)
elseif chance > 50 and chance < 100 and capacity > 200 then
-- texts
player:say(""..player:getName().." rolled a "..chance..".", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_INFO_DESCR, ""..player:getName().." you won "..ItemType(rewards2):getArticle().." "..ItemType(rewards2):getName().."!")
--logs
logItemUsage(player:getId(), item:getId(), 'data/logs/items/magic_box.log') -- TODO
-- storages
player:setStorageValue(lucky_storage, (player:getStorageValue(lucky_storage) or 0) + 1)
player:setStorageValue(storage, (player:getStorageValue(storage) or 0) + 1)
Game.setStorageValue(global_storage, (Game.getStorageValue(global_storage) or 0) + 1)
--actions
player:addItem(rewards2, 1)
player:getPosition():sendMagicEffect(75)
item:remove(1)
elseif chance >= 0 and chance < 50 and capacity > 200 then
-- texts
player:say(""..player:getName().." rolled a "..chance..".", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Sorry "..player:getName()..", better luck next time!\nYou won "..ItemType(rewards1):getArticle().." "..ItemType(rewards1):getName().."...")
--logs
logItemUsage(player:getId(), item:getId(), 'data/logs/items/magic_box.log') -- TODO
-- storages
player:setStorageValue(veryLucky_storage, (player:getStorageValue(unlucky_storage) or 0) + 1)
player:setStorageValue(storage, (player:getStorageValue(storage) or 0) + 1)
Game.setStorageValue(global_storage, (Game.getStorageValue(global_storage) or 0) + 1)
--actions
player:addItem(rewards1, 1)
player:getPosition():sendMagicEffect(69)
item:remove(1)
else
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You failed opening the box, try again.")
print(""..player:getName().." had problem with "..item:getName()..".")
end
return true
end
P.S: Sorry for the script being so big, I'm still trying to figure out a way to create outside functions to make it simple