• 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.3) Trying to get teleport to trainers to work..

skeira97

New Member
Joined
Dec 12, 2011
Messages
13
Reaction score
0
Hi!


Error i get
____________
[Warning - Event::checkScript] Can not load script: scripts/trainertp.lua
data/movements/scripts/trainertp.lua:4: '}' expected (to close '{' at line 3) near 'of'
[Warning - Event::checkScript] Can not load script: scripts/trainertp2.lua
data/movements/scripts/trainertp2.lua:4: 'do' expected near 'from'




i got in movements.xml

Code:
    <movevent event="StepIn" actionid="14876" script="trainerin.lua"/> 
    <movevent event="StepIn" actionid="14877" script="trainerout.lua"/>


and im working with this lua first for enter the teleport

Code:
local storage = 5845 
local config = { 
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, - position of the first pos ( row 1 column 1 ) 
    distX = 12, - distance in X between each room ( on the same row ) 
    distY = 12, - Y distance between each room ( from the same column ) 
    rX = 4, - number of columns 
    rY = 5 - number of lines
 }  
local function isBusyable ( position ) local player = Tile ( position ): getTopCreature () if player then if player : isPlayer () then return false end end 
     
    
         
             
        
    
    local tile = Tile ( position ) if not tile then return false end 
     
         
    
    local ground = tile : getGround () if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then return false end
      
         
    
    local items = tile : getItems () for i = 1 , tile : getItemCount () from local item = items [ i ] local itemType = item : getType () if itemType : getType () ~ = ITEM_TYPE_MAGICFIELD and not itemType : isMovable () and item : hasProperty (
      
        
        
           CONST_PROP_BLOCKSOLID ) then return false end end 
             
        
    
    return true end 

local function addTrainers ( position , arrayPos ) if not isBusyable ( position ) then for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if not trainer then local monster = Game . createMonster ( "Trainer" , arrayPos [ places 
      
          
             
             
                 ]) 
                monster : getPosition (): sendMagicEffect ( CONST_ME_MAGIC_BLUE ) end end end end
            
        
    

local function calculatingRoom ( uid , position , column , row ) local player = Player ( uid ) if column > = config . rX then 
        column = 0 
        line = line < ( config . rY - 1 ) and line + 1 or false end 
     
          
    
    if line then local room_pos = { x = position . x + ( column * config . DISTX ), y = position . y + ( line * config . distY ), z = position . z } if isBusyable ( room_pos ) then 
            player : teleportTo ( room_pos )
           
         
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT ) 
            addTrainers ( room_pos , {{ x = room_pos . x - 1 , y = room_pos . y + 1 , z = room_pos . z }, { x = room_pos . x + 1 , y = room_pos . y + 1 ,       z = room_pos . z }}) else 
            calculatingRoom ( uid , position , column + 1 , row ) end else 
        player : sendCancelMessage ( "Couldn't find any position for you right now." ) end end
         
        
    
    

function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
      
         
    
    if creature : getStorageValue ( storage ) - os . time () > 0 then 
        creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" ) 
        creature : teleportTo ( fromPosition , true ) return true end      
         
    
    calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 )  
    return true end


and when exit the trainers

Code:
local storage = 5845 
local function removeTrainers ( position ) local arrayPos = {{ x = position . x - 1 , y = position . y + 1 , z = position . z }, { x = position . x + 1 , y = position . y + 1 , z = position . 
           z }} for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if trainer then if trainer : isMonster () then 
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT ) 
                trainer : remove () end end end end
      
         
        
             
            
        
    
    
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
      
         
    
    removeTrainers ( fromPosition ) 
    creature : teleportTo ( creature : getTown (): getTemplePosition ()) 
    creature : setStorageValue ( storage , os . time () + 5 )  
    return true end



how do i get this code to work ? :/


thanks!
 
Hi!


Error i get
____________
[Warning - Event::checkScript] Can not load script: scripts/trainertp.lua
data/movements/scripts/trainertp.lua:4: '}' expected (to close '{' at line 3) near 'of'
[Warning - Event::checkScript] Can not load script: scripts/trainertp2.lua
data/movements/scripts/trainertp2.lua:4: 'do' expected near 'from'




i got in movements.xml

Code:
    <movevent event="StepIn" actionid="14876" script="trainerin.lua"/>
    <movevent event="StepIn" actionid="14877" script="trainerout.lua"/>


and im working with this lua first for enter the teleport

