Hello!
I've decided to release my offline trainer script!
If you decide to use it, please give me some reputation
I have not tested this with any other servers than my own, so please don't expect it to work flawlessly.
Also stamina does not work! However you can limit the rate of how fast you advance, and you can also set the max amount of time you can train each time you use the trainers.
This requires the 9.6 items, btw.
So let's go:
To install it, follow these steps:
1. Open up your database, copy and paste this into the sql-query field:
(I know its not neccessary to store this in a seperate table, but its a personal preference)
2. Open your data/actions folder.
First go to actions.xml and add the following:
3. Open data/actions/scripts folder, and create a new file called offline_trainer.lua
There you paste the following:
4. Soon done now! Now goto your data/creaturscripts/scripts/ find the file called login.lua.
Scroll down to the bottom of the page, and place your marker on a new line before the
"return true
end" sentence, and paste this:
5. Finally, in the same script but at the very end of the file, create a new line and paste this:
After you have followed these steps, you should have a decent offline trainer script. Just place the offline trainer statues around on the map, and this will take care of
the rest.
Hope you enjoy it! Have fun!
I've decided to release my offline trainer script!
If you decide to use it, please give me some reputation
I have not tested this with any other servers than my own, so please don't expect it to work flawlessly.
Also stamina does not work! However you can limit the rate of how fast you advance, and you can also set the max amount of time you can train each time you use the trainers.
This requires the 9.6 items, btw.
So let's go:
To install it, follow these steps:
1. Open up your database, copy and paste this into the sql-query field:
Code:
CREATE TABLE offline_training
(account_id int(11),
name varchar(256),
start_training int(11),
type varchar(256))
2. Open your data/actions folder.
First go to actions.xml and add the following:
Code:
<action itemid="18492" script="offline_trainer.lua"/> -- OFFLINE TRAINING STATUE
<action itemid="18491" script="offline_trainer.lua"/> -- OFFLINE TRAINING STATUE
<action itemid="18490" script="offline_trainer.lua"/> -- OFFLINE TRAINING STATUE
<action itemid="18489" script="offline_trainer.lua"/> -- OFFLINE TRAINING STATUE
<action itemid="18488" script="offline_trainer.lua"/> -- OFFLINE TRAINING STATUE
3. Open data/actions/scripts folder, and create a new file called offline_trainer.lua
There you paste the following:
Code:
-- Offline trainers by Hauni :]
function onUse(cid, item, frompos, item2, topos)
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local name = getCreatureName(cid)
local statueIDs = { [18492]=8, [18491]=SKILL_DISTANCE,[18490]=SKILL_CLUB, [18489]=SKILL_AXE,[18488]=SKILL_SWORD}
if statueIDs[item.itemid] then
db.query("INSERT INTO offline_training (`account_id`,`name`,`start_training`,`type`) VALUES(".. accid ..",'".. name .."',".. os.time()..",'".. statueIDs[item.itemid] .." ');")
doRemoveCreature(cid)
return
end
end
4. Soon done now! Now goto your data/creaturscripts/scripts/ find the file called login.lua.
Scroll down to the bottom of the page, and place your marker on a new line before the
"return true
end" sentence, and paste this:
Code:
-- CONFIG
local secondsPerHit = 2 -- THE ATTACKSPEED (1 hit per 2 seconds; default)
local manaGenPerSec = 10 -- MANA USED PER SEC
local offlineModifier = 0.5 -- FROM 0-1 (or higher if you wish). How fast you are skillin on offline training compared to normal (0.5 = 50%)
local maxSecondsTraining = 60 * 60 * 12 -- (Default 12 hours)
--END of config
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local name = getCreatureName(cid)
local checkTraining = db.storeQuery("SELECT * FROM offline_training WHERE `account_id`=".. accid .." AND `name`='".. name .."';")
local skills = {[8]=MAGIC, [4]=SKILL_DISTANCE,[1]=SKILL_CLUB, [3]=SKILL_AXE,[2]=SKILL_SWORD}
local skillNames = {[8]="Magic Level", [4]="Distance Fighting",[1]="Club Fighting", [3]="AxeFighting",[2]="Sword Fighting"}
if checkTraining then
local skill = result.getDataInt(checkTraining, "type")
local timeTrained = result.getDataInt(checkTraining, "start_training")
local secondsTrained = os.time()-timeTrained
local skillTries = math.floor((secondsTrained/secondsPerHit)*offlineModifier)
local skillBefore
local skillAfter
if timeTrained > maxSecondsTraining then
timeTrained = maxSecondsTraining
end
if skill ~= 8 then
skillBefore = getPlayerSkillLevel(cid, skills[skill])
doPlayerAddSkillTry(cid, skills[skill], skillTries)
skillAfter = getPlayerSkillLevel(cid, skills[skill])
else
skillBefore = getPlayerMagLevel(cid)
doPlayerAddSpentMana(cid, manaGenPerSec*secondsTrained)
skillAfter = getPlayerMagLevel(cid)
end
local skillBeforeShield = getPlayerSkillLevel(cid, 5)
doPlayerAddSkillTry(cid, 5, skillTries)
local skillAfterShield = getPlayerSkillLevel(cid, 5)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your ".. skillNames[skill] .." skill changed from level ".. skillBefore.." to level ".. skillAfter ..".")
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your Shielding skill changed from level ".. skillBeforeShield.." to level ".. skillAfterShield ..". ")
db.query("DELETE FROM offline_training WHERE `account_id`=".. accid .." AND `name`='".. name .."';")
end
5. Finally, in the same script but at the very end of the file, create a new line and paste this:
Code:
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
After you have followed these steps, you should have a decent offline trainer script. Just place the offline trainer statues around on the map, and this will take care of
the rest.
Hope you enjoy it! Have fun!
Last edited: