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

Custom script doesn't work?

FenX

Advanced OT User
Joined
Jul 8, 2019
Messages
360
Solutions
1
Reaction score
159
Lua:
local config = {
    [9990] = Position(989, 1042, 7),
    [9991] = Position(989, 1042, 7)
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local targetPosition = config[item.uid]
    if not targetPosition then
        return true
    end
    local chance = 50
    if math.random(1, 100) <= chance then
        player:teleportTo(targetPosition)
        doTargetCombatHealth(0, player, COMBAT_PHYSICALDAMAGE, -150, -150, CONST_ME_NONE)
        targetPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, '')
        return true
    else
        player:sendCancelMessage('')
    end
end
This is my script. Simple script to send a player to a designated location when stepping in on a tile/w.e with the unique ids 9990/9991.

XML:
    <movement event="StepIn" fromuid="9990" touid="9991" script="custom/port.lua"/>

When I get on the server to test, it doesn't work. No errors in console. Unique ids are present on the map. No duplicate uniqueids. Just doesn't work.

TFS 1.3

Enlighten me please :(
 
Solution
you have set the action id in your map properly?

try
<movevent event="StepIn" actionid="9990" script="custom/port.lua" />
<movevent event="StepIn" actionid="9991" script="custom/port.lua" />

or

<movevent event="StepIn" uniqueid="9990" script="custom/port.lua" />
<movevent event="StepIn" uniqueid="9991" script="custom/port.lua" />

if you have action or unique id
Is it even running the script? Put a print("test") at the start of the script to even see if it's triggering the Step movement action for a start.
 
you have set the action id in your map properly?

try
<movevent event="StepIn" actionid="9990" script="custom/port.lua" />
<movevent event="StepIn" actionid="9991" script="custom/port.lua" />

or

<movevent event="StepIn" uniqueid="9990" script="custom/port.lua" />
<movevent event="StepIn" uniqueid="9991" script="custom/port.lua" />

if you have action or unique id
 
Solution
Solved.

Look what I did like an idiot:
XML:
  <movement event="StepIn" fromuid="9990" touid="9991" script="custom/port.lua"/>

MOVEMENT and not "MOVEVENT" 😂
 
Back
Top