• 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 1.2 hunting room from old TFS

Verrine

Member
Joined
Mar 2, 2016
Messages
117
Reaction score
7
Hi
Im fighting with old script that doesnt want to work with TFS 1.2
here is script:
PHP:
function onStepIn(cid, item, pos, fromPosition)
   -- all credits for slave ots @ otland.net
   -- use the following AIDs
   -- for enter teleprot --> 55xx
   -- for exit teleprot --> 44xx
   -- for summon sqm --> 33xx
   --you can relocate this area valuis for empty storages
   local InRoom = 12345  -- for players only. keep the same in all scripts
   local Exhaust = 12346 -- for magic effects dont edit. keep the same for all scripts
   local onexit = 12347 -- when exit he maynot enter after 30 sec. keep it for all rooms
   local playerpos = getPlayerPosition(cid) -- player position for magic effects
   local onsummon = 12344  -- when player summon this makes exhauste
   local onsummontime = os.date("%S seconds", getPlayerStorageValue(cid, onsummon)  - os.time())  -- dont change
   local onexittime = os.date("%S seconds", getPlayerStorageValue(cid, onexit)  - os.time())  -- dont change
   --------------------------------------------------------------------------------------------------------------------
   -- all creadits to 7I7A and Admin Slave <$>
   local RoomID = 5501  --  55xx where xx = room id  for enter
   local ExitID =  4401  -- 44xx where xx = room id  for exit
   local SummonID =  3301  -- 33xx wher xx = room id for summon monster
   local reqcoins = 20 -- required coins to enter with id 6527
   local pos = {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}}  -- for each room
   local exitpos = {x=32463, y=32472, z=7}  -- for each room
   local startpos = {x=32463, y=32462, z=7}  -- for each room
   local monsterpos = {x=32469, y=32468, z=7}  --on blood  -- for each room
   local teleportpos = {x=32467, y=32472, z=7}  -- enter teleport for timer
   local monster = 'Demon'  -- monster name , dont remove ''
   local xtime = 600000  -- 1 minutes  milleseconds / huntting
   local duration = 600  -- 10 minutes for exhaust storage . seconds
   local mon = Game.createMonster(param, monster)
   local mons = getSpectators(pos.from, pos.to)  -- check numbers of creatures in room
   --local mons = getCreatureInRange(mon, pos.from, pos.to, count)
   --------------- end of configs -----------
   ------------------
   -- summond sqm aid 33xx
   if item.actionid == SummonID then
     if isPlayer(cid) then 
       if getGlobalStorageValue(RoomID) > 0 and player:getStorageValue(onexitInRoom) == RoomID and getPlayerStorageValue(cid, Exhaust) > os.time() then
         -- this means that player have hunt time, if he haven't he will be kicked out
         if (table.maxn(mons) >= 1) then
           doSendMagicEffect(playerpos, 2)
           doPlayerSendCancel(cid, 'sorry, you monster is already summoned.')
           doTeleportThing(cid, fromPosition)
           return true
         else
           if getPlayerStorageValue(cid, onsummon) > os.time() then
             doPlayerSendCancel(cid, ' you must wait ' .. onsummontime .. ' before summon another monster.')
             doSendMagicEffect(playerpos, 2)
             doTeleportThing(cid, fromPosition)
             return 1
           -- missing an end here? -- Xikini
         else
           doTeleportThing(cid, exitpos)
           setPlayerStorageValue(cid, onexit, os.time()+30)
           doSendMagicEffect(exitpos, 10)
           setGlobalStorageValue(RoomID, -1)
           setPlayerStorageValue(cid, InRoom, -1)
           return true
         end
       return true
       end
     end
   end -- extra end here? -- Xikini
