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

Storage for Teleport

Repsor

New Member
Joined
May 26, 2022
Messages
10
Solutions
1
Reaction score
0
im a bit confused with my script :D

Lua:
local teleportToSoulfinal = MoveEvent()

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

    if player:getStorageValue(Storage.soulquest.goscr, 1)then
     player:getStorageValue(Storage.soulquest.gosgr, 1)
     player:getStorageValue(Storage.soulquest.gosha, 1)
     player:getStorageValue(Storage.soulquest.gosma, 1)
     player:getStorageValue(Storage.soulquest.gossp, 1)

        local destination = Position(33682, 31634, 14)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination)
        destination:sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:teleportTo(fromPosition)
        player:say('You need kill the other bosses too!', TALKTYPE_MONSTER_SAY)
    end
end

teleportToSoulfinal:type("stepin")
teleportToSoulfinal:aid(9992)
teleportToSoulfinal:register()

the goal is that someone can only enter the Teleport when he have all 5 Storages (killed bosses)

Some help would be nice :)

Canary 1.3.1 , 12.81
 
Solution
im a bit confused with my script :D

Lua:
local teleportToSoulfinal = MoveEvent()

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

    if player:getStorageValue(Storage.soulquest.goscr, 1)then
     player:getStorageValue(Storage.soulquest.gosgr, 1)
     player:getStorageValue(Storage.soulquest.gosha, 1)
     player:getStorageValue(Storage.soulquest.gosma, 1)
     player:getStorageValue(Storage.soulquest.gossp, 1)

        local destination = Position(33682, 31634, 14)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination)...
im a bit confused with my script :D

Lua:
local teleportToSoulfinal = MoveEvent()

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

    if player:getStorageValue(Storage.soulquest.goscr, 1)then
     player:getStorageValue(Storage.soulquest.gosgr, 1)
     player:getStorageValue(Storage.soulquest.gosha, 1)
     player:getStorageValue(Storage.soulquest.gosma, 1)
     player:getStorageValue(Storage.soulquest.gossp, 1)

        local destination = Position(33682, 31634, 14)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination)
        destination:sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:teleportTo(fromPosition)
        player:say('You need kill the other bosses too!', TALKTYPE_MONSTER_SAY)
    end
end

teleportToSoulfinal:type("stepin")
teleportToSoulfinal:aid(9992)
teleportToSoulfinal:register()

the goal is that someone can only enter the Teleport when he have all 5 Storages (killed bosses)

Some help would be nice :)

Canary 1.3.1 , 12.81

Lua:
local teleportToSoulfinal = MoveEvent()

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

    if player:getStorageValue(Storage.soulquest.goscr) == 1 and player:getStorageValue(Storage.soulquest.gosgr) == 1 and player:getStorageValue(Storage.soulquest.gosha) == 1 and player:getStorageValue(Storage.soulquest.gosma) == 1 and player:getStorageValue(Storage.soulquest.gossp) == 1 then
        local destination = Position(33682, 31634, 14)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination)
        destination:sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:teleportTo(fromPosition)
        player:say('You need kill the other bosses too!', TALKTYPE_MONSTER_SAY)
    end
end

teleportToSoulfinal:type("stepin")
teleportToSoulfinal:aid(9992)
teleportToSoulfinal:register()

you just need to put an "and" between each storage check and the function corrtly:
For check storage:
Lua:
"getStorageValue(Storage) == NUMBER"

For set storage:
Lua:
"setStorageValue(Storage, NUMBER)"

storage1 and storage2 and storage3 and storage4...

Post edit, sleep won me
 
Last edited:
Solution
You also don't need 5 seperate storages. You can use one storage.
Boss A sets storage value to 1 + old storage.
Boss B sets storage value to 10 + old storage.
Boss C sets storage value to 100 + old storage.
etc

Player with storage value equal to 11011 have killed Boss A, B, D and E.
To be able to pass trought teleport you need to have that storage value be equal to 11111.

Example:
Lua:
 if player:getStorageValue(Storage.soulquest) == 11111

If player kills boss C then script will check player's storage value, after that convert it to string and read third number:
Lua:
local str = tostring(player:getStorageValue(Storage.soulquest))
local bossNumber= 3
if string.sub(str, bossNumber, bossNumber) == "1" then
  --...player already did the 3rd boss
else
  player:setStorageValue(Storage.soulquest, player:getStorageValue(Storage.soulquest) + 10 ^ (bossNumber - 1))
end

With it, all kills can be done within one single lua file. And another one for teleport.

You should take care about optimalization. Having 50k accounts with 100k characters where each have 5 entries of your quest in database instead of just one is a extra waste of space on your server. Imagine if you have such nonoptimized 1k+ scripts.
 
Last edited:
Back
Top