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

Solved onUse - teleport all players from arena

ligus

New Member
Joined
Apr 26, 2010
Messages
253
Reaction score
0
Hello, I want to make script which teleport all players from the arena after using item with UID.

There is my script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local tp = {
            {x = 2458, y = 3145, z = 14},
            {x = 2458, y = 3146, z = 14},
            {x = 2458, y = 3147, z = 14}           
}          

    if(item.uid == 4251) then
        for x = 1741, 1748 do
            for y = 2103, 2110 do
                local pos = {x = x, y = y, z = getCreaturePosition(cid).z}
                if(isPlayer(getTopCreature(pos).uid)) then         
                    local tpx = tp[math.random(#tp)]             
                    doTeleportThing(getTopCreature(pos).uid, tpx)
                    doSendMagicEffect(tpx, CONST_ME_TELEPORT)
                end
            end
        end            
    end

    return true
end

But it teleports only player who use this special UID, it should teleport all players from the arena. How can it be done?
 
Code:
local tp = {
     {x = 2458, y = 3145, z = 14},
     {x = 2458, y = 3146, z = 14},
     {x = 2458, y = 3147, z = 14}  
}  

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local players = {}
     if item.uid == 4251 then
         for x = 1741, 1748 do
             for y = 2103, 2110 do
                 local pid = getTopCreature({x = x, y = y, z = getCreaturePosition(cid).z}).uid
                 if isPlayer(pid) then  
                     table.insert(players, pid)
                 end
             end
         end  
         for x = 1, #players do  
             local tpx = tp[math.random(#tp)]  
             doTeleportThing(players[x], tpx)
             doSendMagicEffect(tpx, CONST_ME_TELEPORT)
         end
     end
     return true
end

Btw, doing this is not needed if you added the script with uniqueid 4251 in actions.xml (unless you are going to add more items to it with for example different uniqueids).
Code:
if item.uid == 4251 then
 
Thanks! :) I am trying also to change them outfits but I do not have idea why it does not work.

Code:
local conditionBl = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBl, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionBl, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})     

doAddCondition(players[x], conditionBl)


Error:
Code:
(LuaInterface::luaAddOutfitCondition) Condition not found

What's wrong?
 
Did you added the condition above function onUse?
Code:
local conditionBl = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBl, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(conditionBl, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
 
Code:
local teleportAreas = {
    Position(2458, 3145, 14),
        Position(2458, 3146, 14),
        Position(2458, 3147, 14)          
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local specs = Game.getSpectators(Player(cid):getPosition(), false, true, 20, 20, 20, 20)
    local randomTpAreas = teleportAreas[math.random(#teleportAreas)]
    for i = 1, #specs do
        specs[i]:teleportTo(randomTpAreas)
        randomTpAreas:sendMagicEffect(CONST_ME_TELEPORT)
    end

    return true
end
 
Code:
local teleportAreas = {
    Position(2458, 3145, 14),
        Position(2458, 3146, 14),
        Position(2458, 3147, 14)         
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local specs = Game.getSpectators(Player(cid):getPosition(), false, true, 20, 20, 20, 20)
    local randomTpAreas = teleportAreas[math.random(#teleportAreas)]
    for i = 1, #specs do
        specs[i]:teleportTo(randomTpAreas)
        randomTpAreas:sendMagicEffect(CONST_ME_TELEPORT)
    end

    return true
end

Thanks, that is what I needed
 
Back
Top