end
-------------------------------- enter teleprot
   if item.actionid == RoomID then
     if not isPlayer(cid) then
       return 1
     end
     if player:getStorageValue(cid, onexit) > os.time() then
       doPlayerSendCancel(cid, 'you must wait ' .. onexittime .. ' .')
       doTeleportThing(cid, fromPosition)
       return 1
     end
     if getGlobalStorageValue(RoomID) < 0 and player:getStorageValue(onexitInRoom) < 0 then
       if doPlayerRemoveItem(cid,6527, reqcoins) == TRUE then
         doSendAnimatedText(playerpos, "welcome", 247)
         doPlayerSendTextMessage(cid, 25, 'you have 10 minutes of huntting!')
         setGlobalStorageValue(RoomID, 1)
         setPlayerStorageValue(cid, InRoom, RoomID)
         setPlayerStorageValue(cid, Exhaust, os.time() + duration)
         doTeleportThing(cid, startpos)
         doAreaClean(pos.from, pos.to) 
         return addEvent(
         function()
         if isPlayer(cid) and getGlobalStorageValue(RoomID) > 0 or player:getStorageValue(onexitInRoom) == RoomID then
           --setPlayerStorageValue(cid, onexit, os.time()+10)  --
           doTeleportThing(cid, exitpos)
           doPlayerSendTextMessage(cid, 25, 'times up!')
           setPlayerStorageValue(cid, InRoom, -1)
           setPlayerStorageValue(cid, Exhaust, 0)
           setPlayerStorageValue(cid, DoubleSpawn, -1)
           doSendMagicEffect(exitpos, 10)
           return setGlobalStorageValue(RoomID, -1)
           end end,               -- double end here? -- Xikini
           xtime, cid)--, RoomID) auto kicker
         else
           doPlayerSendCancel(cid, 'you dont have ' .. reqcoins .. ' game tokens!')
           doTeleportThing(cid, fromPosition)
           doSendMagicEffect(playerpos, 2)
           return 1
         end
       else
         doTeleportThing(cid, fromPosition)
         doSendMagicEffect(playerpos, 2)
         return doPlayerSendCancel(cid, 'Somebody is already in the room.')
       end
     return true
     end
     --------------------------
     --exit teleport aid = 44xx
     if item.actionid == ExitID then
       if isPlayer(cid) then 
         doTeleportThing(cid, exitpos)
         setPlayerStorageValue(cid, onexit, os.time()+30)
         doPlayerSendTextMessage(cid, 25, 'you went out!')
         setPlayerStorageValue(cid, Exhaust, -1)
         setPlayerStorageValue(cid, InRoom, -1)
         doSendMagicEffect(exitpos, 10)
         return setGlobalStorageValue(RoomID, -1)
       end
     return true
     end

   return true
end

what I got?
an error with local onsummontime = os.date("%S seconds", getPlayerStorageValue(cid, onsummon) - os.time()) -- dont change

Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/hunting.lua:onStepIn
data/movements/scripts/hunting.lua:13: attempt to perform arithmetic on a boolean value
stack traceback:
        [C]: in function '__sub'
        data/movements/scripts/hunting.lua:13: in function <data/movements/scripts/hunting.lua:1>

Im verry new in scripting tfs and I have many problems with it so please be clear.
I think its problem with this os.date but I dont know how to fix it ;< Can someone help me to fix it? or just fix that code if someone is good enough for that? ill be glad for help. Here is original post: https://otland.net/threads/amazing-hunting-room-much-features-in-1-script.180092/
 
also what server are you using? cus u were writin old tfs lua then new so wth
tfs 1.2 as I wrote in title ;]

Code:
remove()
You don't want to use creature as it applies to all things which are creatures.. e.g players, npc's etc, you should be more specific.

Use functionality like
Code:
isMovable()
isCorpse()
isMonster()
isSummon(cid)

When writing a script you need to take everything into consideration so you are left with few unexpected results :)

still does not work ;/ @StreamSide written something like this:

PHP:
local p = {
    from = {x=31994, y=32446, z=7},
    to = {x=31989, y=32444, z=7}
}

function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
        return true
    end
end

function onSay(cid, words, param)

    if words == "!cleanxx" then
   
    for x = p.from.x, p.to.x do
    cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, cid:getName() .. ' look' .. p.from.x .. ' and ' .. p.to.x)
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do
                local c = {x = x, y = y, z = z}
                if c:isMovable() or c:isCorpse() or c:isMonster() or c:isSummon(cid) then
                    c:remove()
                end
            end
        end
    end

end

    return true
end

Did it to talkaction for tests because its easier to check it
I written text message after for to check if this for running or smth and I dont even get 1 message so I think that "for" does not running
 
Last edited:
tfs 1.2 as I wrote in title ;]



still does not work ;/ @StreamSide written something like this:

PHP:
local p = {
    from = {x=31994, y=32446, z=7},
    to = {x=31989, y=32444, z=7}
}

function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
        return true
    end
end

