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

Help me with script Arena

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
eAkBZ9R.jpg





1- When using the lever and transport them to the other site what add a color, team purple and green.
2-Possible to add more sqms for players.

my progress help me!
Code:
    local black = {
    pos = {
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7}
  }

  outfit = {lookType = myOutfit.lookType, lookHead = 114, lookBody = 114, lookLegs = 114,   lookFeet = 114, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}

  gotoblack = {x = 1000, y = 1000, z = 7}

  }
 
  local white = {
    pos = {
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7},
    {x = 1000, y = 1000, z = 7}
  }

  outfit = {lookType = myOutfit.lookType, lookHead = 0, lookBody = 0, lookLegs = 0,     lookFeet = 0, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}

  goto = {x = 1000, y = 1000, z = 7}
  }
 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
      doBroadcastMessage("Se ha activado la arena PVP", MESSAGE_STATUS_WARNING)
      if isPlayer(cid) then
      if whiteteam then
      doTeleportThing(cid, white.goto, true)
      doCreatureChangeOutfit(pid, white.outfit)
      end
      if blackteam then
      doTeleportThing(cid, black.goto, true)
      doCreatureChangeOutfit(pid, black.outfit)
      end
      end
      end
 
Last edited by a moderator:
Found this on my hdd, mod made by me some time ago. Tell me if it works or not cause i'm not sure if it is.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="battle-arena" version="1.0" author="slawkens" contact="[email protected]" enabled="yes">
    <server>
        <engine id="0.4_SVN" />
    </server>
    <description><![CDATA[
        OK, so.. basically what have to be done on map
            - uniqueid: 10001 - lever used for start battle (like in annihilator)
            - uniqueid: 10002 - teleport/tile that can be used to escape arena (exit = same as death)
            - spots for each team + edit config section in this file
    ]]></description>
    <config name="battle-arena-config"><![CDATA[
        config = {
            arena = {
                fromPosition = {x = 2241, y = 1285, z = 9}, -- top left corner
                toPosition = {x = 2252, y = 1291, z = 9}, -- bottom right corner
                exitPosition = {x = 2239, y = 1288, z = 8} -- dead player will be teleported there
            },

            partyCheck = false, -- check if each team is in proper party? (true/false)

            -- reward, not implemented yet (more complicated thing)
            reward = {
                item = {2160, 1}
            },

            teams = 2,
            minMembers = 3,
            maxMembers = 15,

            -- (not implemented yet) max 5 minutes for a battle (so they won't block it)
            timeLimit = 5 * 60,

            outfits = {
                { -- team 1 (white)
                    lookHead = 0,
                    lookBody = 0,
                    lookLegs = 0,
                    lookFeet = 0
                },
                { -- team 2 (black)
                    lookHead = 114,
                    lookBody = 114,
                    lookLegs = 114,
                    lookFeet = 114
                }
            },

            positions = {
                { -- team 1
                    { -- starting position
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8}
                    },
                    { -- destination
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9}
                    }
                },
                { -- team 2
                    { -- starting position
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8},
                        {x = 2240, y = 1287, z = 8}
                    },
                    { -- destination
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9},
                        {x = 2243, y = 1288, z = 9}
                    }
                }
            },

            storages = {
                outfit = 501,
                reward = 502,
                counter = 503,
                members = 504
            }
        }
    ]]></config>

    <lib name="battle-arena-lib"><![CDATA[
        battleArena = {
            doTeleport = function(cid, position, poff)
                if(poff) then
                    doSendMagicEffect(getCreaturePos(cid), CONST_ME_POFF)
                end

                doTeleportThing(cid, position)
                doSendMagicEffect(position, CONST_ME_TELEPORT)
            end,

            doLeave = function(cid)
                doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
                doRemoveCondition(cid, CONDITION_INFIGHT)
                doPlayerSetPzLocked(cid, false)

                local restoreOutfit = getPlayerStorageValue(pid, config.storages.outfit)
                if(restoreOutfit ~= -1) then
                    doCreatureChangeOutfit(pid, table.unserialize(restoreOutfit))
                    setPlayerStorageValue(pid, config.storages.outfit, -1)
                end

                battleArena.doTeleport(cid, config.arena.exitPosition, false)
            end
        }
    ]]></lib>

    <action uniqueid="10001" event="script"><![CDATA[
        domodlib('battle-arena-config')
        domodlib('battle-arena-lib')
        local config = config

        function onUse(cid, item, fromPosition, itemEx, toPosition)
            if(item.itemid == 1946) then
                doTransformItem(item.uid, 1945)
                return true
            end

            --if(getStorage(config.storages.busy) == 1) then
            --    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There is already a battle, please wait.")
            --    return true
            --end

            local started, players = os.mtime(), {}
            for i, t in ipairs(config.positions) do
                players[i] = {}
                for _, pos in pairs(t[1]) do
                    local tmp = getTopCreature(pos).uid
                    if(tmp > 0 and isPlayer(tmp)) then
                        table.insert(players[i], tmp)
                    end
                end
            end

            local firstTeamMembers = table.maxn(players[1])
            if(members < config.minMembers or members > config.maxMembers) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Minimum fighters: " .. config.minMembers .. ", maximum: " .. config.maxMembers)
                return true
            end

            for _, t in ipairs(players) do
                local members = table.maxn(t)
                if(members ~= firstTeamMembers) then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more players for a battle.")
                    return true
                end
            end

            -- check if players are in the same party (each team have to be in the own separated party)
            if(config.partyCheck) then
                local party = {}
                for i = 1, config.teams do
                    party[i] = getPlayerParty(players[i][1])
                    if(not party[i]) then
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Everyone have to be in a party (each team own party).")
                        return true
                    end
                end

                for i, t in ipairs(players) do
                    for _, pid in ipairs(t) do
                        if(getPlayerParty(pid) ~= party[i]) then
                            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Everyone have to be in a party (each team own party).")
                            return true
                        end
                    end
                end
            end

            -- teleport everyone and change their outfits
            for i, t in pairs(players) do
                for _, pid in ipairs(t) do
                    local outfit = getCreatureOutfit(pid)
                    setPlayerStorageValue(pid, config.storages.outfit, table.serialize(outfit))
                    outfit.lookType = config.outfits[i].lookType and config.outfits[i].lookType or outfit.lookType
                    outfit.lookHead = config.outfits[i].lookHead and config.outfits[i].lookHead or outfit.lookHead
                    outfit.lookBody = config.outfits[i].lookBody and config.outfits[i].lookBody or outfit.lookBody
                    outfit.lookLegs = config.outfits[i].lookLegs and config.outfits[i].lookLegs or outfit.lookLegs
                    outfit.lookFeet = config.outfits[i].lookFeet and config.outfits[i].lookFeet or outfit.lookFeet
                    doCreatureChangeOutfit(pid, outfit)

                    battleArena.doTeleport(pid, config.positions[2][i])
                end
            end

            -- doSetStorage(config.storages.counter, table.maxn(players[1]))
            -- doSetStorage(config.storages.members, table.serialize(players))
            print('battle-arena: script executed in: ' .. (os.mtime() - started) .. 'ms')
            return true
        end
    ]]></action>

    <movevent type="StepIn" uniqueid="10002" event="script"><![CDATA[
        domodlib('battle-arena-config')
        domodlib('battle-arena-lib')
        local config = config

        function onStepIn(cid, item, position, fromPosition)
            battleArena.doLeave(cid)
            return true
        end
    ]]></movevent>

    <talkaction words="/reward" access="5"><![CDATA[
        domodlib('battle-arena-config')
        local status = getStorage(config.storages.reward)
        if(status == 1) then
            doSetStorage(config.storages.reward, status == 1 and - 1 or 1)
        end

        doPlayerSendCancel('Battle reward has been ' .. (status == 1 and 'disabled' or 'enabled'))
        _result = true
    ]]></talkaction>

    <event type="prepareDeath" name="battle-arena" event="script"><![CDATA[
        domodlib('battle-arena-config')
        domodlib('battle-arena-lib')
        local config = config

        function onPrepareDeath(cid, deathList)
            if(isInRange(getCreaturePosition(cid), config.arena.fromPosition, config.arena.toPosition)) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been killed by " .. getCreatureName(deathList[1]))
                battleArena.doLeave(cid, true)
                return false
            end

            return true
        end
    ]]></event>

    <event type="login" name="battle-arena-login" event="script"><![CDATA[
        domodlib('battle-arena-config')
        domodlib('battle-arena-lib')
        local config = config

        function onLogin(cid)
            if(getPlayerStorageValue(pid, config.storages.outfit) ~= -1) then
                battleArena.doLeave(cid)
            end

            registerCreatureEvent(cid, "battle-arena")
            return true
        end
    ]]></event>
</mod>
 
Back
Top