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

Lua TFS 0.4 | Huntarena with choice

Hernest

New Member
Joined
Jul 26, 2010
Messages
152
Reaction score
3
Location
poland
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="HuntArea System" version="Tested only on 0.4" author="Hugq" contact="[email protected]" enabled="yes">
<config name="HuntAreaFunctions"><![CDATA[
config = {
    -- Teleport AID = v[1], v[2], v[3], v[4], v[5], v[6], v[7] ;]
    [10001] = {{x = 2406, y = 987, z = 7}, {x = 2406, y = 984, z = 7}, {x = 2400, y = 984, z = 6}, 15, 800, 4, 4},
    [10002] = {{x = 2406, y = 1006, z = 7}, {x = 2406, y = 1003, z = 7}, {x = 2400, y = 1003, z = 6}, 15, 800, 4, 4},
    [10003] = {{x = 2406, y = 1025, z = 7}, {x = 2406, y = 1022, z = 7}, {x = 2400, y = 1022, z = 6}, 15, 800, 4, 4},
    [10004] = {{x = 2426, y = 1006, z = 7}, {x = 2426, y = 1003, z = 7}, {x = 2420, y = 1003, z = 6}, 15, 800, 4, 4}

}
monsters1 = {
    -- Tile AID = b[1], b[2] ;]
    [10201] = {"monster name", {x = 2406, y = 987, z = 7}},
    [10202] = {"monster name", {x = 2406, y = 1006, z = 7}},
    [10203] = {"monster name", {x = 2406, y = 1025, z = 7}},
    [10204] = {"monster name", {x = 2426, y = 1006, z = 7}}

}

function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
                if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end
    local creature = getTopCreature(position)
    if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
        if not(table.find(creaturesList, creature.uid)) then
            table.insert(creaturesList, creature.uid)
        end
    end
        return creaturesList
end
]]></config>
<talkaction words="/arena" hidden="no" event="script"><![CDATA[
function onSay(cid, words, param)
    monsterarena = param
    local aret = monsterarena
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)

    local m = {"pandora", "ice demon", "ice guard", "black hero", "gorlic", "grim"}
    if isInArray(m, monsterarena) then
    local aret = "husky"
        doCreatureSay(cid, monsterarena.." is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, "You choose: " .. aret .. ".", TALKTYPE_ORANGE_1)
    end
    
end
]]></talkaction>
<talkaction words="!testuje" hidden="yes" event="script"><![CDATA[
    function onSay(cid, words, param)
        local he = monsterarena
        doCreatureSay(cid, "".. he .. "", TALKTYPE_ORANGE_1)
    end
]]></talkaction>






<movevent type="StepIn" actionid="10001-10004" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
local v = config[item.actionid]
function kickEvent(cid, item, position, fromPosition)
    if (getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE) ~= 0 and getCreatureStorage(cid, 654321) > 0) then
            doTeleportThing(cid, v[3])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        doCreatureSay(cid, "You have been kicked out from hunting room.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
    end
end
    if getPlayerLevel(cid) >= v[5] then
        if(getPlayerItemCount(cid, 11230) > 0) then
        local players = getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE)
            if #players == 0 then
            local creatures = getCreaturesInRange(v[2], v[6], v[7], TRUE, FALSE)
                for i = 1, #creatures do
                    doRemoveCreature(creatures[i])
                end
                doSendMagicEffect(position, CONST_ME_TELEPORT)
                doTeleportThing(cid, v[1])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doPlayerRemoveItem(cid, 11230, 1)
                doCreatureSay(cid, "Now you have " .. v[4] .. " minutes for hunting monsters, else you will be kicked out.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
                pauseKick = addEvent(kickEvent, v[4] * 60 * 1000, cid)
                doCreatureSetStorage(cid, 654321, 1)
                return TRUE
            else
                doCreatureSay(cid, "There is someone else in the room.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
            end
        else
            doCreatureSay(cid, "You don't have enough ivory bones.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
        end
        else
            doCreatureSay(cid, "You must be at least level " .. v[5] .. " or higher to enter.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
    end
    doTeleportThing(cid, fromPosition)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    return TRUE
end
]]></movevent>
<movevent type="StepIn" actionid="10101-10104" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        stopEvent(pauseKick)
    end
end]]></movevent>
<movevent type="StepIn" actionid="10201-10204" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    local b = monsters[item.actionid]
    if(isPlayer(cid) and exhaustion.check(cid, item.actionid)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You should wait " .. exhaustion.get(cid, item.actionid) .. " seconds.")
    elseif (isPlayer(cid)) then
        exhaustion.set(cid, item.actionid, 0)
            doSummonCreature(b[1], b[2])
        doSendMagicEffect(b[2], CONST_ME_TELEPORT)
    end
end]]></movevent>
</mod>

Hello, i want to give players choice between monsters, for example /arena Demon.

Code from config:
Code:
monsters1 = {
    -- Tile AID = b[1], b[2] ;]
    [10201] = {"monster name", {x = 2406, y = 987, z = 7}},
    [10202] = {"monster name", {x = 2406, y = 1006, z = 7}},
    [10203] = {"monster name", {x = 2406, y = 1025, z = 7}},
    [10204] = {aret, {x = 2426, y = 1006, z = 7}} -- <-- did not work
}


and talkaction code:
Code:
function onSay(cid, words, param)
    monsterarena = param
    local aret = monsterarena
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)

    local m = {"pandora", "ice demon", "ice guard", "black hero", "gorlic", "grim"}
    if isInArray(m, monsterarena) then
    local aret = "husky"
        doCreatureSay(cid, monsterarena.." is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, "You choose: " .. aret .. ".", TALKTYPE_ORANGE_1)
    end
   
end

any ideas how to fix it?
It is hunting arena created by hugg.

Just summoning monsters did not work, invalid value

Code:
<movevent type="StepIn" actionid="10201-10204" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    local b = monsters[item.actionid]
    if(isPlayer(cid) and exhaustion.check(cid, item.actionid)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You should wait " .. exhaustion.get(cid, item.actionid) .. " seconds.")
    elseif (isPlayer(cid)) then
        exhaustion.set(cid, item.actionid, 0)
            doSummonCreature(b[1], b[2])
        doSendMagicEffect(b[2], CONST_ME_TELEPORT)
    end
end]]></movevent>
 
Last edited:
Code:
[21:13:09.598] [Error - MoveEvents Interface]
[21:13:09.598] domodlib('HuntAreaFunctions')
[21:13:09.598] function onStepIn(cid, item, position, fromPosition)
[21:13:09.598]     local b = monsters[item.actionid]
[21:13:09.598]     if(isPlayer(cid) and exhaustion.check(cid, item.actionid)) then
[21:13:09.598]         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You should wait " .. exhaustion.get(cid, item.actionid) .. " seconds.")
[21:13:09.598]     elseif (isPlayer(cid)) then
[21:13:09.598]         exhaustion.set(cid, item.actionid, 0)
[21:13:09.598]             doSummonCreature(b[1], b[2])
[21:13:09.598]         doSendMagicEffect(b[2], CONST_ME_TELEPORT)
[21:13:09.598]     end
[21:13:09.598] end:onStepIn
[21:13:09.598] Description:
[21:13:09.598] [string "LuaInterface::loadBuffer"]:3: attempt to index global 'monsters' (a nil value)
[21:13:09.598] stack traceback:
[21:13:09.598]  [string "LuaInterface::loadBuffer"]:3: in function <[string "LuaInterface::loadBuffer"]:2>

@Loney
@Limos


And how to create param in quote?
e.g
/arena Demon
local n = param
print(n) --> "Demon"
 
Last edited:
Back
Top