E
Evil Puncker
Guest
I found an old script here in otland for large seashell and wanted to update it in order to PR into tfs, help with optimization, logic and with chances (yeah i'm kinda dumb)
- item can only be opened each 20 hours
- the text is displayed on the item position not on player position
- the pearl is created on player position
- both open and closed seashells should display the "You have already opened a shell today." after opened
- chances should be: (48% pearl)(16% finger squeezed)(36% nothing)
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local timenow = os.time()
local nextday = timenow + 72000
local CHANCES = math.random(100)
if item.itemid == 7552 then
if player:getStorageValue(75520) < timenow then
if CHANCES <= 20 then
Game.createItem(math.random(7632,7633), 1, player:getPosition())
toPosition:say("You found a beautiful pearl",TALKTYPE_MONSTER_SAY)
elseif (CHANCES <= 60 and CHANCES > 20) then
player:addHealth(-200)
toPosition:say("Ouch! You squeezed your fingers",TALKTYPE_MONSTER_SAY)
else
toPosition:say("Nothing is inside",TALKTYPE_MONSTER_SAY)
end
player:setStorageValue(75520, nextday)
item:transform(item.itemid+1)
item:decay()
else
toPosition:say("You have already opened a shell today.",TALKTYPE_MONSTER_SAY)
end
elseif item.itemid == 7553 then
toPosition:say("You have already opened a shell today.",TALKTYPE_MONSTER_SAY)
end
return true
end