heitorzinhotc
Viva la Vida!
- Joined
- Aug 8, 2008
- Messages
- 109
- Reaction score
- 8
I am using script below in the movements, in the tile from the coaches.
But when the player leaves the tile, he continues to receive stamina.
Can you help me? I would like you to stop raising the stamina when the player leaves the tile.
TFS 1.3, version 12.
But when the player leaves the tile, he continues to receive stamina.
Can you help me? I would like you to stop raising the stamina when the player leaves the tile.
TFS 1.3, version 12.
Lua:
eventsId = {}
local function rechargeStamina(cid)
local player = Player(cid)
if not player then
eventsId[cid] = nil
return
end
player:setStamina(player:getStamina() + 1)
eventsId[cid] = addEvent(rechargeStamina, 180000, cid)
end
function onStepIn(creature, item, position, fromPosition)
if creature:isPlayer() then
local cid = creature:getId()
eventsId[cid] = addEvent(rechargeStamina, 180000, cid)
end
return true
end
function onStepOut(creature, item, pos, fromPosition)
if creature:isPlayer() then
local cid = creature:getId()
stopEvent(eventsId[cid])
eventsId[cid] = nil
end
return true
end