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

Problem with walkback movement script

bury

Active Member
Joined
Jul 27, 2008
Messages
421
Solutions
7
Reaction score
25
I'm using tfs 0.4

Searched in the forum but it seems that the script I use works for everybody lol

walkback.lua

Lua:
local SPECIAL_QUESTS = {2001}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if(not isPlayer(cid)) then
        return true
    end

    if(isContainer(item.uid)) then
        if(not isInArray(SPECIAL_QUESTS, item.actionid) and item.uid > 65535) then
            return true
        end
    elseif(getTileInfo(position).creatures <= 1) then
        return true
    end
   
    if(fromPosition.x == 0) then -- player just logged in
        fromPosition = getTownTemplePosition(getPlayerTown(cid))
        doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
    end

    doTeleportThing(cid, fromPosition, true)
    return true
end

movements.xml

Code:
    <!-- Walkback when walking on quest chest -->
    <movevent type="StepIn" itemid="1738" event="script" value="walkback.lua"/>
    <movevent type="StepIn" itemid="1740" event="script" value="walkback.lua"/>
    <movevent type="StepIn" fromid="1746" toid="1749" event="script" value="walkback.lua"/>

problema7.jpg


problema8.jpg


Thanks you forum.
 
You can put simple prints just after every return and you will see where the function stucks

If you put them after you will get an error something like "can't reach code" and the it won't get printed.
Put it before a return.

Also put one below the function onStepIn to check if the script is even loaded.
Another thing is to check for "2000" in movements.xml, most servers looks for the actionid insted of the item itself.
 
@pasiak12

If you put them after you will get an error something like "can't reach code" and the it won't get printed.
Put it before a return.

Also put one below the function onStepIn to check if the script is even loaded.
Another thing is to check for "2000" in movements.xml, most servers looks for the actionid insted of the item itself.

If I search for "2000" in movements.xml I don't find anything. Sorry but what you mean about before or after return? If I go to the chest the characters get on there (and it doesn't go down to the floor again). You can keep on the chest everytime. I dont know if you want me to edit the scripts returns and test it until I find the error or something like that? :)

Also script loads properly (no error on console, and also I dont get any error when I get on the chest).

Thanks!
 
If you want to fix some error, you firstly need to find the error.

Put some prints before every return like

Code:
print("return 1")
return true

and then watch the server console after steeping on chest[/code]
 
If you want to fix some error, you firstly need to find the error.

Put some prints before every return like

Code:
print("return 1")
return true

and then watch the server console after steeping on chest[/code]

Hello!

I dont know if I have to write print("return 1") in all the four return true or print("return 1") on first return true, then print("return 2") in the second one and so on.

I tested both way, and server spams always:

return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1
return 1

Thanks
 
Put different numbered returns (We need to distinguish them from themselves) and show us the code.

Step only once on the chest and present us the result of the console.
 
Put different numbered returns (We need to distinguish them from themselves) and show us the code.

Step only once on the chest and present us the result of the console.

Okay yes, I made both things. Tried with:

print("return 1")
print("return 2")
print("return 3")
print("return 4")

in each return true, and that is what happened. When I start server it spams

return 1
return 1
return 1
return 1
return 1

Everytime.

Ok, but everytime I get into a chest I get return 3:

return 1
return 1
return 3
return 3
return 3
return 1
return 1
return 3
return 3
return 1
return 3
return 1
return 1
return 1
return 1

The script:


Lua:
local SPECIAL_QUESTS = {2001}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if(not isPlayer(cid)) then
    print("return 1")
        return true
    end

    if(isContainer(item.uid)) then
        if(not isInArray(SPECIAL_QUESTS, item.actionid) and item.uid > 65535) then
        print("return 2")
            return true
        end
    elseif(getTileInfo(position).creatures <= 1) then
    print("return 3")
        return true
    end
   
    if(fromPosition.x == 0) then -- player just logged in
        fromPosition = getTownTemplePosition(getPlayerTown(cid))
        doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
    end

    doTeleportThing(cid, fromPosition, true)
    print("return 4")
    return true
end

Thanks dude!
 
Show the result of this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if(isPlayer(cid)) then
        doTeleportThing(cid, fromPosition, true)
        print("works")
    else
        print("error")
    end
end
 
Show the result of this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if(isPlayer(cid)) then
        doTeleportThing(cid, fromPosition, true)
        print("works")
    else
        print("error")
    end
end

Error spams in the start of the server, but only that script, true? I dont have to mix it with mine or w/e?

In that case, it displays error everytime. Thanks.
 
Check if this function works.
Where did you get the datapack?
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
        doTeleportThing(cid, fromPosition, true)
end
 
Check if this function works.
Where did you get the datapack?
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
        doTeleportThing(cid, fromPosition, true)
end

Uff I've it since 2012, I cant remember good, but normally everything use to work properly. Should I check that function without any prints, in my original script or how?

Thanks!!

EDIT:

If not, is possibly to load any other walkback?? Thanks.

bump

bump
 
Last edited by a moderator:
If not, is possibly to load any other walkback?? Thanks.

You can register another things to work with that walkback script

Code:
<movevent type="StepIn" itemid="1738" event="script" value="walkback.lua"/>

where you can set another item id on itemid="1738" part

You can also set it to action or unique id.
 
You can register another things to work with that walkback script

Code:
<movevent type="StepIn" itemid="1738" event="script" value="walkback.lua"/>

where you can set another item id on itemid="1738" part

You can also set it to action or unique id.

But the problem is the walkback.lua script doesnt work somehow in my server no?
 
Back
Top