Code:
local storage = 5845
local config = {
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, - position of the first pos ( row 1 column 1 )
    distX = 12, - distance in X between each room ( on the same row )
    distY = 12, - Y distance between each room ( from the same column )
    rX = 4, - number of columns
    rY = 5 - number of lines
} 
local function isBusyable ( position ) local player = Tile ( position ): getTopCreature () if player then if player : isPlayer () then return false end end
    
   
        
            
       
   
    local tile = Tile ( position ) if not tile then return false end
    
        
   
    local ground = tile : getGround () if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then return false end
     
        
   
    local items = tile : getItems () for i = 1 , tile : getItemCount () from local item = items [ i ] local itemType = item : getType () if itemType : getType () ~ = ITEM_TYPE_MAGICFIELD and not itemType : isMovable () and item : hasProperty (
     
       
       
           CONST_PROP_BLOCKSOLID ) then return false end end
            
       
   
    return true end

local function addTrainers ( position , arrayPos ) if not isBusyable ( position ) then for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if not trainer then local monster = Game . createMonster ( "Trainer" , arrayPos [ places
     
         
            
            
                 ])
                monster : getPosition (): sendMagicEffect ( CONST_ME_MAGIC_BLUE ) end end end end
           
       
   

local function calculatingRoom ( uid , position , column , row ) local player = Player ( uid ) if column > = config . rX then
        column = 0
        line = line < ( config . rY - 1 ) and line + 1 or false end
    
         
   
    if line then local room_pos = { x = position . x + ( column * config . DISTX ), y = position . y + ( line * config . distY ), z = position . z } if isBusyable ( room_pos ) then
            player : teleportTo ( room_pos )
          
        
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
            addTrainers ( room_pos , {{ x = room_pos . x - 1 , y = room_pos . y + 1 , z = room_pos . z }, { x = room_pos . x + 1 , y = room_pos . y + 1 ,       z = room_pos . z }}) else
            calculatingRoom ( uid , position , column + 1 , row ) end else
        player : sendCancelMessage ( "Couldn't find any position for you right now." ) end end
        
       
   
   

function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
     
        
   
    if creature : getStorageValue ( storage ) - os . time () > 0 then
        creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
        creature : teleportTo ( fromPosition , true ) return true end     
        
   
    calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 ) 
    return true end


and when exit the trainers

Code:
local storage = 5845
local function removeTrainers ( position ) local arrayPos = {{ x = position . x - 1 , y = position . y + 1 , z = position . z }, { x = position . x + 1 , y = position . y + 1 , z = position .
           z }} for places = 1 , #arrayPos from local trainer = Tile ( arrayPos [ places ]): getTopCreature () if trainer then if trainer : isMonster () then
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
                trainer : remove () end end end end
     
        
       
            
           
       
   
   
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then return false end
     
        
   
    removeTrainers ( fromPosition )
    creature : teleportTo ( creature : getTown (): getTemplePosition ())
    creature : setStorageValue ( storage , os . time () + 5 ) 
    return true end



how do i get this code to work ? :/


thanks!
The indentation is all wrong. You have spaces and comments in wrong way... Fix the indentation and try run the code.
Exemple Line 3:
Lua:
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, - position of the first pos ( row 1 column 1 )
should be:
Lua:
 first_room_pos = { x = 1403 , y = 1252 , z = 7 }, -- position of the first pos ( row 1 column 1 )
Is missing a "-" to be a comment block.
 
I didn't change anything in the code. I just fixed the errors my editor threw at me. And made it a little more readable.

By just looking through the code, there are suntax errors left and right.
All your comments were "- comment here". This needs to be "-- comment here". In Lua, a comment in your code is either "--" for single line comments or "--[[ Comment
here ]]--" for multiline comments
All of your for loops had a "from" instead of a "do". All loops use "do" the same way if use "then".

Lua:
local storage = 5845
local config = {
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, -- position of the first pos ( row 1 column 1 )
    distX = 12, -- distance in X between each room ( on the same row )
    distY = 12, -- Y distance between each room ( from the same column )
    rX = 4, -- number of columns
    rY = 5 -- number of lines
 } 
local function isBusyable ( position ) local player = Tile ( position ): getTopCreature ()
    if player then
        if player : isPlayer () then
            return false
        end
    end
    
    local tile = Tile ( position ) if not tile then return false end
    local ground = tile : getGround () 
    if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false 
    end
    local items = tile:getItems ()
    for i = 1 , tile:getItemCount() do
        local item = items [ i ]
        local itemType = item : getType ()
    if itemType:getType () ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable () and item:hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
        end
    end
    
    return true