function onSay(cid, words, param)

    if words == "!cleanxx" then
 
    for x = p.from.x, p.to.x do
    cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, cid:getName() .. ' look' .. p.from.x .. ' and ' .. p.to.x)
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do
                local c = {x = x, y = y, z = z}
                if c:isMovable() or c:isCorpse() or c:isMonster() or c:isSummon(cid) then
                    c:remove()
                end
            end
        end
    end

end

    return true
end

Did it to talkaction for tests because its easier to check it
I written text message after for to check if this for running or smth and I dont even get 1 message so I think that "for" does not running
take a look at this cant test today but gonna try
https://otland.net/threads/addevent-remove-created-item.222424/
also
https://github.com/orts/server/blob...events/scripts/worldchanges/yasir.lua#L44-L79
 
Ill try it
I need to remove same range of items at tifferent locations so i thought that I need to make smth like automatic AoE rune like desintegrate 9x9 sqm that automaticly cast in for example in start position

{3, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}

i need to clean same areas with different palces so it can be just for example startposition with smth like up and it would be ok it doesn't need to be so flexible at all

those topics I checked and have no idea how to do them they are spells like desintegrate but I dont know how to do that ;/
 
Last edited:
Ill try it
I need to remove same range of items at tifferent locations so i thought that I need to make smth like automatic AoE rune like desintegrate 9x9 sqm that automaticly cast in for example in start position

0x111111111
01111111111
0111111111

smth like that
isnt that funny when you dont even read or try to do by urself
 
isnt that funny when you dont even read or try to do by urself
trying that for 3 days, yeah I tried to do smth like fireball but on spell casts You chow position with crosshair there it wouldnt be shown by crosshair so I dont know how to put cordinates ;/

here is my other version does not show any errors but dont work also
Code:
local p = {
    from = {x=31994, y=32446, z=7},
    to = {x=31989, y=32444, z=7}
}

function onSay(cid, words, param)

    if words == "!cleanxx" then
    cleaning(p.from, p.to)

end

    return true
end

function cleaning(fromPos, toPos)

    for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do
                totalArea = {x=x, y=y, z=z}
                item = getTopVisibleThing()
                if not isPlayer(item.uid) then
                    item:remove()
                end
            end
        end
    end
    return true
end

now Im trying with table and to make it like spell
 
trying that for 3 days, yeah I tried to do smth like fireball but on spell casts You chow position with crosshair there it wouldnt be shown by crosshair so I dont know how to put cordinates ;/

here is my other version does not show any errors but dont work also
Code:
local p = {
    from = {x=31994, y=32446, z=7},
    to = {x=31989, y=32444, z=7}
}

function onSay(cid, words, param)

    if words == "!cleanxx" then
    cleaning(p.from, p.to)

end

    return true
end

function cleaning(fromPos, toPos)

    for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do
                totalArea = {x=x, y=y, z=z}
                item = getTopVisibleThing()
                if not isPlayer(item.uid) then
                    item:remove()
                end
            end
        end
    end
    return true
end

now Im trying with table and to make it like spell
what tfs are you using? u using item:remove thats a meta also i posted like 3 times how to iterate area why dont u try it?
 
what tfs are you using? u using item:remove thats a meta also i posted like 3 times how to iterate area why dont u try it?
Im using TFS 1.2
so just remove() would be ok? I repaired that code up (Codex posted it) but now i want to make function that will remove items, dead mobs from room
BTW tried with making it like desintegrate rune but server crashed ;/ Im new with this stuff
I did smth like you posted before also looking in threads posted there they using
trapItem2:remove()

so I guess trapItem2 is ID of item that needs to be deleted? damn I have no idea for this ;/ I made tons of this code versions and everytime its wrong without any errors in console and does not delete items

EDIT:

PHP:
 for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do

   
                c = {x=x, y=y, z=z}
                local position = c
                local tile = position:getTile()
                local object = tile and tile:getTopVisibleThing()
               
                    object:remove()
               
            end
        end
    end

with this here is an error:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/czysc.lua:onSay
data/talkactions/scripts/czysc.lua:18: attempt to call method 'getTile' (a nil value)
stack traceback:
        [C]: in function 'getTile'
        data/talkactions/scripts/czysc.lua:18: in function <data/talkactions/scripts/czysc.lua:7>

took smth from desintegrate rune
 
