• 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 [TFS 1.2 - 8.60] Problem with swimming.lua & a teleport

adric21

Well-Known Member
Joined
Apr 26, 2016
Messages
275
Solutions
1
Reaction score
71
I have a problem with these scripts for version tfs 1.2 8.6

The first one does not work swimming.lua since the player when entering the sea does not change.

Lua:
local condition = Condition(CONDITION_OUTFIT)
condition:setOutfit({lookType = 267})
condition:setTicks(-1)

function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end

    creature:addCondition(condition)
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end

    creature:removeCondition(CONDITION_OUTFIT)
    return true
end


The second problem is when creating a teleport so that only players with level 250 can enter it does not work either.

Lua:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    local creature = Creature(cid)
    if(item.actionid<2000 and item.actionid>1000) then
        local levelReq = item.actionid-1000
        if(player:getLevel() <= levelReq) then
            creature:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level "..levelReq.." to enter.")
            return false
        end
    end    
    return true
end
 
Last edited by a moderator:
Solution
I use this script but idk how to change the text color orange for yellow
this is the script:
Code:
local effects = {
    {position = Position(981, 995, 7), text = 'Bienvenido!', effect = CONST_ME_FIREWORK_RED},
    {position = Position(1017, 987, 7), text = 'Expowiska', effect = CONST_ME_STUN,},
    {position = Position(1017, 986, 7), text = 'Questy', effect = CONST_ME_STUN,},
    {position = Position(1017, 985,7), text = 'Trener', effect = CONST_ME_STUN,},
    {position = Position(1023, 987, 7), text = 'Sklepy', effect = CONST_ME_STUN,},
    {position = Position(1023, 986, 7), text = 'Temple', effect = CONST_ME_STUN,},
    {position = Position(1023, 985, 7), text = 'Domki', effect = CONST_ME_STUN,},
    {position = Position(997, 1003...
The second problem is when creating a teleport so that only players with level 250 can enter it does not work either.

Code:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    local creature = Creature(cid)
    --if(item.actionid<2000 and item.actionid>1000) then
        local levelReq = item.actionid-1000
        if(player:getLevel() <= levelReq) then
            creature:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level "..levelReq.." to enter.")
            return false
        end
    --end  
    return true
end
Try and put action id 1250
 
Last edited:
1. Did you update your compat.lua?
forgottenserver/compat.lua at master · otland/forgottenserver · GitHub

2. What is the action id of the item you created? Try this script and take an SS of your console
Lua:
function onStepIn(creature, item, position, fromPosition)
    print("1")
    if not creature:isPlayer() then
        return false
    end

    if item.actionid < 2000 and item.actionid > 1000 then
        print("2")
        local levelReq = item.actionid - 1000
        if player:getLevel() <= levelReq then
            print("3")
            creature:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level " .. levelReq .. " to enter.")
            return false
        end
    end
    return true
end
 
I just fixed the 2 script only the one of swimming I do not know because it does not change of outfit when it walks on the sea. Update my compact.lua
 
Should be this:
Lua:
if player:getLevel() >= levelReq then

If item actionid is 1250, levelreq var becomes 250. But your condition says if level is below 250 then give access, not above. :p
 
I use this script but idk how to change the text color orange for yellow
this is the script:
Code:
local effects = {
    {position = Position(981, 995, 7), text = 'Bienvenido!', effect = CONST_ME_FIREWORK_RED},
    {position = Position(1017, 987, 7), text = 'Expowiska', effect = CONST_ME_STUN,},
    {position = Position(1017, 986, 7), text = 'Questy', effect = CONST_ME_STUN,},
    {position = Position(1017, 985,7), text = 'Trener', effect = CONST_ME_STUN,},
    {position = Position(1023, 987, 7), text = 'Sklepy', effect = CONST_ME_STUN,},
    {position = Position(1023, 986, 7), text = 'Temple', effect = CONST_ME_STUN,},
    {position = Position(1023, 985, 7), text = 'Domki', effect = CONST_ME_STUN,},
    {position = Position(997, 1003, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1013, 1003, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(997, 1012, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1013, 1012, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1004, 1004, 7), text = 'Dzwignie', effect = CONST_ME_STUN,},
    {position = Position(1006, 1004, 7), text = 'Dzwignie', effect = CONST_ME_STUN,},
    }
function onThink(creature, interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end
 
I use this script but idk how to change the text color orange for yellow
this is the script:
Code:
local effects = {
    {position = Position(981, 995, 7), text = 'Bienvenido!', effect = CONST_ME_FIREWORK_RED},
    {position = Position(1017, 987, 7), text = 'Expowiska', effect = CONST_ME_STUN,},
    {position = Position(1017, 986, 7), text = 'Questy', effect = CONST_ME_STUN,},
    {position = Position(1017, 985,7), text = 'Trener', effect = CONST_ME_STUN,},
    {position = Position(1023, 987, 7), text = 'Sklepy', effect = CONST_ME_STUN,},
    {position = Position(1023, 986, 7), text = 'Temple', effect = CONST_ME_STUN,},
    {position = Position(1023, 985, 7), text = 'Domki', effect = CONST_ME_STUN,},
    {position = Position(997, 1003, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1013, 1003, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(997, 1012, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1013, 1012, 7), text = 'Depo', effect = CONST_ME_STUN,},
    {position = Position(1004, 1004, 7), text = 'Dzwignie', effect = CONST_ME_STUN,},
    {position = Position(1006, 1004, 7), text = 'Dzwignie', effect = CONST_ME_STUN,},
    }
function onThink(creature, interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                for i = 1, #spectators do
                    spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                end
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
        end
    end

Lua:
spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
Lua:
TALKTYPE_MONSTER_SAY

forgottenserver/const.h at master · otland/forgottenserver · GitHub
 
Solution
Back
Top