end
local function addTrainers ( position , arrayPos )
     if not isBusyable ( position ) then
         for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
         if not trainer then local monster = Game.createMonster ( "Trainer" , arrayPos [ places ])
                monster : getPosition():sendMagicEffect ( CONST_ME_MAGIC_BLUE )
            end
        end
    end
end
local function calculatingRoom ( uid , position , column , row ) 
    local player = Player( uid )
     if column >= config . rX then
        column = 0
        line = line < ( config . rY - 1 ) and line + 1 or false
    end
    
    if line then
        local room_pos = { x = position.x + ( column * config.DISTX ), y = position.y + ( line * config.distY ), z = position.z }
        if isBusyable ( room_pos ) then
            player : teleportTo ( room_pos )
        
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
            addTrainers ( room_pos , {{ x = room_pos.x - 1 , y = room_pos.y + 1 , z = room_pos.z }, { x = room_pos.x + 1 , y = room_pos.y + 1 , z = room_pos.z }}) else
            calculatingRoom ( uid , position , column + 1 , row )
        end
    else
        player : sendCancelMessage ( "Couldn't find any position for you right now." )
    end
end
function onStepIn ( creature , item , position , fromPosition )
    if not creature : isPlayer () then return false
    end
    if creature : getStorageValue ( storage ) - os . time () > 0 then
        creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
        creature : teleportTo ( fromPosition , true ) return true
    end     
        
    calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 ) 
    return true
 end
Lua:
local storage = 5845
local function removeTrainers ( position )
    local arrayPos = {{ x = position.x - 1 , y = position.y + 1 , z = position.z }, { x = position.x + 1 , y = position.y + 1 , z = position.z }}
           for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
            if trainer then
                if trainer : isMonster () then
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
                trainer : remove ()
            end
        end
    end
end
    
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then
    return false
end
      
    removeTrainers ( fromPosition )
    creature : teleportTo ( creature : getTown (): getTemplePosition ())
    creature : setStorageValue ( storage , os . time () + 5 ) 
    return true
end
 
I didn't change anything in the code. I just fixed the errors my editor threw at me. And made it a little more readable.

By just looking through the code, there are suntax errors left and right.
All your comments were "- comment here". This needs to be "-- comment here". In Lua, a comment in your code is either "--" for single line comments or "--[[ Comment
here ]]--" for multiline comments
All of your for loops had a "from" instead of a "do". All loops use "do" the same way if use "then".

Lua:
local storage = 5845
local config = {
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, -- position of the first pos ( row 1 column 1 )
    distX = 12, -- distance in X between each room ( on the same row )
    distY = 12, -- Y distance between each room ( from the same column )
    rX = 4, -- number of columns
    rY = 5 -- number of lines
}
local function isBusyable ( position ) local player = Tile ( position ): getTopCreature ()
    if player then
        if player : isPlayer () then
            return false
        end
    end
   
    local tile = Tile ( position ) if not tile then return false end
    local ground = tile : getGround ()
    if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
    end
    local items = tile:getItems ()
    for i = 1 , tile:getItemCount() do
        local item = items [ i ]
        local itemType = item : getType ()
    if itemType:getType () ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable () and item:hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
        end
    end
   
    return true
end
local function addTrainers ( position , arrayPos )
     if not isBusyable ( position ) then
         for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
         if not trainer then local monster = Game.createMonster ( "Trainer" , arrayPos [ places ])
                monster : getPosition():sendMagicEffect ( CONST_ME_MAGIC_BLUE )
            end
        end
    end
end
local function calculatingRoom ( uid , position , column , row )
    local player = Player( uid )
     if column >= config . rX then
        column = 0
        line = line < ( config . rY - 1 ) and line + 1 or false
    end
   
    if line then
        local room_pos = { x = position.x + ( column * config.DISTX ), y = position.y + ( line * config.distY ), z = position.z }
        if isBusyable ( room_pos ) then
            player : teleportTo ( room_pos )
       
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
            addTrainers ( room_pos , {{ x = room_pos.x - 1 , y = room_pos.y + 1 , z = room_pos.z }, { x = room_pos.x + 1 , y = room_pos.y + 1 , z = room_pos.z }}) else
            calculatingRoom ( uid , position , column + 1 , row )
        end
    else
        player : sendCancelMessage ( "Couldn't find any position for you right now." )
    end
