• 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/
 
Well, I can tell you what is wrong with that script, but maybe I won't be able to fix it.

This is the thePlayerStorageValue(cid, val) from tfs 1.2:
Code:
function getPlayerStorageValue(cid, key)
    local p = Player(cid)
    return p ~= nil and p:getStorageValue(key) or false
end

If the key does not exist it will return "false".

That line 13 is trying to add a number with false and that does not work.

For a quick fix you can change that piece of code up there to this one (in compat.lua):
Code:
function getPlayerStorageValue(cid, key)
    local p = Player(cid)
    return p ~= nil and p:getStorageValue(key) or 0
end
 
when I changed it now TP does not work but there is no error in here lol

EDITL:
Changed some functions and now this:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/hunting.lua:onStepIn
data/lib/compat/compat.lua:829: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/lib/compat/compat.lua:829: in function 'doTeleportThing'
        data/movements/scripts/hunting.lua:105: in function <data/movements/scripts/hunting.lua:1>
after entering at teleport
 
Last edited:
after change it standing on teleport is impossible and script does not show any errors also doesnt teleport me into the room :/

maybe os.time() return string not int ? then it needs to be changed into numbers?

thats what I have for now
PHP:
function onStepIn(player, item, position, 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 position = {from = {x=31986, y=32434, z=7}, to = {x=31994, y=32442, z=7}}  -- for each room
local exitpos = {x=31986, y=32444, z=7}           -- for each room
local startpos = {x=31986, y=32434, z=7}           -- for each room
local monsterpos = {x=31993, y=32441, z=7}  --on blood     -- for each room
local teleportpos = {x=31990, y=32444, 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(position.from, position.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 player:isPlayer() then 
     if Game.getStorageValue(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)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'sorry, you monster is already summoned.')
         player:teleportTo(fromPosition)
         doTeleportThing(cid, fromPosition)
         return true
         else
         if getPlayerStorageValue(cid, onsummon) > os.time() then
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ' you must wait ' .. onsummontime .. ' before summon another monster.')
           doSendMagicEffect(playerpos, 2)
           player:teleportTo(fromPosition)
           return 1
       
         
         else
           player:teleportTo(exitpos)
           setPlayerStorageValue(cid, onexit, os.time()+30)
           doSendMagicEffect(exitpos, 10)
           Game.setStorageValue(RoomID, -1)
           setPlayerStorageValue(cid, InRoom, -1)
           return true
         end
         return true
       end
     end

end
-------------------------------- enter teleprot
if item.actionid == RoomID then
   if not player:isPlayer() then
   return 1
end
if player:getStorageValue(onexit) > os.time() then

   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'you must wait ' .. onexittime .. ' .')

   player:teleportTo(fromPosition)
   return 1
end

if Game.getStorageValue(RoomID) < 0 and player:getStorageValue(onexitInRoom) < 0 then
   if player:removeItem(6527, reqcoins) then
     doSendAnimatedText(playerpos, "welcome", 247)
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'you have 10 minutes of huntting!')
     Game.setStorageValue(RoomID, 1)
     setPlayerStorageValue(cid, InRoom, RoomID)
     setPlayerStorageValue(cid, Exhaust, os.time() + duration)

     player:teleportTo(startpos)
     doAreaClean(position.from, position.to)     
     return addEvent(
     function()
       if player:isPlayer() and  Game.getStorageValue(RoomID) > 0 or player:getStorageValue(onexitInRoom) == RoomID then
         setPlayerStorageValue(cid, onexit, os.time()+10)     --
         player:teleportTo(exitpos)     
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'times up!')
         setPlayerStorageValue(cid, InRoom, -1)
         setPlayerStorageValue(cid, Exhaust, 0)
         setPlayerStorageValue(cid, DoubleSpawn, -1)
         doSendMagicEffect(exitpos, 10)
         return Game.setStorageValue(RoomID, -1)
  end
     end,
     xtime, cid)--, RoomID) auto kicker
   else
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'you dont have ' .. reqcoins .. ' game tokens!')
     player:teleportTo(fromPosition)
     doSendMagicEffect(playerpos, 2)
     return 1
   end
else
   player:teleportTo(fromPosition) 
   doSendMagicEffect(playerpos, 2)
  return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Somebody is already in the room.')
