Portal level requirement help!

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
How do I assign a level requirement to a portal??? I don't want to use a Exp door due to people blocking it etc.
 

Siegh

Thronar Developer
Joined
Mar 12, 2011
Messages
1,164
Best answers
1
Reaction score
477
Location
Brazil
How do I assign a level requirement to a portal??? I don't want to use a Exp door due to people blocking it etc.
Use this as a moveevent on the tile below the teleport:

Code:
function onStepIn(cid, pos)
tp = {x=1663, y=2552, z=4} --the place where the portal takes you
bp = {x=1663, y=2552, z=4} --teleports back to somewhere close if not high enough
lvlreq = 10 --level required for 
    if isPlayer(cid) then
        if getPlayerLevel(cid) >= lvlreq then
            doTeleportThing(cid, tp)
        else
            doPlayerSendCancel(cid, "You don't have enough level. ("..lvlreq..")")
            doTeleportThing(cid, bp)
        end
    end
return true
end
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
assuming you are using tfs 1.2+


Code:
function onStepIn(creature, item, position, fromPosition)
    local reqLevel = 10
   
    local pLevel = creature:getLevel()
    if pLevel >= reqLevel then
        return true
    end
   
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..reqLevel.." to enter.")
    player:teleportTo(fromPosition, true)
    return false
end
 
OP
brewska

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
It doesn't allow lower levels to enter it which is good thank you for that I will rep+ but now I have a different problem when a player with the required level "enters the portal" I get this
[Error - MoveEvent::executeStep] Call stack overflow
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
It doesn't allow lower levels to enter it which is good thank you for that I will rep+ but now I have a different problem when a player with the required level "enters the portal" I get this
[Error - MoveEvent::executeStep] Call stack overflow
which script you use
 
OP
brewska

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
The first script by Siegh , ill try yours but do I need portal position in your script?
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
The first script by Siegh , ill try yours but do I need portal position in your script?
no. just add the movement script.
 
OP
brewska

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
I tried yours and its allowing me to walk into the portal on a lower lvl and then it sends this msg after I enter the portal on the low lvl.


data/movements/scripts/bglvltp.lua:eek:nStepIn
data/movements/scripts/bglvltp.lua:9: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/movements/scripts/bglvltp.lua:9: in function <data/movements/scripts/bglvltp.lua:1>
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
I tried yours and its allowing me to walk into the portal on a lower lvl and then it sends this msg after I enter the portal on the low lvl.


data/movements/scripts/bglvltp.lua:eek:nStepIn
data/movements/scripts/bglvltp.lua:9: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/movements/scripts/bglvltp.lua:9: in function <data/movements/scripts/bglvltp.lua:1>
Code:
function onStepIn(creature, item, position, fromPosition)
    local reqLevel = 10
  
    local pLevel = creature:getLevel()
    if pLevel >= reqLevel then
        return true
    end
  
    creature:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..reqLevel.." to enter.")
    creature:teleportTo(fromPosition, true)
    return false
end
 
OP
brewska

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
Still not working :/ same message.
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
Still not working :/ same message.
cant be the same message player doesn't exist anymore lol i suggest you try again and remember to reload =)
 
OP
brewska

brewska

Excellent OT User
Joined
Oct 24, 2008
Messages
21
Best answers
0
Reaction score
0
TYYYY you were right its working!!! now how do I ++ rep do I just hit the like button on ur page? or what
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,341
Best answers
6
Reaction score
476
TYYYY you were right its working!!! now how do I ++ rep do I just hit the like button on ur page? or what
There is no more 'rep' as per the rules. but you can mark my post as the best solution. =)
 

Nekiro

Support Team
Support Team
Joined
Sep 7, 2015
Messages
1,891
Best answers
81
Reaction score
669
Code:
function onStepIn(creature, item, position, fromPosition)
    local reqLevel = 10
 
    local pLevel = creature:getLevel()
    if pLevel >= reqLevel then
        return true
    end
 
    creature:sendTextMessage(MESSAGE_INFO_DESCR, "You must be level "..reqLevel.." to enter.")
    creature:teleportTo(fromPosition, true)
    return false
end
If any creature that is not player will enter this scripted tile it will throw error in console, because only player has levels.

Code:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if player:getLevel() >= 8 then -- if player got higher or equal level to the required level it will let him pass
        return true
    end

    player:teleportTo(fromPosition, true)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your level is too low to enter.")
    return true
end
 
Last edited:
Top