• 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!

Lua MoveEvent Training Square [TFS_11]

kushovu

NXA
Joined
Jan 27, 2009
Messages
75
Reaction score
13
Hi everyone its me again with another compat problem

TFS Version: 1.1
Engine: https://github.com/otland/forgottenserver
Data pack:https://github.com/orts/server

Map Version: 10.76
Map source: https://github.com/orts/world/

In the last post i had problems adding an NPC of an Outdated TFS

At this time i want to Add the Training Square system but the only one i found is this

https://otland.net/threads/training-square.33899/

But this one only works on (TFS 0.3.4pl2)

I do the best i can installing it and checking if Compat.lua was working but after everything it is half working, when i enter to the Square it says "Your training will begin) but never advance

Also at the console i get this Error:
Sin_t_tulo13.jpg


Someone could help me?

Bump
 
Last edited by a moderator:
Added that line at Compat.lua but didn't work (sorry newbie arround here)

if i'm not in an error That link is from the Source for compiling, i used that version So it should have that function active but its all i understand from this
 
The links are to show where you can find it.
You can just change the function to what posted in the script, use itemid then instead of uid.
 
Ok, i went to my Source code and find that lines so i got that funcion active, the last thing is to change the lua of the sqtrainer

from this:
Code:
        local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
        if weaponLeft.itemid ~= 0 then
            weaponLeft = getItemWeaponType(weaponLeft.uid)
        end
        if weaponRight.itemid ~= 0 then
            weaponRight = getItemWeaponType(weaponRight.uid)
        end

To this:?

Code:
        local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
        if weaponLeft.itemid ~= 0 then
            weaponLeft = ItemType(itemid):getWeaponType(weaponLeft)
        end
        if weaponRight.itemid ~= 0 then
            weaponRight = ItemType(itemid):getWeaponType(weaponRight)
        end
 
Instead of itemid the itemid of the item, so weaponRight.itemid etc, adding weaponRight between () is not needed btw.
 
So it shout see like this:

Code:
        local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
        if weaponLeft.itemid ~= 0 then
            weaponLeft = ItemType(itemid):getWeaponType()
        end
        if weaponRight.itemid ~= 0 then
            weapon

Thanks! now i'm getting another 2 Errors:

Function: 'doPlayerAddSpentMana'
and
Function: 'addEvent'

Sin_t_tulo15.jpg
 
Please can you explainme a little more?

Code:
-- 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 -- Time to wait before start again in seconds

-- Weapon Types --
local weaponTypes = {
    { 1, 2 }, -- Sword
    { 2, 1 }, -- Club
    { 3, 3 }, -- Axe
    { 4, 5 }, -- Shield
    { 5, 4 } -- Distance
}

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 "..lock.." seconds before you start again")
        return false
    end
    setPlayerStorageValue(p.cid, 18010, 1)
    if isPlayer(p.cid) and p.item.actionid == 900 then
        doPlayerSendTextMessage(p.cid,22,"Your training session will now begin")
        addEvent(trainMe, t, p)
    end
    return true
end
function onStepOut(cid, item)
    if getPlayerStorageValue(cid, 18010) == 2 then
        return false
    end
    setPlayerStorageValue(cid, 18010, 2)
    addEvent(trainLock, lock * 1000, 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 and p.item.actionid == 900 then
        local weaponLeft = getPlayerSlotItem(p.cid, CONST_SLOT_LEFT)
        local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
        if weaponLeft.itemid ~= 0 then
            weaponLeft = ItemType(itemid):getWeaponType()
        end
        if weaponRight.itemid ~= 0 then
            weaponRight = ItemType(itemid):getWeaponType()
        end
        for _, t in pairs(weaponTypes) do
            if t[1] == weaponLeft or t[1] == weaponRight then           
                doPlayerAddSkillTry(p.cid, t[2], skillTries)
            end
        end
        manaspent = getPlayerMana(p.cid)
        doPlayerAddSpentMana(p.cid, manaspent)
        doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)

        doSendMagicEffect(getPlayerPosition(p.cid),34)
   
        addEvent(trainMe, t, p)
    end
    return true
end

Here is the code, i'm trying to understand it but its my first time with a Lua Script
 
It is no longer doPlayerAddSpentMana in 1.0 I guess.

Also I think Limos meant you have to change it to cid.uid? Not sure if that's how it works in 1.0 but it might also work with Player(cid) I think.

Sorry if I'm completely wrong and none of this is helpful I don't use 1.0 x.x
 
creature/player to avoid confusion.
Ah I understand now... I completely forgot that I had helped a friend with something similar but the default stepOut function used in his data folder still used cid which was just a labeling error as it was suppose to be creature. It doesn't matter what it is called in the end but to someone like myself that doesn't follow 1.0 development it is quite confusing when you see cid and it really isn't meant to be xD

But now that I am interested... if the cid is userdata then why does getPlayerStorage~(cid) work? Shouldnt it be cid:getStorage?
 
Back
Top