end
function onStepIn ( creature , item , position , fromPosition )
    if not creature : isPlayer () then return false
    end
    if creature : getStorageValue ( storage ) - os . time () > 0 then
        creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
        creature : teleportTo ( fromPosition , true ) return true
    end    
       
    calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 )
    return true
end
Lua:
local storage = 5845
local function removeTrainers ( position )
    local arrayPos = {{ x = position.x - 1 , y = position.y + 1 , z = position.z }, { x = position.x + 1 , y = position.y + 1 , z = position.z }}
           for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
            if trainer then
                if trainer : isMonster () then
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
                trainer : remove ()
            end
        end
    end
end
   
function onStepIn ( creature , item , position , fromPosition ) if not creature : isPlayer () then
    return false
end
     
    removeTrainers ( fromPosition )
    creature : teleportTo ( creature : getTown (): getTemplePosition ())
    creature : setStorageValue ( storage , os . time () + 5 )
    return true
end


Thanks! i dont get any errors now, but hmm im thinking how i can make this work, where in in lua codes i make it to work with actionid 14876? cuz if im right, i dont need to set any location on the teleport and only actionid 14876 and it should find the positions by itself? have any ideas?
 
Give these a shot. This should work with any type of item that has this action id. Even a battle axe if you wish.
All you need to do is to set the action id of your teleport, and check over with the script.
This should make it work.

I added comments where I did something.

Lua:
local storage = 5845
local actionId = 14876 -- This number is tha actio  id you put on your teleporters
local config = {
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, -- position of the first pos ( row 1 column 1 )
    distX = 12, -- distance in X between each room ( on the same row )
    distY = 12, -- Y distance between each room ( from the same column )
    rX = 4, -- number of columns
    rY = 5 -- number of lines
 }

local function isBusyable ( position ) local player = Tile ( position ): getTopCreature ()
    if player then
        if player : isPlayer () then
            return false
        end
    end
    
    local tile = Tile ( position ) if not tile then return false end
    local ground = tile : getGround ()
    if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
    end
    local items = tile:getItems ()
    for i = 1 , tile:getItemCount() do
        local item = items [ i ]
        local itemType = item : getType ()
    if itemType:getType () ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable () and item:hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
        end
    end
    
    return true
end

local function addTrainers ( position , arrayPos )
     if not isBusyable ( position ) then
         for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
         if not trainer then local monster = Game.createMonster ( "Trainer" , arrayPos [ places ])
                monster : getPosition():sendMagicEffect ( CONST_ME_MAGIC_BLUE )
            end
        end
    end
end
local function calculatingRoom ( uid , position , column , row )
    local player = Player( uid )
     if column >= config . rX then
        column = 0
        line = line < ( config . rY - 1 ) and line + 1 or false
    end
    
    if line then
        local room_pos = { x = position.x + ( column * config.DISTX ), y = position.y + ( line * config.distY ), z = position.z }
        if isBusyable ( room_pos ) then
            player : teleportTo ( room_pos )
        
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
            addTrainers ( room_pos , {{ x = room_pos.x - 1 , y = room_pos.y + 1 , z = room_pos.z }, { x = room_pos.x + 1 , y = room_pos.y + 1 , z = room_pos.z }}) else
            calculatingRoom ( uid , position , column + 1 , row )
        end
    else
        player : sendCancelMessage ( "Couldn't find any position for you right now." )
    end
end

function onStepIn ( creature , item , position , fromPosition )
    if item:getActionId() == actionId then    --[[ I added this to check if the "item" you are stepping into has an action id of 14876.
                                                 I surroned this code, since this is where it all executes. If your action id does not match. Nothing will happen. ]]--
        if not creature : isPlayer () then
            return false
        end
        if creature : getStorageValue ( storage ) - os . time () > 0 then
            creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
            creature : teleportTo ( fromPosition , true )
            return true
        end     
        
        calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 )
    end
    return true
 end

Lua:
local actionId = 14877 -- Added a variable for action id once again.
local storage = 5845
local function removeTrainers ( position )
    local arrayPos = {{ x = position.x - 1 , y = position.y + 1 , z = position.z }, { x = position.x + 1 , y = position.y + 1 , z = position.z }}
           for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
            if trainer then
                if trainer : isMonster () then
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
                trainer : remove ()
            end
        end
    end
end
    
function onStepIn ( creature , item , position , fromPosition )
    if item:getActionId() == actionId then    -- Once again I surrounded the rest of the code with an if statement. Only to check if the "item" you are stepping into has your action id
        if not creature : isPlayer () then
            return false
        end

        removeTrainers ( fromPosition )
        creature : teleportTo ( creature : getTown (): getTemplePosition ())
        creature : setStorageValue ( storage , os . time () + 5 )
    end
    return true
