• 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.X+ 1.2 Teleport players party

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hi, i need help to make one script.
This is a PvP area, players make team with 3 peoples (in party), and npc teleport all to this area (this script is OK).

I need in this PvP area, only one team can open a chest, when player try to open a chest, script need to check all players in this area, and check if all this players are in the same party and not have more players. So this players will be teleported to position (1000,1000,7)
1586398866910.png
 
In this place only be teleport one party team or two party teams?; for only one team to open the chest, u can save a globalStorage; I think you can do all of this in Actions -> onUse, use Spectators for range from item pos.

soo....

There is code not tested, need some rules like Add leader to party list, add partySize condition equals to inTeam > 3, validate the storage for use in event for only first party on taked the chest can teleport...

Remember i dont test the code i just made for you

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local newPos = {x = 1000, y = 1000, z = 7}
    local position = item:getPosition()
    local spectators = getSpectators(position, 6, 6, false, true)
    local inTeam = 0
    local party = player:getParty()
    local partySize = party:getMemberCount()
    local onTaken = 9999

    if getGlobalStorageValue(onTaken) == -1 then
        for _, spectator in ipairs(spectators) do
            if spectator:getParty() == party then
                inTeam = inTeam+1;
            end
        end

        if inTeam == 3 then
            for _, member in ipairs(party:getMembers()) do
                if Tile(member:getPosition()):hasFlag(TILESTATE_PVPZONE) then
                    doTeleportThing(member, newPos)
                    doSendMagicEffect(getPlayerPosition(member), CONST_ME_TELEPORT)
                end
            end
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Chest has been taken.")
    end
    
    return true
end
 
In this place only be teleport one party team or two party teams?; for only one team to open the chest, u can save a globalStorage; I think you can do all of this in Actions -> onUse, use Spectators for range from item pos.

soo....

There is code not tested, need some rules like Add leader to party list, add partySize condition equals to inTeam > 3, validate the storage for use in event for only first party on taked the chest can teleport...

Remember i dont test the code i just made for you

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local newPos = {x = 1000, y = 1000, z = 7}
    local position = item:getPosition()
    local spectators = getSpectators(position, 6, 6, false, true)
    local inTeam = 0
    local party = player:getParty()
    local partySize = party:getMemberCount()
    local onTaken = 9999

    if getGlobalStorageValue(onTaken) == -1 then
        for _, spectator in ipairs(spectators) do
            if spectator:getParty() == party then
                inTeam = inTeam+1;
            end
        end

        if inTeam == 3 then
            for _, member in ipairs(party:getMembers()) do
                if Tile(member:getPosition()):hasFlag(TILESTATE_PVPZONE) then
                    doTeleportThing(member, newPos)
                    doSendMagicEffect(getPlayerPosition(member), CONST_ME_TELEPORT)
                end
            end
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Chest has been taken.")
    end
   
    return true
end
dont work fine, its a area PVP, all players will battle (3x3), and the last players in the arena can open the chest....
exemple: i
if at the end there are only 2 players left in the party, the 2 will be teleported ... if there are 3 left, the 3 will be teleported.
but you can only open the chest after only one team left in the arena
 
Back
Top