end
return true
end
--------------------------
--exit teleport aid = 44xx
if item.actionid == ExitID then
   if player:isPlayer() then 
     player:teleportTo(exitpos)
     setPlayerStorageValue(cid, onexit, os.time()+30)
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'you went out!')
     setPlayerStorageValue(cid, Exhaust, -1)
     setPlayerStorageValue(cid, InRoom, -1)
     doSendMagicEffect(exitpos, 10)
     return Game.setStorageValue(RoomID, -1)
   end
   return true
end

return true
end
end
 
Last edited:
I just updated the code to 1.2 and commented out things that were not used, I added some functionality to the script, however i did not test it or shorten it up.

Have fun playing with or adjusting 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 <$>
    RoomID = 5501,  --  55xx where xx = room id  for enter
    ExitID = 4401,  -- 44xx where xx = room id  for exit
    SummonID = 3301,  -- 33xx wher xx = room id for summon monster
    reqcoins = 20, -- required coins to enter with id 6527
    -- not used
    --pos = {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}},  -- for each room
    exitpos = {x=32463, y=32472, z=7},  -- for each room
    startpos = {x=32463, y=32462, z=7}, -- for each room
    monsterpos = {x=32469, y=32468, z=7},  --on blood  -- for each room
    -- not used
    --teleportpos = {x=32467, y=32472, z=7},  -- enter teleport for timer
    creatureName = 'Demon'  -- monster name , dont remove ''
    xtime = 600000,  -- 1 minutes  milleseconds / huntting
    duration = 600,  -- 10 minutes for exhaust storage . seconds
    onsummon = 12344  -- when player summon this makes exhauste
}

-- 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 seconds", 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)
            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 onStepIn(player, item, position, fromPosition)
    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) )

    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

    p.exHaust = player:getStorageValue(c.Exhaust)

    p.onExitInRoom = player:getStorageValue(c.onexitInRoom)

    -- global storage
    p.gRoomID = Game.getStorageValue(c.RoomID)

    -- summond sqm aid 33xx
    if item.actionid == c.SummonID then
        if player:isPlayer() then
            if p.gRoomID > 0 and p.onExitInRoom == c.RoomID and p.exHaust > os.time() then
                if (table.maxn(p.spectators) >= 1) then
                    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
                        player:sendCancelMessage('You must wait ' .. p.summonTime .. ' before summon another ' .. c.creatureName .. '.')
                        p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                        player:teleportTo(fromPosition)
                    else
                        player:teleportTo(c.exitpos)
                        player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
                        Game.setStorageValue(c.RoomID, -1)
                        player:setStorageValue(c.InRoom, -1)
                    end
                    return true
                end
            end
            if item.actionid == c.RoomID then
                if not player:isPlayer() then
                    return true
                end
                if p.onExitTime > os.time() then
                    player:sendCancelMessage('You must wait ' .. p.onExitTime .. '.')
                    player:teleportTo(fromPosition)
                    return true
                end
                if p.gRoomID < 0 and p.onExitInRoom < 0 then
                    if player:removeItem(6527, c.reqcoins) then
                        player:say("Welcome", TALKTYPE_MONSTER_SAY)
                        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. ', you have 10 minutes of huntting!')
                        Game.setStorageValue(c.RoomID, 1)
                        player:setStorageValue(c.InRoom, c.RoomID)
                        player:setStorageValue(c.Exhaust, os.time() + c.duration)
                        player:teleportTo(c.startpos)
                        -- not defined
                        --doAreaClean(pos.from, pos.to)
                        addEvent(reset, c.xtime, player:getId())
                    else
                        player:sendCancelMessage('you dont have ' .. c.reqcoins .. ' game tokens!')
                        player:teleportTo(fromPosition)
                        p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    end
                    return true
                else
                    player:teleportTo(fromPosition)
                    p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    player:sendCancelMessage('Somebody is already in the room.')
                    return true
                end

                if item.actionid == c.ExitID then
                    if player:isPlayer() then
                        player:teleportTo(c.exitpos)
                        player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        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
                end
            end
        end
    end
    return true
end
 
Last edited:
I just updated the code to 1.2 and commented out things that were not used, I added some functionality to the script, however i did not test it or shorten it up.