Last edited:
Im using TFS 1.2
so just remove() would be ok? I repaired that code up (Codex posted it) but now i want to make function that will remove items, dead mobs from room
BTW tried with making it like desintegrate rune but server crashed ;/ Im new with this stuff
I did smth like you posted before also looking in threads posted there they using
trapItem2:remove()

so I guess trapItem2 is ID of item that needs to be deleted? damn I have no idea for this ;/ I made tons of this code versions and everytime its wrong without any errors in console and does not delete items
try something like
Code:
local j = {
    [1] = {
        fromPosition = Position(33099, 32875, 7),
        toPosition = Position(33106, 32893, 7)
    },
    [2] = {
        fromPosition = Position(33099, 32875, 7),
        toPosition = Position(33106, 32893, 7)
    }
}

function onSay(cid, words, param)

    if words == "!cleanxx" then
        for i = 1, #j do
        local c = j[i]
            iterateArea(
                function(position)
                    local tile = Tile(position)
                    if tile then
                        local items = tile:getItems()
                        if items then
                            for i = 1, #items do
                                items[i]:remove()
                            end
                        end

                        local ground = tile:getGround()
                        if ground then
                            ground:remove()
                        end
                    end
                end,
                c.fromPosition,
                c.toPosition
            )
        end
        print("done")
    return false
end
 
try something like
Code:
local j = {
    [1] = {
        fromPosition = Position(33099, 32875, 7),
        toPosition = Position(33106, 32893, 7)
    },
    [2] = {
        fromPosition = Position(33099, 32875, 7),
        toPosition = Position(33106, 32893, 7)
    }
}

function onSay(cid, words, param)

    if words == "!cleanxx" then
        for i = 1, #j do
        local c = j[i]
            iterateArea(
                function(position)
                    local tile = Tile(position)
                    if tile then
                        local items = tile:getItems()
                        if items then
                            for i = 1, #items do
                                items[i]:remove()
                            end
                        end

                        local ground = tile:getGround()
                        if ground then
                            ground:remove()
                        end
                    end
                end,
                c.fromPosition,
                c.toPosition
            )
        end
        print("done")
    return false
end
It works! Just need to add if to specify items to remove but nice It deleted all the stuff
 
easy to do, wait me im smurfin at lol lmao
Code:
local j = {
[1] = {
  fromPosition = Position(31989, 32444, 7),
  toPosition = Position(31994, 32446, 7)
   }
}

   

function onSay(cid, words, param)

  if words == "!cleanxx" then
  for i = 1, #j do
  local c = j[i]
  iterateArea(
  function(position)
  local tile = Tile(position)
  if tile then
  local items = tile:getItems()
  if items then
  for i = 1, #items do
                 if items[i] then

                 while not isInArray(items[i].itemid)
                 and items[i]:getType():isMovable()
                 and items[i].uid > 65535
                 and items[i].actionid == 0
                 do
                 items[i]:remove()
       
                 end
     
  end
  end
             end

  --local ground = tile:getGround()
  -- if not ground then
  --  ground:remove()
  -- end
  end
  end,
  c.fromPosition,
  c.toPosition
  )
  end
  print("done")
     end
  return false
end
I did this for now and it delete items that I want ;]

only does not deleting creatures
 
Last edited:
Code:
local j = {
[1] = {
  fromPosition = Position(31989, 32444, 7),
  toPosition = Position(31994, 32446, 7)
   }
}

  

function onSay(cid, words, param)

  if words == "!cleanxx" then
  for i = 1, #j do
  local c = j[i]
  iterateArea(
  function(position)
  local tile = Tile(position)
  if tile then
  local items = tile:getItems()
  if items then
  for i = 1, #items do
                 if items[i] then

                 while not isInArray(items[i].itemid)
                 and items[i]:getType():isMovable()
                 and items[i].uid > 65535
                 and items[i].actionid == 0
                 do
                 items[i]:remove()
      
                 end
    
  end
  end
             end

  --local ground = tile:getGround()
  -- if not ground then
  --  ground:remove()
  -- end
  end
  end,
  c.fromPosition,
  c.toPosition
  )
  end
  print("done")
     end
  return false
end
I did this for now and it delete items that I want ;]

only does not deleting creatures
creatures? u mean monsters inside?
 
yup summons / monsters
try with something like

