Codex NG
Recurrent Flamer
- Joined
- Jul 24, 2015
- Messages
- 2,994
- Solutions
- 12
- Reaction score
- 1,657
Since my original account created this script, I can take full credit for the original and the updated version
Credits and instructions are in the script itself.
Credits and instructions are in the script itself.
Code:
--[[
Square Skill Trainer made by Arthur aka artofwork 12/1/14, my original account
Updated 10/15/2015, to 1.2 based on tfs sources on github by Codex NG :)
This script will train all of a players skills indefintely including magic level
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
Now removes offline training time for free accounts
New in this script?
skill tries for both free account & premium accounts
mana gain for both free & premium accounts
mana multipliers to effect magic level for both free and premium accounts based on percentage
experience gain for both free and prem accounts
Added optional all skills for free accounts or just the weapons & shield they have equiped
add this too movements
<!-- Square Trainer -->
<movevent event="StepIn" actionid="900" script="squaretrainer.lua"/>
<movevent event="StepOut" actionid="900" script="squaretrainer.lua"/>
save this file in data\movements\script\ as squaretrainer.lua
]]--
local special = false -- true for vip false for prem
-- do not edit
local currentTime = os.time()
local day = 86400 -- 1 full day in seconds
local minimumTime = 0 -- minimum time for vip
local addSkillTimer = 1000 -- do not edit - time at which skill tries are added
local skills = 5 -- 0 to 5 includes 0:fist, 1:club, 2:sword, 3:axe, 4:distance, 5:shield -- do not edit
-------------------------------
local allskills = false -- should free accounts train all their skills
local removeOfflineTime = true -- do you want to remove offline training time?
-- minutes to remove per minute, should be minimum 2 since they gain a minute for every minute they are not killing something
local timeOfOfflineToRemove = 2
-- minimum hours needed to train, set it to 12 if u want to test the tp to temple
local minimumTimeNeedToUseTrainers = 1
local useConfigMlRate = false -- do you want to use the config settings rate of Magic in this script
local useConfigExpRate = false -- do you want to use the config settings rate of Exp in this script
local useConfigSkillRate = true -- do you want to use the config settings rate of Skills in this script
-- do not edit
local keys = {
RATE_SKILL = 6,
RATE_MAGIC = 8,
RATE_LOOT = 7,
RATE_EXPERIENCE = 5
}
local tseconds = 1000
local tminute = 60 * tseconds
local thour = 60 * tminute
local trainingTimeMax = thour * minimumTimeNeedToUseTrainers -- 43200000 default value (12 hours)
-----------------
-- used by isSpecial, this allows certain account types to skip the offline time removal
local godAccount = 4
-- tile actionid
local aid = 900
local p = {}
local addskills =
{
prem = 1000, -- xp to add as vip/prem (depends if special is true) account per interval
-- the rate is a percentage of their max mana, this way it scales with their level :)
manaGainPremRate = .10, -- mana to add as vip/prem (depends if special is true) account per interval
premSkillTries = 100, -- Number of tries per skill for vip/prem (depends if special is true) account per interval
premManaMultiplier = 5, -- when player has full mana multiply how much more mana is used to gain magic level
free = 100,
manaGainFreeRate = .01, -- mana to add as free account per interval
freeSkillTries = 1, -- Number of tries per skill for free account
freeManaMultiplier = 1, -- when player has full mana multiply how much more mana is used to gain magic level
balanceShield = 3 -- 3 is good, but if shielding goes up too quick then lower it, use only whole numbers e.g. 1, 2, 3
}
-- do not edit
local weaponTypes = {
[0] = { 0, 0 }, -- fist
{ 1, 2 }, -- Sword
{ 2, 1 }, -- Club
{ 3, 3 }, -- Axe
{ 4, 5 }, -- Shield
{ 5, 4 }, -- Distance
{ 6, 0 } -- 6 is rod / wands, 0 is for fists..
}
local shieldId = 5
function getSlottedItems(player)
local left = pushThing(player:getSlotItem(CONST_SLOT_LEFT)).itemid
local right = pushThing(player:getSlotItem(CONST_SLOT_RIGHT)).itemid
left = ItemType( left ):getWeaponType()
right = ItemType( right ):getWeaponType()
return left, right
end
--------------------------------
-- this function is only effected by free accounts
function templeTeleport(p)
p.player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
p.player:setStorageValue( 18010, 0)
local temple = p.player:getTown():getTemplePosition()
p.player:teleportTo(temple)
temple:sendMagicEffect(CONST_ME_ENERGYAREA)
p.player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, "..p.name.." you don't have enough offline time to train.")
end
function RemoveOfflineTrainingTime(p)
if trainingTimeCheck(p) then
p.player:removeOfflineTrainingTime(timeOfOfflineToRemove * 60000)
p.seconds = 60000 -- reset the timer
end
end
function trainingTimeCheck(p)
local time_ = p.player:getOfflineTrainingTime()
if time_ <= (timeOfOfflineToRemove * tminute) then
templeTeleport(p)
end
if time_ >= trainingTimeMax then
return true
else
templeTeleport(p)
end
end
function isSpecial(player)
-- this is so i could test the shit right away
if player:getAccountType() >= godAccount then
return true
end
if special then
return (math.floor((player:getStorageValue(13540) - currentTime) / (day)) > minimumTime)
else
return player:isPremium()
end
end
function train(p)
local player = p.player
if player:isPlayer() and player:getStorageValue(18010) == 1 then
if isSpecial(player) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your training session will now begin.")
addEvent(trainMe, 1, p)
else -- if free account, they have to wait 30 seconds to begin training
if p.secondsTime > 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your training session will begin in "..(p.secondsTime).." seconds.")
end
if p.secondsTime <= 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your training session will now begin.")
addEvent(trainMe, 1, p)
else
p.secondsTime = p.secondsTime - 10
addEvent(train, 10000, p)
end
end
end
return true
end
function returnRate(useRate, RATE)
return useRate and configManager.getNumber(RATE) - 3300 or 1
end