Have fun playing with or adjusting 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 <$>
    RoomID = 5501,  --  55xx where xx = room id  for enter
    ExitID = 4401,  -- 44xx where xx = room id  for exit
    SummonID = 3301,  -- 33xx wher xx = room id for summon monster
    reqcoins = 20, -- required coins to enter with id 6527
    -- not used
    --pos = {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}},  -- for each room
    exitpos = {x=32463, y=32472, z=7},  -- for each room
    startpos = {x=32463, y=32462, z=7}, -- for each room
    monsterpos = {x=32469, y=32468, z=7},  --on blood  -- for each room
    -- not used
    --teleportpos = {x=32467, y=32472, z=7},  -- enter teleport for timer
    creatureName = 'Demon'  -- monster name , dont remove ''
    xtime = 600000,  -- 1 minutes  milleseconds / huntting
    duration = 600,  -- 10 minutes for exhaust storage . seconds
    onsummon = 12344  -- when player summon this makes exhauste
}

-- 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 seconds", 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)
            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 onStepIn(player, item, position, fromPosition)
    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) )

    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

    p.exHaust = player:getStorageValue(c.Exhaust)

    p.onExitInRoom = player:getStorageValue(c.onexitInRoom)

    -- global storage
    p.gRoomID = Game.getStorageValue(c.RoomID)

    -- summond sqm aid 33xx
    if item.actionid == c.SummonID then
        if player:isPlayer() then
            if p.gRoomID > 0 and p.onExitInRoom == c.RoomID and p.exHaust > os.time() then
                if (table.maxn(p.spectators) >= 1) then
                    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
                        player:sendCancelMessage('You must wait ' .. p.summonTime .. ' before summon another ' .. c.creatureName .. '.')
                        p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                        player:teleportTo(fromPosition)
                    else
                        player:teleportTo(c.exitpos)
                        player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
                        Game.setStorageValue(c.RoomID, -1)
                        player:setStorageValue(c.InRoom, -1)
                    end
                    return true
                end
            end
            if item.actionid == c.RoomID then
                if not player:isPlayer() then
                    return true
                end
                if p.onExitTime > os.time() then
                    player:sendCancelMessage('You must wait ' .. p.onExitTime .. '.')
                    player:teleportTo(fromPosition)
                    return true
                end
                if p.gRoomID < 0 and p.onExitInRoom < 0 then
                    if player:removeItem(6527, c.reqcoins) then
                        player:say("Welcome", TALKTYPE_MONSTER_SAY)
                        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. ', you have 10 minutes of huntting!')
                        Game.setStorageValue(c.RoomID, 1)
                        player:setStorageValue(c.InRoom, c.RoomID)
                        player:setStorageValue(c.Exhaust, os.time() + c.duration)
                        player:teleportTo(c.startpos)
                        -- not defined
                        --doAreaClean(pos.from, pos.to)
                        addEvent(reset, c.xtime, player:getId())
                    else
                        player:sendCancelMessage('you dont have ' .. c.reqcoins .. ' game tokens!')
                        player:teleportTo(fromPosition)
                        p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    end
                    return true
                else
                    player:teleportTo(fromPosition)
                    p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                    player:sendCancelMessage('Somebody is already in the room.')
                    return true
                end

                if item.actionid == c.ExitID then
                    if player:isPlayer() then
                        player:teleportTo(c.exitpos)
                        player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        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
                end
            end
        end
    end
    return true
end
-- not defined
--doAreaClean(pos.from, pos.to)
is defined in libs 050-functions.lua here it is :
PHP:
function getMonstersInRange(fromPosition, toPosition)
    local creatures = getCreaturesInRange(fromPosition, toPosition)
    local monsters = {}
    for _, creature in ipairs(creatures) do
        if(isMonster(creature)) then
            table.insert(monsters, creature)
        end
    end

    return monsters
end



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 doAreaClean(frompos, topos)
for x = frompos.x, topos.x do
    for y = frompos.y, topos.y do
        for z = frompos.z, topos.z do
    local p = {x=x,y=y,z=z}
     if isCleanAbleArea(p) or created_by_otswe == true then
        doCleanTile(p,false)
        end
      end
   end
   end
end

anyway
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/hunting.lua:onStepIn
data/movements/scripts/hunting.lua:71: attempt to index field 'monster' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/hunting.lua:71: in function <data/movements/scripts/hunting.lua:60>
i got this now but i guess its problem with spawn monster function?
Thanks for your reply :)
 
There is a clerical error where is says
Code:
creatureName = 'Demon'  -- monster name , dont remove ''
There should be a comma there
Code:
creatureName = 'Demon',  -- monster name , dont remove ''

Also where it says
Code:
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

You can change it to this to help trouble shoot the issue
Code:
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)
    -- breaking point emulation start
    if not p.monster then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, c.creatureName .. ' is not being created.')
        return false
    end
    -- breaking point emulation end
    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