end
 
Give these a shot. This should work with any type of item that has this action id. Even a battle axe if you wish.
All you need to do is to set the action id of your teleport, and check over with the script.
This should make it work.

I added comments where I did something.

Lua:
local storage = 5845
local actionId = 14876 -- This number is tha actio  id you put on your teleporters
local config = {
    first_room_pos = { x = 1403 , y = 1252 , z = 7 }, -- position of the first pos ( row 1 column 1 )
    distX = 12, -- distance in X between each room ( on the same row )
    distY = 12, -- Y distance between each room ( from the same column )
    rX = 4, -- number of columns
    rY = 5 -- number of lines
}

local function isBusyable ( position ) local player = Tile ( position ): getTopCreature ()
    if player then
        if player : isPlayer () then
            return false
        end
    end
  
    local tile = Tile ( position ) if not tile then return false end
    local ground = tile : getGround ()
    if not ground or ground : hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
    end
    local items = tile:getItems ()
    for i = 1 , tile:getItemCount() do
        local item = items [ i ]
        local itemType = item : getType ()
    if itemType:getType () ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable () and item:hasProperty ( CONST_PROP_BLOCKSOLID ) then
        return false
        end
    end
  
    return true
end

local function addTrainers ( position , arrayPos )
     if not isBusyable ( position ) then
         for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
         if not trainer then local monster = Game.createMonster ( "Trainer" , arrayPos [ places ])
                monster : getPosition():sendMagicEffect ( CONST_ME_MAGIC_BLUE )
            end
        end
    end
end
local function calculatingRoom ( uid , position , column , row )
    local player = Player( uid )
     if column >= config . rX then
        column = 0
        line = line < ( config . rY - 1 ) and line + 1 or false
    end
  
    if line then
        local room_pos = { x = position.x + ( column * config.DISTX ), y = position.y + ( line * config.distY ), z = position.z }
        if isBusyable ( room_pos ) then
            player : teleportTo ( room_pos )
      
            player : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
            addTrainers ( room_pos , {{ x = room_pos.x - 1 , y = room_pos.y + 1 , z = room_pos.z }, { x = room_pos.x + 1 , y = room_pos.y + 1 , z = room_pos.z }}) else
            calculatingRoom ( uid , position , column + 1 , row )
        end
    else
        player : sendCancelMessage ( "Couldn't find any position for you right now." )
    end
end

function onStepIn ( creature , item , position , fromPosition )
    if item:getActionId() == actionId then    --[[ I added this to check if the "item" you are stepping into has an action id of 14876.
                                                 I surroned this code, since this is where it all executes. If your action id does not match. Nothing will happen. ]]--
        if not creature : isPlayer () then
            return false
        end
        if creature : getStorageValue ( storage ) - os . time () > 0 then
            creature : sendTextMessage ( MESSAGE_INFO_DESCR , "You gotta wait a few seconds before you can enter trainning room again" )
            creature : teleportTo ( fromPosition , true )
            return true
        end   
      
        calculatingRoom ( creature . uid , config . first_room_pos , 0 , 0 )
    end
    return true
end

Lua:
local actionId = 14877 -- Added a variable for action id once again.
local storage = 5845
local function removeTrainers ( position )
    local arrayPos = {{ x = position.x - 1 , y = position.y + 1 , z = position.z }, { x = position.x + 1 , y = position.y + 1 , z = position.z }}
           for places = 1 , #arrayPos do
            local trainer = Tile ( arrayPos [ places ]): getTopCreature ()
            if trainer then
                if trainer : isMonster () then
                trainer : getPosition (): sendMagicEffect ( CONST_ME_TELEPORT )
                trainer : remove ()
            end
        end
    end
end
  
function onStepIn ( creature , item , position , fromPosition )
    if item:getActionId() == actionId then    -- Once again I surrounded the rest of the code with an if statement. Only to check if the "item" you are stepping into has your action id
        if not creature : isPlayer () then
            return false
        end

        removeTrainers ( fromPosition )
        creature : teleportTo ( creature : getTown (): getTemplePosition ())
        creature : setStorageValue ( storage , os . time () + 5 )
    end
    return true
end


Added em but no progress yet so far, when i enter the teleport with my second char that should take the next room that is empty it says "Couldnt find any position for you right now" Im thinking if theres a step if have missed to add to make it work? some file in other file
 
Back
Top