Code:
        local spectators, spectator = Game.getSpectators(Position(32566, 31406, 15), false, false, 7, 7)
        for i = 1, #spectators do
            spectator = spectators[i]
            if spectator:isMonster() then
                spectator:remove()
            end
        end
 
I think last question in here
Can I make this script for multiple rooms with different monsters?
I just dont want to mess in files with tons of scripts
 
just tell me what u want and what you have done, i will do it
Code:
local c = {
    --you can relocate this area valuis for empty storages
    InRoom = 12345,  -- for players only. keep the same in all scripts
    Exhaust = 12346, -- for magic effects dont edit. keep the same for all scripts
    onexit = 12347, -- when exit he may not enter after onexitTime sec. keep it for all rooms
    onexitTime = 30,
  --------------------------------------------------------------------------------------------------------------------
    -- all creadits to 7I7A and Admin Slave <$>

    reqcoins = 20, -- required coins to enter with id 6527
    -- not used
  
    xtime = 60000,  -- 1 minutes  milleseconds / huntting
    duration = 60,  -- 10 minutes for exhaust storage . seconds 600
    onsummon = 12344  -- when player summon this makes exhauste
}


local RoomID = {
[1] = 5501,
[2] = 5502

}  --  55xx where xx = room id  for enter
local ExitID = {
[1] = 4401,
[2] = 4402

}  -- 44xx where xx = room id  for exit

local SummonID = {
[1] = 6601,
[2] = 6602
}  -- 33xx wher xx = room id for summon monster
local position = {
[1] =     {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}},
[2] =     {from = {x=31972, y=32434, z=7}, to = {x=31980, y=32442, z=7}}
}  -- for each room
local exitpos = {
[1] = {x=31986, y=32444, z=7},
[2] = {x=31972, y=32444, z=7}
}
    -- for each room
local startpos = {
[1] = {x=31986, y=32434, z=7},
[2] = {x=32463, y=32462, z=7}
} -- for each room
local monsterpos = {
[1] = {x=31992, y=32440, z=7},
[2] = {x=31978, y=32440, z=7}
  
} --on blood  -- for each room

local creatureName = {
[1] = 'Rotworm',
[2] = 'Vampire'
}     -- monster name , dont remove ''

local  czysc = {
[1] = {
    fromPosition = Position(31989, 32444, 7),
    toPosition = Position(31994, 32446, 7)
    }
}

-- this will make sure the answer is positive
function subtract(a, b)
    return a < b and b - a or a - b
end

function intervals(value)
    --return os.date("%S", subtract(value, os.time()))
    return subtract(value, os.time())
end

-- change the definition of this function to suit your needs
-- getSpectatorsInArea(position, range[, onlyPlayers])
function getSpectatorsInArea(position, range, onlyPlayers)
    -- Game.getSpectators(centerPos, multifloor, onlyPlayers or false, minXrange, maxXrange, minYrange, maxYrange)
    return Game.getSpectators(position, false, onlyPlayers or true, range, range, range, range)
end

function reset(cid)
    local player = Player(cid)
    if player then
        if Game.getStorageValue(c.RoomID) > 0 or player:getStorageValue(c.onexitInRoom) == c.RoomID then
            player:setStorageValue(c.onexit, os.time() + c.onexitTime)
          
        --end
            player:teleportTo(c.exitpos)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'times up!')
            player:setStorageValue(c.InRoom, -1)
            player:setStorageValue(c.Exhaust, 0)
            -- not defined
            player:setStorageValue(DoubleSpawn, -1)
            --c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
            Game.setStorageValue(c.RoomID, -1)
        end
    end
    return true
end

function clean(fromPosition, toPosition)

        for i = 1, #j do
        local a = j[i]
            iterateArea(
                function(position)
                    local tile = Tile(position)
                    if tile then
                        local items = tile:getItems()
                        if items then
                            for i = 1, #items do
                                if items[i] then

                                while not isInArray(items[i].itemid)
                                and items[i]:getType():isMovable()
                                and items[i].uid > 65535
                                and items[i].actionid == 0
                                do
                                items[i]:remove()

                                end
                               
                            end
                        end
                        end
                    end
                end,
                a.fromPosition,
                a.toPosition
            )
        end
        print("done")

    return false
end


