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

Action script doubt tfs 1.1

Xarly

Member
Joined
Mar 9, 2015
Messages
360
Reaction score
20
Hello guys well i want to make a script for when i use example silver prison key in one Iditem the player get teleported sto a position so use silver prison key on the item with id 22607 and player get teleported to a x position and the item break how i can make it? im using tfs 1.1 thanks guys!
 
You are supposed to compare 2 positions, like in that link, now you added 1 position into the other position, player:getPosition() already gets a position, the position of the player, this should not be changed or things added to it.
 
You are supposed to compare 2 positions, like in that link, now you added 1 position into the other position, player:getPosition() already gets a position, the position of the player, this should not be changed or things added to it.
sorry my english its bad xD so if i only want to use the key when player its on the position 33603, 32394, 11 only when player its on correct position can use if its on another position i want can't use the key what i need do then?
 
Last edited:
Code:
if comparePos(player:getPosition(), Position(33603, 32394, 11)) then
got that
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if comparePos(player:getPosition(), Position(33603, 32394, 11)) then
end
if target.itemid == 22634 then
item:remove(22634)
player:teleportTo(Position(33574, 32414, 12), false)
end
return true
end

but still can using key from any sqm >.<
 
The end should be under the rest. An if statement works like this.
Code:
-- what is added here is outside the "if statement", so it doesn't matter if that "if statement" is added or not, it would be the same as if it wasn't there
if ... then
     -- this will only happen if the "if statement" is true
end
-- what is added here is outside the "if statement", so it doesn't matter if that "if statement" is added or not, it would be the same as if it wasn't there
 
The end should be under the rest. An if statement works like this.
Code:
-- what is added here is outside the "if statement", so it doesn't matter if that "if statement" is added or not, it would be the same as if it wasn't there
if ... then
     -- this will only happen if the "if statement" is true
end
-- what is added here is outside the "if statement", so it doesn't matter if that "if statement" is added or not, it would be the same as if it wasn't there
Okey bro! finally haha thank you so much
 
Better? :p
Code:
if .. then
     -- add code here
end
-- not add code here, if no effect here
One question bro!, if i now want like anihilathor but with the same method, so 5 Spots 5 players on x position for use the x key on the x item how i can add it?
 
Better? :p
Code:
if .. then
     -- add code here
end
-- not add code here, if no effect here
if u can limos let me something when u can please^^ for try to make the same method but the players need to stay 5 players on 5 positions for use the key thanks bro
 
First you need to declare this positions alright??
Code:
local config = {
playerPositions = {
        Position(1, 2, 3),
        Position(4, 5, 6),
        Position(7, 8, 9),
        Position(10, 11, 12),
        Position(13, 14, 15)
    }
}

Second you need to verify this:
Code:
for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
                return true
            end
 
First you need to declare this positions alright??
Code:
local config = {
playerPositions = {
        Position(1, 2, 3),
        Position(4, 5, 6),
        Position(7, 8, 9),
        Position(10, 11, 12),
        Position(13, 14, 15)
    }
}

Second you need to verify this:
Code:
for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
                return true
            end
oeky mate i try in one moment and i let you know^^
 
First you need to declare this positions alright??
Code:
local config = {
playerPositions = {
        Position(1, 2, 3),
        Position(4, 5, 6),
        Position(7, 8, 9),
        Position(10, 11, 12),
        Position(13, 14, 15)
    }
}

Second you need to verify this:
Code:
for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
                return true
            end
well bro tried ur script but the players can teleport aniway if only 1 player its on the sqm >.< without 5
 
First you need to declare this positions alright??
Code:
local config = {
playerPositions = {
        Position(1, 2, 3),
        Position(4, 5, 6),
        Position(7, 8, 9),
        Position(10, 11, 12),
        Position(13, 14, 15)
    }
}

Second you need to verify this:
Code:
for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
                return true
            end
okey now its working bro the only problem its if i use the key, the key break xDD aniway if no are 5 players on the spots so how i can solve it so ineed a function for key don't break if not 5 players @Limos could you help me limos? for a function not remove item if not 5 players on the spots?
i tried adding too the problem its only 1 players its teleported not the 5 :S
for i = 1, #config.playerPositions do
playerTile = Tile(config.playerPositions):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
else
if not playerTile or not playerTile:isPlayer() then
not item:remove(22607)
return true
end

but not work >.<

that the full code but still removing keys without players or without positions

local config = {
playerPositions = {
Position(33607, 32362, 11),
Position(33608, 32362, 11),
Position(33609, 32362, 11),
Position(33610, 32362, 11),
Position(33611, 32362, 11)
},
newPositions = {
Position(33222, 31659, 13),
Position(33221, 31659, 13),
Position(33220, 31659, 13),
Position(33219, 31659, 13)
},
demonPositions = {
Position(33219, 31657, 13),
Position(33221, 31657, 13),
Position(33223, 31659, 13),
Position(33224, 31659, 13),
Position(33220, 31661, 13),
Position(33222, 31661, 13)
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.itemid == 22641 then
item:remove(22607)
for i = 1, #config.playerPositions do
playerTile = Tile(config.playerPositions):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 5 players.")
return true
end
end
player:teleportTo(Position(33533, 32414, 12), false)
end
return true
end
 
Last edited:
Back
Top