-- Config --
local skilltries = 10 -- Number of tries per skill
local t = 2 * 1000 -- Set the time before try is added to skills
local lock = 10 * 1000 -- Time to wait before start again
-------------------------------------------------------------------------
function onStepIn(cid, item, pos, fromPos)
local p = {cid = cid, item = item, pos = pos}
if getPlayerStorageValue(p.cid, 18010) == 2 then
doTeleportThing(p.cid, fromPos, TRUE)
doPlayerSendTextMessage(p.cid,22,"You must wait 10 seconds before you start again")
return false
end
setPlayerStorageValue(p.cid, 18010, 1)
if isPlayer(p.cid) and getPlayerStorageValue(p.cid, 18010) == 1 then
if p.item.actionid == 900 then
doPlayerSendTextMessage(p.cid,22,"Your training session will now begin")
addEvent(trainMe, t, p)
end
end
return true
end
function onStepOut(cid, item)
if getPlayerStorageValue(cid, 18010) == 2 then
return false
end
setPlayerStorageValue(cid, 18010, 2)
addEvent(trainLock, lock, cid)
doPlayerSendTextMessage(cid,22,"Your training session has now ended")
return true
end
function trainLock (cid)
if isPlayer(cid) then
setPlayerStorageValue(cid, 18010, 0)
end
end
function trainMe(p)
if isPlayer(p.cid) and getPlayerStorageValue(p.cid, 18010) == 1 then
if p.item.actionid == 900 then
manaspent = getPlayerMana(p.cid) -- Total player mana
doPlayerAddSkillTry(p.cid, SKILL_FIST, skilltries)
doPlayerAddSkillTry(p.cid, SKILL_SWORD, skilltries)
doPlayerAddSkillTry(p.cid, SKILL_CLUB, skilltries)
doPlayerAddSkillTry(p.cid, SKILL_AXE, skilltries)
doPlayerAddSkillTry(p.cid, SKILL_DISTANCE, skilltries)
doPlayerAddSkillTry(p.cid, SKILL_SHIELD, skilltries)
doPlayerAddSpentMana(p.cid, manaspent)
doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)
doSendMagicEffect(getPlayerPosition(p.cid),34)
end
addEvent(trainMe, t, p)
end
return true
end