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

Request stepIn check thing tfs 1.2

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi folks! I know this is the best topic title of 2016!!

I spent angry by creating a script that did not work.. So here I am.. I'm requesting a script that when the player stepIn will check if in position (1000, 1000, 7) and (1010, 1010, 7) have a item with id 2160 and 2162, if so, great, the player will be teletransported to a programmed place, if does not have the item ids on the positions then the player will get a random teleport between position (2000, 2000, 7) and (2020, 2020, 7).

Also I need this in table because will have more than 7 of this shit thing.

Thanks.
 
Hi folks! I know this is the best topic title of 2016!!

I spent angry by creating a script that did not work.. So here I am.. I'm requesting a script that when the player stepIn will check if in position (1000, 1000, 7) and (1010, 1010, 7) have a item with id 2160 and 2162, if so, great, the player will be teletransported to a programmed place, if does not have the item ids on the positions then the player will get a random teleport between position (2000, 2000, 7) and (2020, 2020, 7).

Also I need this in table because will have more than 7 of this shit thing.

Thanks.
Just to confirm..
If item x is on tile x and if item y is on tile y then
teleport player, remove items?
 
Just to confirm..
If item x is on tile x and if item y is on tile y then
teleport player, remove items?
I think he means he wants a table of positions and when you step on one of these, and if you're carrying itemid 2160/2162 or both? Then you are teleported somewhere and if not, then you are teleported randomly to some place
 
Well if nothing else, this is a really easy way to teleport them to a random location.. :p
Code:
randx = math.random(21)
randy = math.random(21)
doTeleportThing(cid, {x = randx + 1999, y = randy + 1999, z = 7}, true)
Once I get more clarification on how the script is meant to work, I'll create the script for 0.3.7, and you guys can then just convert any of the functions to 1.x
 
Just to confirm..
If item x is on tile x and if item y is on tile y then
teleport player, remove items?

Only teleport, does not remove the items.
I'll try explain with more details:

It is suppost to be in table, so, when the player stepIn will check if in position X and Y have itens with id 2160 and 2162..
If yes: awesome, will be teletransported to a programmed place.
If no: too bad, the player will get a random teleport and can go to position T or Q (not like you did @Xikini ).
 
Code:
local config = {
    [5000] = { -- action ID of the lever
        spot1 = {item = 2160, pos = Position(32365,32239,5)}, -- itemID and pos of spot 1
        spot2 = {item = 2162, pos = Position(32368,32239,5)}, -- itemID and pos of spot 2
        randomLocation = {Position(32358,32239,5), Position(32360,32241,5)}, -- randomLocation start and end
        failMessage = 'You were missing some items so random teleport for you! Life is tough.', -- message upon Failure (missing items from locations)
        successSpot = Position(32363,32244,5),
        successMessage = 'Success feels good yay yay yay!' -- message upon Success
    }
}

function onStepIn(creature, item, position, fromPosition)
    local lever = config[item.actionid]
    if not lever then
        return true
    end

    local item1,item2 = Tile(lever.spot1.pos):getItemById(lever.spot1.item), Tile(lever.spot2.pos):getItemById(lever.spot2.item)
   
    if not item1 or not item2 then
        local randomSpot = Position(math.random(lever.randomLocation[1].x, lever.randomLocation[2].x), math.random(lever.randomLocation[1].y, lever.randomLocation[2].y), lever.randomLocation[1].z)
        creature:teleportTo(randomSpot, false)
        creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, lever.failMessage)
    return true
    end
   
    creature:teleportTo(lever.successSpot, false)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, lever.successMessage)
    item1:remove(1)
    item2:remove(1)
return true
end
 
@imkingran
There is a way to check 7 items and other 3 items, etc.. Maybe add a loop on it, dunno!? It is to avoid use different files. Also, the randomSpot is suppost to be something like.

Code:
local randomSpots = {   
    Position(3999, 9999, 7),
    Position(4747, 4376, 7),
    Position(7432, 9324, 8)
}

creature:teleportTo(randomSpots[math.random(#randomSpots)])

Don't know if what I did above is correct.
 
@imkingran
There is a way to check 7 items and other 3 items, etc.. Maybe add a loop on it, dunno!? It is to avoid use different files. Also, the randomSpot is suppost to be something like.

Code:
local randomSpots = { 
    Position(3999, 9999, 7),
    Position(4747, 4376, 7),
    Position(7432, 9324, 8)
}

creature:teleportTo(randomSpots[math.random(#randomSpots)])

Don't know if what I did above is correct.

Code:
local config = {
    [5000] = { -- action ID of the tp
        spotsToCheck = {
            {pos = Position(32366,32237,5), item = 2148},
            {pos = Position(32368,32237,5), item = 2152},
            {pos = Position(32368,32239,5), item = 2392}
        },
        randomLocation = {
            Position(32358,32239,5),
            Position(32361,32241,5),
            Position(32360,32241,5)
        }, -- random Locations
        failMessage = 'You were missing some items so random teleport for you! Life is tough.', -- message upon Failure (missing items from locations)
        successSpot = Position(32363,32244,5),
        successMessage = 'Success feels good yay yay yay!' -- message upon Success
    },
    [5001] = {
        spotsToCheck = {
            {pos = Position(32366,32237,5), item = 2148},
            {pos = Position(32364,32234,5), item = 2152},
            {pos = Position(32362,32232,5), item = 2157},
            {pos = Position(32363,32231,5), item = 2160},
            {pos = Position(32368,32239,5), item = 2392}
        },
        randomLocation = {
            Position(32358,32239,5),
            Position(32361,32241,5),
            Position(32361,32241,5),
            Position(32361,32241,5),
            Position(32360,32241,5)
        },
        failMessage = 'You were missing some items so random teleport for you! Life is tough.',
        successSpot = Position(32363,32244,5),
        successMessage = 'Success feels good yay yay yay!'
    }
}

local function checkItems(tp)
    local allitems = true
    for i =1, #tp.spotsToCheck do
        local spot = tp.spotsToCheck[i]
        local tile = Tile(spot.pos)
        if not tile:getItemById(spot.item) then
            allitems = false
            break
        end
    end
    return allitems
end

local function removeItems(tp)
    for i =1, #tp.spotsToCheck do
        local spot = tp.spotsToCheck[i]
        local tile = Tile(spot.pos)
        local item = tile:getItemById(spot.item)
        if item then
            item:remove(1)
        end
    end
end

function onStepIn(creature, item, position, fromPosition)
    local tp = config[item.actionid]
    if not tp then
        return true
    end
   
    if not checkItems(tp) then
        creature:teleportTo(tp.randomLocation[math.random(#tp.randomLocation)], false)
        creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, tp.failMessage)
    return true
    end
   
    removeItems(tp)
    creature:teleportTo(tp.successSpot, false)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, tp.successMessage)
   
return true
end
 
Back
Top