--[[
Square Skill Trainer made by Arthur aka artofwork
This script will train all of a players skills indefintely
It has a small configuration setup where you can set the number of tries per skill
The time interval in between each skill try added
A storage value to help prevent abuse
You can assign any tile you wish to this script that a player can walk on with action id 900
Added a time check based on how much soul they have left
Example:
19:32 Luceria, you have enough soul points to train for 1 hour and 10 minutes
19:32 Your training session will begin in 30 seconds
19:32 Your training session will begin in 20 seconds
19:33 Your training session will begin in 10 seconds
19:33 Your training session will now begin
]]--
-- Config --
local soul = 1 -- the amount of soul to take
local storage = 18010-- Storage value for the player when he steps on and off the tile
local amount = 0 -- the minimum soul they need to use trainers
local skilltries = 1 -- Number of tries per skill
local t = 4000 -- Set the time before try is added to skills (4 seconds)
-- temple x, y, z coordinates set in config.lua --
local mposx = getConfigInfo('newPlayerSpawnPosX')
local mposy = getConfigInfo('newPlayerSpawnPosY')
local mposz = getConfigInfo('newPlayerSpawnPosZ')
local ACCESS_TO_USE = 0
local TEMPLE_POS = {x = mposx, y = mposy, z = mposz}
-------------------------------------------------------------------------
function timeCheck(p)
local hour = math.floor(getPlayerSoul(p.cid) / 60)
local minutes = getPlayerSoul(p.cid) % 60
if getPlayerSoul(p.cid) > 120 then
doPlayerSendTextMessage(p.cid, 22, getCreatureName(p.cid)..', you have enough soul points to train for '.. hour ..' hours and '.. minutes ..' minutes')
elseif getPlayerSoul(p.cid) == 120 then
doPlayerSendTextMessage(p.cid, 22, getCreatureName(p.cid)..', you have enough soul points to train for '.. hour ..' hours.')
elseif getPlayerSoul(p.cid) > 60 and getPlayerSoul(p.cid) < 120) then
doPlayerSendTextMessage(p.cid, 22, getCreatureName(p.cid)..', you have enough soul points to train for '.. hour ..' hour and '.. minutes ..' minutes')
elseif getPlayerSoul(p.cid) == 60 then
doPlayerSendTextMessage(p.cid, 22, getCreatureName(p.cid)..', you have enough soul points to train for '.. hour ..' hour.')
else
doPlayerSendTextMessage(p.cid, 22, getCreatureName(p.cid)..', you have enough soul points to train for '.. minutes ..' minutes')
end
end
function templeTeleport(p)
if getPlayerAccess(p.cid) >= ACCESS_TO_USE then
doCreatureSetStorage(p.cid, storage, 0)
doSendMagicEffect(getThingPos(p.cid), CONST_ME_TELEPORT)
doTeleportThing(p.cid, TEMPLE_POS)
doSendMagicEffect(TEMPLE_POS, CONST_ME_ENERGYAREA)
else
doPlayerSendCancel(p.cid,'You don\'t have access to do this.')
end
end
function takeSoulPoints(p)
if getPlayerSoul(p.cid) > amount then
doPlayerAddSoul(p.cid, -p.soul)
p.seconds = 60000
else
doPlayerSendTextMessage(p.cid,22,'Sorry '.. getCreatureName(p.cid) ..', you do not have enough soul points to train.')
addEvent(templeTeleport, 1, p)
end
end
function trainerthree(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
doPlayerSendTextMessage(p.cid, 22, 'Your training session will begin in 30 seconds')
addEvent(trainertwo, 10 * 1000, p)
end
return false
end
function trainerthree(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
doPlayerSendTextMessage(p.cid, 22, 'Your training session will begin in 20 seconds')
addEvent(trainerone, 10 * 1000, p)
end
return false
end
function trainerone(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
doPlayerSendTextMessage(p.cid, 22, 'Your training session will begin in 10 seconds')
addEvent(readyToTrain, 10 * 1000, p)
end
return false
end
function readyToTrain(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
doPlayerSendTextMessage(p.cid, 22, 'Your training session will now begin')
doPlayerAddSoul(p.cid, -p.soul)
addEvent(trainMeA, t, p)
end
return false
end
function trainMeA(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
for i = 0, 5 do
doPlayerAddSkillTry(p.cid, i, skilltries)
end
if p.seconds <= 1000 then
addEvent(takeSoulPoints, 1 * 1000, p)
end
p.seconds = p.seconds - t
addEvent(trainMeB, t, p)
end
return false
end
function trainMeB(p)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
for i = 0, 5 do
doPlayerAddSkillTry(p.cid, i, skilltries)
end
if p.seconds <= 1000 then
addEvent(takeSoulPoints, 1 * 1000, p)
end
p.seconds = p.seconds - t
addEvent(trainMeA, t, p)
end
return false
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local seconds = 60000
local p = {cid = cid, item = item, pos = pos, soul = soul, seconds = seconds}
doCreatureSetStorage(p.cid, storage, 1)
if isPlayer(p.cid) and getCreatureStorage(p.cid, storage) == 1 then
if p.item.actionid == 900 and getPlayerSoul(p.cid) > amount then
timeCheck(p)
addEvent(trainerthree, 1 * 1000, p)
else
addEvent(takeSoulPoints, 1, p)
end
end
return false
end
function onStepOut(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if isPlayer(cid) then
doCreatureSetStorage(cid, storage, 0)
doPlayerSendTextMessage(cid, 22, 'Your training session has now ended')
end
return true
end