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

Need help with one of my MODS. I think its easy for some of you :)

ohman

Member
Joined
Oct 24, 2008
Messages
294
Reaction score
8
Location
Sweden
Hey guys! Im trying to setup my Areahunting MOD.

I want a TP out from the room so players can exit whenever they want. But the script kicks out the player automaticly after x minutes. If players leave the room with my tp and walk away they will be tp'ed back outside the room when the "kick-time" has come to an end. So I want the tp to stop the "kick-event".


Here is the script:
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 = 33134, y = 32969, z = 6}, {x = 33134, y = 32969, z = 6}, {x = 33134, y = 32976, z = 6}, 1, 8, 4, 4},
    [10002] = {{x = 1026, y = 1020, z = 7}, {x = 1027, y = 1018, z = 7}, {x = 1027, y = 1023, z = 7}, 1, 8, 2, 2}
}
monsters = {
    -- Tile AID = b[1], b[2] ;]
    [17001] = {"Dragon Lord", {x = 33134, y = 32969, z = 6}},
    [10202] = {"Frost Dragon", {x = 1029, y = 1020, 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>
<movevent type="StepIn" actionid="10001-10002" 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, 2157) > 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, 2157, 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 enought golden nugget.", 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-10102" 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="17001-17002" 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, 10)
            doSummonCreature(b[1], b[2])
        doSendMagicEffect(b[2], CONST_ME_TELEPORT)
    end
end]]></movevent>
</mod>

I tried to do something like this and put it after the last </movement> but I got an error when I started the server.
Code:
<movevent type="StepIn" actionid="18001-18002" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
 doCreatureSetStorage(cid, 654321, -1)
        stopEvent(pauseKick)
end]]></movevent>


I hope you guys can do it better than me! Thanks :)
 
Back
Top