function onStepIn(player, item, position, fromPosition)
    fromPosition=c.exitpos
    local p = {}
    -- player position for magic effects
    p.effectPosition = player:getPosition()
    p.summonTime = intervals( player:getStorageValue(c.onsummon) )
    p.onExitTime = intervals( player:getStorageValue(c.onexit) )
    -- assign later
    --player:teleportTo((c.startpos))
    p.exHaust = player:getStorageValue(c.Exhaust)
    p.onExitInRoom = player:getStorageValue(c.onexitInRoom)
    -- global storage
    p.gSummonID = Game.getStorageValue(c.RoomID)
    -- summond sqm aid 33xx
  
  
    if not player:isPlayer() then
        return false
    else
    --pierwszy if, wykonuje sie podczas wejscia w tp do roomu
        if item.actionid == c.RoomID then
            --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,  tonumber(p.onExitTime) .. ' cant teleport. --tonumber(p.onExitTime')
            if p.onExitTime < c.onexitTime then
                player:sendCancelMessage('You must wait ' .. c.onexitTime - p.onExitTime .. '.')
                player:teleportTo(fromPosition)
                return true
            else
                if Game.getStorageValue(c.RoomID) < 0 then --czy ktos jest w roomie
                    if player:removeItem(6527, c.reqcoins) then --czy masz coiny
                        --doAreaClean(c.position.from, c.position.to)
                        player:teleportTo(c.startpos)
                      
                        player:say("Welcome", TALKTYPE_MONSTER_SAY)
                        p.monster = Game.createMonster(c.creatureName, c.monsterpos)
                        p.spectators = getSpectatorsInArea(p.monster:getPosition(), 7 )
                        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. ', you have 10 minutes of hunting!')
                        Game.setStorageValue(c.RoomID, 1)
                        player:setStorageValue(c.InRoom, c.RoomID)
                        player:setStorageValue(c.Exhaust, os.time() + c.duration)
                                -- not defined
                      
                        addEvent(reset, c.xtime, player:getId())
                    else --brak coinow
                        player:sendCancelMessage('you dont have ' .. c.reqcoins .. ' game tokens!')
                        player:teleportTo(fromPosition)
                        --p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                        return true
                    end
                else --room pelny
                    player:teleportTo(fromPosition)
                    --p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    player:sendCancelMessage('Somebody is already in the room.')
                    return true
                end
            end      
        end      
        --koniec pierwszego ifa

        --drugi if, wykonuje sie podczas wejscia na kratke do summonowania
        if item.actionid == c.SummonID then
            if Game.getStorageValue(c.RoomID) > 0 then
            --and p.onExitInRoom == c.RoomID and p.exHaust > os.time() then --ide o zaklad ze bedzie tu blad, 1 i 3 warunek wyjebio bledy
            -- do p trzeba bedzie dopisac gRoomId bo brakuje
                --if (table.maxn(p.spectators) >= 1) then --czy jest 1 lub wiecej mobow zespawnowanych
                    --p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    --player:sendCancelMessage('Sorry, ' .. c.creatureName .. ' has already been summoned.')
                    --player:teleportTo(fromPosition)
                    --return true
                --else
                --    if p.summonTime > os.time() then --jest mniej ale musisz czekac --btw kolejny blad
                    --    player:sendCancelMessage('You must wait ' .. p.summonTime .. ' before summon another ' .. c.creatureName .. '.')
                    --    p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    --     player:teleportTo(fromPosition)
                    --else
                          
                        --player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        --c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
                        --Game.setStorageValue(c.RoomID, -1)
                        --player:setStorageValue(c.InRoom, -1)
                        p.monster = Game.createMonster(c.creatureName, c.monsterpos)
                          
                    end
                return true
                end
            --end
        --end
        --koniec drugiego ifa

        --trzeci if, wykonuje sie gdy wchodzisz w tp do wyjscia
        if item.actionid == c.ExitID then
            --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,  c.ExitID .. ' cant teleport. c.ExitID')
            --if player:isPlayer() then
            player:teleportTo(c.exitpos)
            Game.setStorageValue(c.RoomID, -1)
            player:setStorageValue(c.onexit, os.time()) --mozliwe ze znowu blad
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You went out!')
            player:setStorageValue(c.Exhaust, -1)
            player:setStorageValue(c.InRoom, -1)
            c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
            Game.setStorageValue(c.RoomID, -1)
        end
        --koniec trzeciego ifa
    end



return true
end
thats my tries with some comments
I want to do this for multiple rooms
 

Similar threads

Back
Top