• 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.1 Frozen Starlight portal

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,391
Solutions
7
Reaction score
550
Releasing my frozen starlight script. for TFS 1.1 due to request

What does it do?
By using the command "!set" a player can save their co-ords and then create a portal to those co-ords by using their frozen starlight on the ground to create a portal.

Features
-Only the person who makes portal can use it.
-Cannot make portal if in combat
-Cannot make portal on saved Co-ords.
-Cannot make portal on stairs, holes, ladders etc to avoid crashing server.
-Cooldown enabled to prevent spamming portals
-Can only make 1 portal at a time to prevent spam


Installation

data/actions/actions.xml
Code:
<action itemid="2361" script="starlighttp.lua"/>

data/actions/scripts/starlighttp.lua
Code:
local groundIds = {
    294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 430, 462, 469, 470, 482,
    484, 485, 489, 924, 3135, 3136, 7933, 7938, 8170, 8286, 8285, 8284, 8281,
    8280, 8279, 8277, 8276, 8567, 8585, 8596, 8595, 8249, 8250, 8251,
    8252, 8253, 8254, 8255, 8256, 8592, 8972, 9606, 9625, 13190, 14461, 19519, 21536
}

local storages = {82001, 82002, 82003}

local function doRemoveTeleport(pos)
    local tp = Tile(pos):getItemById(1387)
    if tp then
        tp:remove()
    end
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey, player)
    local s, player = {}, Player(cid)
    for x = 1, 3 do
        s[#s + 1] = player:getStorageValue(storages[x])
    end

    if player:getExhaustion(1000) > 0 then
        player:say('Your Starlight is still recharging!', TALKTYPE_MONSTER_SAY)
        return true
    end

    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:say('You cannot make a Portal whilst in battle!', TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    player:setExhaustion(1000, 10)

    if s[1] < 0 then
        player:say('You need to set your position!', TALKTYPE_MONSTER_SAY)
        return true
    end

    if toPosition.x == s[1] and toPosition.y == s[2] and toPosition.z == s[3] then
        player:say('You cannot create a portal here.', TALKTYPE_MONSTER_SAY)
        return true
    end

    local tile = Tile(toPosition)
    local ground = tile:getGround()
    if ground and isInArray(groundIds, ground:getId())
            or tile:getItemById(14435)
            or tile:getItemById(1387)
            or tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID)
            or tile:hasProperty(CONST_PROP_NOFIELDBLOCKPATH) then
        player:say('You cannot make a Portal here..', TALKTYPE_MONSTER_SAY)
        return true
    end

local teleport = Game.createItem(1387, 1, toPosition)
if teleport then
teleport:setActionId(2361)
teleport:setAttribute('description', 'Only ' .. player:getName():lower() .. ' can use this teleport.')
end

    addEvent(doRemoveTeleport, 10 * 1000, toPosition)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_BLUE)
    player:say('Your Frozen Starlight shimmers and creates a portal', TALKTYPE_MONSTER_SAY)
    return true
end

data/movements/movements.xml

Code:
<movevent event="StepIn" actionid="2361" script="ownertp.lua"/>

data/movements/scripts/ownertp.lua
Code:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local desc = item:hasAttribute('description') and item:getAttribute('description')
    if not desc:find(player:getName():lower()) then
        player:say('You cannot use this teleport.', TALKTYPE_MONSTER_SAY, false, 0, fromPosition)
        player:teleportTo(fromPosition)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        position:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    local storages, s = {82001, 82002, 82003}, {}
    for i = 1, 3 do
        s[#s + 1] = player:getStorageValue(storages[i])
    end

    local teleportDestination = Position(s[1], s[2], s[3])
    player:teleportTo(teleportDestination)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    teleportDestination:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

data/talkactions/talkactions.xml
Code:
  <talkaction words="!set" script="custom/starlighttp.lua"/>

data/talkactions/scripts/starlighttp.lua

Code:
local storages = {82001, 82002, 82003}

function onSay(cid, words, param)
     local player = Player(cid)
     local pos = player:getPosition()
     local p = {pos.x, pos.y, pos.z}
     for x = 1, 3 do
         player:setStorageValue(storages[x], p[x])
     end
     player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Position set!")
     player:say('Your position has been set!', TALKTYPE_MONSTER_SAY)
     player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
     return false
end


BIG THANKS TOO
-Limos
- Helping me to start the script.
 
Last edited:
Very awesome bro thanks alot :)

Releasing my frozen starlight script. for TFS 1.1 due to request

What does it do?
By using the command "!set" a player can save their co-ords and then create a portal to those co-ords by using their frozen starlight on the ground to create a portal.

Features
-Only the person who makes portal can use it.
-Cannot make portal if in combat
-Cannot make portal on saved Co-ords.
-Cannot make portal on stairs, holes, ladders etc to avoid crashing server.
-Cooldown enabled to prevent spamming portals
-Can only make 1 portal at a time to prevent spam


Installation

data/actions/actions.xml
Code:
<action itemid="2361" script="starlighttp.lua"/>

data/actions/scripts/starlighttp.lua
Code:
local groundIds = {
    294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 430, 462, 469, 470, 482,
    484, 485, 489, 924, 3135, 3136, 7933, 7938, 8170, 8286, 8285, 8284, 8281,
    8280, 8279, 8277, 8276, 8567, 8585, 8596, 8595, 8249, 8250, 8251,
    8252, 8253, 8254, 8255, 8256, 8592, 8972, 9606, 9625, 13190, 14461, 19519, 21536
}