Use either print or send a text message to the player to check if values are registering as expected, this is the easiest way to troubleshoot unexpected results.

Returning a value from the interface using the above mentioned is a way to emulate breaking points in your code, which allows you to isolate errors. :)
 
Last edited by a moderator:
Also where it says
Code:
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

You can change it to this to help trouble shoot the issue
Code:
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)
    -- breaking point emulation start
    if not p.monster then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, c.creatureName .. ' is not being created.')
        return false
    end
    -- breaking point emulation end
    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )

Use either print or send a text message to the player to check if values are registering as expected, this is the easiest way to troubleshoot unexpected results.

Returning a value from the interface using the above mentioned is a way to emulate breaking points in your code, which allows you to isolate errors. :)

I added this:
Code:
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea( p.monster:getPosition(), 7 )
    if p.monster then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, c.creatureName .. ' is not being created.')
        return false
    end

    p.exHaust = player:getStorageValue(c.Exhaust)
same error so I changed if not to actual if and same error Im standing at teleport - console shows me an error and nothing happens also wont teleport me ;/ Im looking for exapmle function of placing monster maybe here is the problem? (Im asking for this becouse sometimes many errors are showed by easy to fix mistakes)
checking positions again for arena now but with yours actual script where I can put arena position and how to make it work? this script should work with more than one arena thats why it is in tabs in config (sorry for my english but i guess you got my point?)
 
Please look at the example again, you placed the code in the wrong position.
This is why you are still getting the error.
Also make sure the flag in the monster file is set to 1, although I am not sure if this will make a difference :p
HTML:
<flag summonable="1" />
 
Please look at the example again, you placed the code in the wrong position.
This is why you are still getting the error.
Also make sure the flag in the monster file is set to 1, although I am not sure if this will make a difference :p
HTML:
<flag summonable="1" />
silly me
rotworm has been spawned but Im not moved inside arena (changed demon to rotworm because of flags as you said ;))
no console errors - trying to put your code to near teleport to check it
edited function :
Code:
function onStepIn(player, item, position, fromPosition)
    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) )
    player:teleportTo((c.startpos))
    if not c.startpos then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, c.startpos .. ' cant teleport.')
        return false
    end
    p.monster = Game.createMonster(c.creatureName, c.monsterpos)

Tfs crashes when I step in tp dont know why ;/ room looks like:
n50t3a.jpg

mb Im doing smth wrong
 
Last edited:
Here is a hint on testing.. always check the value before you pass it to a function.

So this code fragment
Code:
    player:teleportTo((c.startpos))
    if not c.startpos then
        -- this was probably crashing the server
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,  c.startpos .. ' cant teleport.')
        return false
    end
should be applied like this
Code:
    -- test 1st
    if not c.startpos then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ' start position cant teleport.')
        return false
    end
    -- assign later
    player:teleportTo((c.startpos))
On a final note, you can't attach tables to a string just by using the .. operator.

c.startpos is a table, it is defined outside of onStepIn interface, I am quite sure this is not your issue as the value is already defined.
 
I dont understand why but now after replacing my buggy code to yours I got teleported, monster has been spawned.
When I killed it I cant enter at spawn point to spawn next mob, when I try to step in to aID 3301 it shows me an error "17:07 The tile seems to be protected against unwanted intruders."

for me looks like there is no storage to make it work?
Added DoubleSpawn into 051-storages.lua

Okay edited some code (dont really know if its good) but now i have this:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/hunting.lua:onStepIn
data/movements/scripts/hunting.lua:118: attempt to compare number with string
stack traceback:
        [C]: in function '__lt'
        data/movements/scripts/hunting.lua:118: in function <data/movements/scripts/hunting.lua:62>

code:
PHP:
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 <$>
  RoomID = 5501,  --  55xx where xx = room id  for enter
  ExitID = 4401,  -- 44xx where xx = room id  for exit
  SummonID = 6601,  -- 33xx wher xx = room id for summon monster
  reqcoins = 20, -- required coins to enter with id 6527
  -- not used
  position = {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}},  -- for each room
  exitpos = {x=31986, y=32444, z=7},  -- for each room
  startpos = {x=31987, y=32434, z=7}, -- for each room
  monsterpos = {x=31992, y=32440, z=7},  --on blood  -- for each room
  -- not used
  --teleportpos = {x=32467, y=32472, z=7},  -- enter teleport for timer
  creatureName = 'Rotworm',  -- monster name , dont remove ''
  xtime = 600000,  -- 1 minutes  milleseconds / huntting
  duration = 600,  -- 10 minutes for exhaust storage . seconds
  onsummon = 12344  -- when player summon this makes exhauste
}

