ausirosiris
Member
- Joined
- May 23, 2020
- Messages
- 105
- Reaction score
- 22
need a very basic and simple script for a ground tile that adds SKILL__MAGLEVEL tries each 2 seconds while you on it.
Describe your problem in the title. A title that doesn’t describe the content of the thread is seen as an invalid title.
Ok, thanks. I'm sorry. I don't know how to post...I quickly edited your title; please choose a better title next time instead of just writing your TFS version.
Just setup an actionId on the tileneed a very basic and simple script for a ground tile that adds SKILL__MAGLEVEL tries each 2 seconds while you on it.
local manaSpentAmount = 100
local trainingCreatures = {}
local function giveMagicTrainingOverTime(cid, lastKnownTraining)
if not isPlayer(cid) then
trainingCreatures[cid] = nil
return
end
if not trainingCreatures[cid] or trainingCreatures[cid] != lastKnownTraining then
return
end
trainingCreatures[cid] = trainingCreatures[cid] + 1
if trainingCreatures[cid] % 20 == 0 then
doPlayerAddSpentMana(cid, manaSpentAmount)
end
addEvent(giveMagicTrainingOverTime, 100, cid, lastKnownTraining + 1)
end
function onStepIn(cid, item, frompos, itemEx, topos)
if not isPlayer(cid) then
return true
end
trainingCreatures[cid] = 0
giveMagicTrainingOverTime(cid, 0)
return true
end
function onStepOut(cid, item, frompos, itemEx, topos)
if not isPlayer(cid) then
return true
end
trainingCreatures[cid] = nil
return true
end
Changed.That's a risky memory leak, would be better to set tonil
instead-1
orguid
as index