local storages = {82001, 82002, 82003}

local function doRemoveTeleport(pos)
    local tp = Tile(pos):getItemById(1387)
    if tp then
        tp:remove()
    end
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey, player)
    local s, player = {}, Player(cid)
    for x = 1, 3 do
        s[#s + 1] = player:getStorageValue(storages[x])
    end

    if player:getExhaustion(1000) > 0 then
        player:say('Your Starlight is still recharging!', TALKTYPE_MONSTER_SAY)
        return true
    end

    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:say('You cannot make a Portal whilst in battle!', TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    player:setExhaustion(1000, 10)

    if s[1] < 0 then
        player:say('You need to set your position!', TALKTYPE_MONSTER_SAY)
        return true
    end

    if toPosition.x == s[1] and toPosition.y == s[2] and toPosition.z == s[3] then
        player:say('You cannot create a portal here.', TALKTYPE_MONSTER_SAY)
        return true
    end

    local tile = Tile(toPosition)
    local ground = tile:getGround()
    if ground and isInArray(groundIds, ground:getId())
            or tile:getItemById(14435)
            or tile:getItemById(1387)
            or tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID)
            or tile:hasProperty(CONST_PROP_NOFIELDBLOCKPATH) then
        player:say('You cannot make a Portal here..', TALKTYPE_MONSTER_SAY)
        return true
    end

local teleport = Game.createItem(1387, 1, toPosition)
if teleport then
teleport:setActionId(2361)
teleport:setAttribute('description', 'Only ' .. player:getName():lower() .. ' can use this teleport.')
end

    addEvent(doRemoveTeleport, 10 * 1000, toPosition)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_BLUE)
    player:say('Your Frozen Starlight shimmers and creates a portal', TALKTYPE_MONSTER_SAY)
    return true
end

data/movements/movements.xml

Code:
<movevent event="StepIn" actionid="2361" script="ownertp.lua"/>

data/movements/scripts/ownertp.lua
Code:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local desc = item:hasAttribute('description') and item:getAttribute('description')
    if not desc:find(player:getName():lower()) then
        player:say('You cannot use this teleport.', TALKTYPE_MONSTER_SAY, false, 0, fromPosition)
        player:teleportTo(fromPosition)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        position:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    local storages, s = {82001, 82002, 82003}, {}
    for i = 1, 3 do
        s[#s + 1] = player:getStorageValue(storages[i])
    end

    local teleportDestination = Position(s[1], s[2], s[3])
    player:teleportTo(teleportDestination)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    teleportDestination:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

data/talkactions/talkactions.xml
Code:
  <talkaction words="!set" script="custom/starlighttp.lua"/>

data/talkactions/scripts/starlighttp.lua

Code:
local storages = {82001, 82002, 82003}

function onSay(cid, words, param)
     local player = Player(cid)
     local pos = player:getPosition()
     local p = {pos.x, pos.y, pos.z}
     for x = 1, 3 do
         player:setStorageValue(storages[x], p[x])
     end
     player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Position set!")
     player:say('Your position has been set!', TALKTYPE_MONSTER_SAY)
     player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
     return false
end


BIG THANKS TOO
-Limos
- Helping me to start the script.
Followed all the steps bro and the talkaction works im also not getting any console erros but however when i use the starlight no portal will open up any ideas whats going on?
 
Last edited by a moderator:
Followed all the steps bro and the talkaction works im also not getting any console erros but however when i use the starlight no portal will open up any ideas whats going on?

Most likely you have the frozen starlight duplicated in your actions.xml. search for the item number and remove it from the yala quest ;)
 
Most likely you have the frozen starlight duplicated in your actions.xml. search for the item number and remove it from the yala quest ;)
yah i did bro but now i get error when i try to use the starlight and exaughstion error in console
 
yah i did bro but now i get error when i try to use the starlight and exaughstion error in console

Please post the error here, it will help anyone who wants to help you to figure out what the problem is, most likely you are missing a function from your lib, I am betting you are getting a "nil value" error for line 24?
 
Please post the error here, it will help anyone who wants to help you to figure out what the problem is, most likely you are missing a function from your lib, I am betting you are getting a "nil value" error for line 24?
im using tfs 1.1 and each time i try to use the starlight on the ground i get the error in game cannot use this item and then i get this error in console
mDeccf.png
 
Omg, still getting notifications from this board, getting old. Recopy your script from the original posted here and add this to the top of it


Code:
function Player.setExhaustion(self, value, time)
    return self:setStorageValue(value, time + os.time())
end

function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if storage <= 0 then
        return 0
    end

    return storage - os.time()
end
 
Omg, still getting notifications from this board, getting old. Recopy your script from the original posted here and add this to the top of it


Code:
function Player.setExhaustion(self, value, time)
    return self:setStorageValue(value, time + os.time())
end

function Player.getExhaustion(self, value)
    local storage = self:getStorageValue(value)
    if storage <= 0 then
        return 0
    end

    return storage - os.time()
end
ty bro this fix'd it thanksa lot guys :)
 
I try to use wand, i even added the function above and does not spawn teleport :>

k99uD9m.png


also there is no errors
 
So....Did you set your position like it says by saying !set?
 
Back
Top