-- 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 seconds", 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 onStepIn(player, item, position, fromPosition)
  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.monster = Game.createMonster(c.creatureName, c.monsterpos)

  p.spectators = getSpectatorsInArea(p.monster:getPosition(), 7 )
   
   
  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 item.actionid == c.SummonID then

  if player:isPlayer() then
  if p.gRoomID > 0 and p.onExitInRoom == c.RoomID and p.exHaust > os.time() then
  if (table.maxn(p.spectators) >= 1) then
  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
  player:sendCancelMessage('You must wait ' .. p.summonTime .. ' before summon another ' .. c.creatureName .. '.')
  p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
  player:teleportTo(fromPosition)
  else
  player:teleportTo(c.exitpos)
  player:setStorageValue(c.onexit, os.time() + c.onexitTime)
  c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
  Game.setStorageValue(c.RoomID, -1)
  player:setStorageValue(c.InRoom, -1)
  end
  return true
  end
  end
     end
   end   
   
     
   if item.actionid == c.RoomID then
     if not player:isPlayer() then
       return false
     end
  if p.onExitTime > os.time() then
  player:sendCancelMessage('You must wait ' .. p.onExitTime .. '.')
  player:teleportTo(fromPosition)
  return true
  end
     if p.gRoomID < 1 and p.onExitInRoom < 1 then
       if player:removeItem(6527, c.reqcoins) then
         player:say("Welcome", TALKTYPE_MONSTER_SAY)
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. ', you have 10 minutes of huntting!')
         Game.setStorageValue(c.RoomID, 1)
         player:setStorageValue(c.InRoom, c.RoomID)
         player:setStorageValue(c.Exhaust, os.time() + c.duration)
         player:teleportTo((c.startpos))
  -- not defined
         doAreaClean(pos.from, pos.to)
         addEvent(reset, c.xtime, player:getId())
       else
         player:sendCancelMessage('you dont have ' .. c.reqcoins .. ' game tokens!')
         player:teleportTo(fromPosition)
         p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
         return true
       end
     end   
   
  else
  player:teleportTo(fromPosition)
  p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
  player:sendCancelMessage('Somebody is already in the room.')
  return true
  end

  if item.actionid == c.ExitID then
  if player:isPlayer() then
  player:teleportTo(c.exitpos)
  player:setStorageValue(c.onexit, os.time() + c.onexitTime)
  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
  end
--end

return true
end

I hope that Im not messed with it so bad, now it just shows me that
if p.onExitTime > os.time() then

is comparing string with numbers 0.o

next edit...
I see now that it does not make any sense what I've done
 
Last edited:
Now this code just spawn monster, wont teleport me and exit tp does not work also 3301 tile does not work, when I step Into it it teleports me back to fromposition and says that is protected against unwanted intruders ;/ dont really know what to do with this

also what to do with this function?
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

should I change range to numbers? but now it would check range from player or what? this is really hard to understand for me for now

PHP:
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 <$>
    RoomID = 5501,  --  55xx where xx = room id  for enter
    ExitID = 4401,  -- 44xx where xx = room id  for exit
    SummonID = 6601,  -- 33xx wher xx = room id for summon monster
    reqcoins = 20, -- required coins to enter with id 6527
    -- not used
    position = {from = {x=32463, y=32462, z=7}, to = {x=32471, y=32470, z=7}},  -- for each room
    exitpos = {x=31986, y=32444, z=7},  -- for each room
    startpos = {x=31987, y=32434, z=7}, -- for each room
    monsterpos = {x=31992, y=32440, z=7},  --on blood  -- for each room
    -- not used
    --teleportpos = {x=32467, y=32472, z=7},  -- enter teleport for timer
    creatureName = 'Rotworm',  -- monster name , dont remove ''
    xtime = 600000,  -- 1 minutes  milleseconds / huntting
    duration = 600,  -- 10 minutes for exhaust storage . seconds
    onsummon = 12344  -- when player summon this makes exhauste
}

