Lava Titan
Developer
Hey there, I created this script to give an item each 10 seconds the issue is that it's giving the item everytime you step on the tile, so you can just spam out and in to abuse, can some1 explain how can I fix it please?
Thanks <3
Thanks <3
Code:
local function giveFreeItems(playerId, amount) -- giveFreeItems(player:getId(), 1)
local player = Player(playerId)
if not player then
return
end
if player:getStorageValue(616161) == nil then
return
end
if player:getStorageValue(616161) == 0 then
return
end
if player:getStorageValue(616161) == 1 then
player:addItem(2152, 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, " You received a platinum coin. ")
addEvent(giveFreeItems, 10000, playerId)
end
return true
end
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil or player:isInGhostMode() then
return true
end
player:setStorageValue(616161, 1)
giveFreeItems(player:getId(), 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, "INSIDE")
return true
end
function onStepOut(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil or player:isInGhostMode() then
return true
end
player:setStorageValue(616161, 0)
giveFreeItems(player:getId(), 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, "OUTSIDE")
return true
end