• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Antytrap Tile [help]

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
550
Solutions
17
Reaction score
108
is possible convert this script for tfs 1.2 ?
someone help me please

local session, events =
15 * 60, {}

function train(cid, time)
local player = Player(cid)
if isPlayer(cid) then
if os.time() - time >= session then
events[player:getGuid()] = nil
doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -25105, -50250, CONST_ME_NONE)
doTeleportThing(cid, getPlayerMasterPos(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your trap tile has been expire. Thanks for playing Global-War.")
else
events[player:getGuid()] = addEvent(train, 6000, cid, time)
local v = player:getPosition(cid)
player:say('Trap Tile!', TALKTYPE_MONSTER_SAY)
doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -3105, -3250, CONST_ME_NONE)
doSendMagicEffect(v, CONST_ME_MAGIC_GREEN)
end
end
end

function onStepIn(cid, item, position, fromPosition)
if isPlayer(cid) then
train(cid, os.time())
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Warning!You are in trap tile.")
end
end

function onStepOut(cid, item, position, fromPosition)
if isPlayer(cid) then
local v = getPlayerGUID(cid)
if v then
stopEvent(events[v])
events[v] = nil
end
end
end

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/traptile.lua:eek:nStepIn
luaAddEvent(). Argument #3 is unsafe
stack traceback:
[C]: in function 'addEvent'
data/movements/scripts/traptile.lua:13: in function 'train'
data/movements/scripts/traptile.lua:24: in function <data/movements/scripts/traptile.lua:22>

original script by @narko

https://otland.net/threads/antytrap-tile.146887/#post-1413006
 
tfs 1.2 doesnt use cid
use documentation & look at movement scripts already made to see the correct arguments
https://otland.net/threads/tfs-1-0-1-2-lua-functions.197202/

the problem is that the player argument is called cid and player is a userdata
passing userdatas through addevent is bad so you get the id and then create it again with your callback function
addEvent(train, delay, player:getId(), time)

Code:
local session, events = 15 * 60, {}

function train(cid, time)
    local player = Player(cid)
    if not player then
        return true
    end
    local guid = player:getGuid()
    local gettime = os.time() - time >= session
    if gettime then
        events[guid] = nil
        player:teleportTo(getPlayerMasterPos(cid))
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your trap tile has expired. Thanks for playing Global-War.")
    else
        events[guid] = addEvent(train, 6000, cid, time)
        player:say('Trap Tile!', TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, gettime and -25105 or -3105, gettime and -50250 or -3250, CONST_ME_NONE)
end

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player then
        train(player:getId(), os.time())
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Warning! You are in trap tile.")
    end
end

function onStepOut(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player then
        local v = player:getGuid()
        if v then
            stopEvent(events[v])
            events[v] = nil
        end
    end
end
 
Last edited:
tfs 1.2 doesnt use cid
use documentation & look at movement scripts already made to see the correct arguments
https://otland.net/threads/tfs-1-0-1-2-lua-functions.197202/

the problem is that the player argument is called cid and player is a userdata
passing userdatas through addevent is bad so you get the id and then create it again with your callback function
addEvent(train, delay, player:getId(), time)

very very thanks again :D <3
 
Back
Top