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

TFS 1.X+ Training slot script error

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,492
Solutions
27
Reaction score
857
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I got this scripts to automatically teleport players to training zones, but I encounter this error. Not sure, but I think that it's triggered when the training rooms are full.
1656693806341.png

Lua:
local config = {
                {x=168,y=472,z=8},
                {x=187,y=472,z=8},
                {x=206,y=472,z=8},
                {x=225,y=472,z=8},
                {x=168,y=490,z=8},
                {x=187,y=490,z=8},
                {x=206,y=490,z=8},
                {x=225,y=490,z=8},
                {x=168,y=508,z=8},
                {x=187,y=508,z=8},
                {x=206,y=508,z=8},
                {x=225,y=508,z=8},
                {x=168,y=526,z=8},
                {x=187,y=526,z=8},
                {x=206,y=526,z=8},
                {x=225,y=526,z=8}               
                }

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)
    for _, pos in pairs(config) do
        if not isPlayer(getTopCreature(pos).uid) then
            if doTeleportThing(cid, pos) then
                return true
            end
        end
    end
    doTeleportThing(cid, fromPosition)
    doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    doCreatureSay(cid, "The training area is full.", TALKTYPE_MONSTER, nil, nil, fromPosition)
    return true
end

How can I possibly fix this to don't make this error appear again? Or optimize this script a little bit, it will use the same coordinates.
Thanks in advance! Regards!
 
Solution
change
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)
to
Lua:
function onStepIn(cid, item, position, fromPosition)

I'm 99% sure those other position parameters don't exist, and thus you're getting a nil value
change
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)
to
Lua:
function onStepIn(cid, item, position, fromPosition)

I'm 99% sure those other position parameters don't exist, and thus you're getting a nil value
 
Solution
change
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)
to
Lua:
function onStepIn(cid, item, position, fromPosition)

I'm 99% sure those other position parameters don't exist, and thus you're getting a nil value

Thanks you @Xikini I will do the proper testings asap, for the moment, I think you're right. If I found something else weird I will let you know.
Regards! :D
Post automatically merged:

Edit: Work as intended, solved!
 
Last edited:
Back
Top