• 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 0.X BUG action script tfs 0.4

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hi guys, how are u?
I use tfs 0.4, tibia 8.6 and have this action script...
when using the lever, all members of the party are teleported to a new position.
All must be level 100 or higher, otherwise you can not teleport anyone..
it is there that the error happens, it is teleporting those who have a level superior to 100 and not teleporting that is level inferior to 100
the correct one is: if there is any player level lower than 100 in the party, NONE should be teleported, I do not know where I went wrong, thank you!

Code:
function onUse(cid, item, frompos, item2, topos)
        local partyList = getPartyMembers(getPartyLeader(cid))

        if #partyList == 4 then
                for _, party in ipairs(getPartyMembers(cid)) do
                    if getPlayerLevel(party) < 100 then
                        doPlayerSendTextMessage(party, MESSAGE_INFO_DESCR, "All party member need do be at lvl 100.")
                    else
                        doTeleportThing(party, {x= 84, y= 212, z= 6})
                        doPlayerSendTextMessage(party, MESSAGE_INFO_DESCR, "Your team has been teleported by "..getCreatureName(cid)..".")
                    end
                end
        end
          return TRUE
end
 
Solution
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local count = 0
    for _, pid in pairs(getPartyMembers(cid)) do
        if getPlayerLevel(pid) < 100 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "All party member need do be level 100 or above to enter here.")
            return true
        end
        count = count + 1
    end
    if count ~= 4 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only parties of four may enter here.")
        return true
    end
    for _, pid in pairs(getPartyMembers(cid)) do
        doTeleportThing(pid, {x= 84, y= 212, z= 6})
    end
    return true
end
try this
Code:
 function onUse(cid, item, fromPosition, itemEx, toPosition)
  members = getPartyMembers(party)
  party = getPlayerParty(cid)
          if (party == cid) and getPlayerLevel(cid) > 100  then
          for i=1,#members do
           doTeleportThing(members[i], {x= 84, y= 212, z= 6})
           end
            else
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "All party member need do be at lvl 100.")
          
end
    return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local count = 0
    for _, pid in pairs(getPartyMembers(cid)) do
        if getPlayerLevel(pid) < 100 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "All party member need do be level 100 or above to enter here.")
            return true
        end
        count = count + 1
    end
    if count ~= 4 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only parties of four may enter here.")
        return true
    end
    for _, pid in pairs(getPartyMembers(cid)) do
        doTeleportThing(pid, {x= 84, y= 212, z= 6})
    end
    return true
end
 
Solution
or this way also
Lua:
local memberCount = 4
local teleportPos = { x = 84, y = 212, z = 6 }
local requiredlevel = 100

function onUse(cid, item, frompos, target, topos)
    local partyMembers = getPartyMembers(getPlayerParty(cid))
    if partyMembers and #partyMembers == memberCount then
        local partners = {}
        for _, member in pairs(partyMembers) do
            if getPlayerLevel(member) >= requiredlevel then
                partners[#partners+1] = member
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "All party member need do be at lvl 100.")
                return false
            end
        end
        for _, partner in pairs(partners) do
            doTeleportThing(partner, teleportPos)
            doPlayerSendTextMessage(partner, MESSAGE_INFO_DESCR, "Your team has been teleported by " .. getCreatureName(cid) .. ".")
        end
        return true
    end
    return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only parties of four may enter here.")
end
 
Back
Top