-- 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 seconds", 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 onStepIn(player, item, position, fromPosition)
    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.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea(p.monster:getPosition(), 7 )
   
   
    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 item.actionid == c.SummonID then

        if player:isPlayer() then
            if p.gRoomID > 0 and p.onExitInRoom == c.RoomID and p.exHaust > os.time() then
                if (table.maxn(p.spectators) >= 1) then
                    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
                        player:sendCancelMessage('You must wait ' .. p.summonTime .. ' before summon another ' .. c.creatureName .. '.')
                        p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                        player:teleportTo(fromPosition)
                    else
                        player:teleportTo(c.exitpos)
                        player:setStorageValue(c.onexit, os.time() + c.onexitTime)
                        c.exitpos:sendMagicEffect(CONST_ME_HITAREA)
                        Game.setStorageValue(c.RoomID, -1)
                        player:setStorageValue(c.InRoom, -1)
                    end
                    return true
                end
            end
        end
    end   
       
       
    if item.actionid == c.RoomID then
        if not player:isPlayer() then
            return false
        end
       
       
        if p.onExitTime > os.time() then
            player:sendCancelMessage('You must wait ' .. p.onExitTime .. '.')
            player:teleportTo(fromPosition)
            return true
       
        elseif p.gRoomID < 1 and p.onExitInRoom < 1 then
            if player:removeItem(6527, c.reqcoins) then
                player:say("Welcome", TALKTYPE_MONSTER_SAY)
                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)
                player:teleportTo((c.startpos))
                        -- not defined
                doAreaClean(pos.from, pos.to)
                addEvent(reset, c.xtime, player:getId())
            else
                player:sendCancelMessage('you dont have ' .. c.reqcoins .. ' game tokens!')
                player:teleportTo(fromPosition)
                p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
                return true
            end
           
        --end
        else
            player:teleportTo(fromPosition)
            p.effectPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
            player:sendCancelMessage('Somebody is already in the room.')
            return true
    end
    end
--end   
    if item.actionid == c.ExitID then
        if player:isPlayer() then
            player:teleportTo(c.exitpos)
            Game.setStorageValue(c.RoomID, -1)
            player:setStorageValue(c.onexit, os.time() + c.onexitTime)
            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
    end
--end

return true
end
 
I didn't want to write/repair the script for you, I just updated the code so you could mess with it and get it working for a 1.2 server.
I really have no intention of resolving any issues regarding this script, Sorry.

It more than likely needs a complete re-write tho... anyhow best of luck :)
 
Got it ;]
just tell me if you can what should I do with this:
Code:
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

and how does it works:
Code:
 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.monster = Game.createMonster(c.creatureName, c.monsterpos)

    p.spectators = getSpectatorsInArea(p.monster:getPosition(), 7 )
   
   
    p.exHaust = player:getStorageValue(c.Exhaust)

    p.onExitInRoom = player:getStorageValue(c.onexitInRoom)

    -- global storage
    p.gSummonID = Game.getStorageValue(c.RoomID)

it shouldnt be in {} all the locals?
 
okay got this
anyway local p spawning monster when Im entering teleport that can't be done becouse if something is in room function cant teleport me so it does not work correctly, how can I spawn monster after just entering at 1 tile not in tp, when I remove p.monster from local p p.spectators wont work then
 
ok it works now just does not want to clean room and time features wont work as I want
I mean - I dont know how to store time int in players storage like:
someone enter room 2016/04/11 19:20:20 how to get it and save?
also how can I clean tile I have this function:

Code:
function doAreaClean(frompos, topos)
local tile = getTile()
local thing = tile:getTopVisibleThing(player)

 for x = frompos.x, topos.x do
   for y = frompos.y, topos.y do
     for z = frompos.z, topos.z do
   local p = {x=x,y=y,z=z}
  if isCleanAbleArea(p) then
    if thing == tile:getGround() then
    return false
    else
  if thing:isCreature() then
     thing:remove()

     end
   end
  end
  end
  end
  end
 end
What function can clean tiles?
 
Last edited:
ok it works now just does not want to clean room and time features wont work as I want
I mean - I dont know how to store time int in players storage like:
someone enter room 2016/04/11 19:20:20 how to get it and save?
also how can I clean tile I have this function:

Code:
function doAreaClean(frompos, topos)
local tile = getTile()
local thing = tile:getTopVisibleThing(player)

for x = frompos.x, topos.x do
   for y = frompos.y, topos.y do
     for z = frompos.z, topos.z do
   local p = {x=x,y=y,z=z}
  if isCleanAbleArea(p) then
    if thing == tile:getGround() then
    return false
    else
  if thing:isCreature() then
     thing:remove()

     end
   end
  end
  end
  end
  end
end
What function can clean tiles?
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 :)
 

Similar threads

Back
Top