• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Offline trainers

Cronox

www.Searz-Online.com
Joined
Jul 5, 2011
Messages
1,810
Reaction score
123
Location
Mexico
Don't works offline trainers ,all skills up but magic level don't up.. in 0.3 - 10.10
I have this script:
Code:
local statue = {
[18488] = SKILL_SWORD,
[18489] = SKILL_AXE,
[18490] = SKILL_CLUB,
[18491] = SKILL_DISTANCE,
[18492] = SKILL__MAGLEVEL
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local premiumDays = getPlayerPremiumDays(cid)

if premiumDays > 0 then
doPlayerSetOfflineTrainingSkill(cid, statue[item.itemid])
doPlayerSetOfflineTrainingSkill(cid, SKILL_MAGLEVEL)
doRemoveCreature(cid)
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUNEEDPREMIUMACCOUNT)
end
return true
end
and I see this line bad:
[18492] = SKILL__MAGLEVEL
changed to
[18492] = SKILL_MAGLEVEL

and try but have same error don't up magic level ,i see compat ,see all functions ,lua ,etc i think made by is sources :p but i am not sure. nobody know why
 
Code:
local statue = {
    [18488] = SKILL_SWORD,
    [18489] = SKILL_AXE,
    [18490] = SKILL_CLUB,
    [18491] = SKILL_DISTANCE,
    [18492] = SKILL_MAGLEVEL
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local premiumDays = getPlayerPremiumDays(cid)

    if (isPlayerPzLocked(cid)) then
        return false
    end

    if (isPremium(cid)) then
        doPlayerSetOfflineTrainingSkill(cid, statue[item.itemid])
        doRemoveCreature(cid)
    else
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUNEEDPREMIUMACCOUNT)
    end
    return true
end

Taken from printers datapack.
 
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
 
Back
Top