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

MoveEvent Level Requirement(Teleports,Floors) TFS(1.0)

A

Alw

Guest
Hello, this is a very simple script which I'm going to release.

How does this script work and what does it do?
This script is used as a level-door but for teleports and tiles. If the player doesn't have the required level or are higher he will be sent back to the position he was before he tried to enter the tile or teleport. If he's high enough he will be able to enter the tile or be teleported to the right destination.
How to install it?
You simply make a new file in movements and copy the code, the you add it to movements.xml (code below).
How to use it?
You use it by adding the uid 8700 to any tile or teleport that you want this on. Then you add your required level + 1000 as actionid on your tile or teleport.
ex. I have a teleport that will teleport a player to a quest, but he needs to be atleast level 100.
I open my mapeditor then I add 8700(uid) to the teleport and after that i add 1100 on to action id (required level + 1000). If you're using a teleport(magic forcefield etc) then don't forget to write the destination on it as well.
Problems?
Just post a reply and I'll try to explain it more firmly.


Copy this code onto a new file in movements.
Code:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    local creature = Creature(cid)   
    if(item.actionid<2000 and item.actionid>1000) then
        local levelReq = item.actionid-1000
        if(player:getLevel() <= levelReq) then
            creature:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level "..levelReq.." to enter.")
            return false
        end
    end       
    return true
end

The copy this code to movements.xml (You can change the uid to whatever you like).
Code:
    <movevent event="StepIn" uniqueid="UID" script="Name of script.lua"/>
 
I just updated it to make it more customize-able :)
Code:
local range = {
    ["min"] = 1000,
    ["max"] = 2000
}

function minMax(item, min, max)
    return item.actionid > min and item.actionid < max
end

function onStepIn(cid, item, position, fromPosition)  
    if minMax(item, range["min"], range["max"]) then
        local level = item.actionid - range["min"]
        if(Player(cid):getLevel() < level) then
            Player(cid):teleportTo(fromPosition, true)
            Player(cid):sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level "..level.." to enter.")
            return false
        end
    end      
    return true
end
 
Ah, I see now. You can switch uniqueid with actionid, but then you can't use the same level again for another tile.
You can also use itemid or use different uniqueids and add them all to movements.xml.
 
Hello, this is a very simple script which I'm going to release.

How does this script work and what does it do?
This script is used as a level-door but for teleports and tiles. If the player doesn't have the required level or are higher he will be sent back to the position he was before he tried to enter the tile or teleport. If he's high enough he will be able to enter the tile or be teleported to the right destination.
How to install it?
You simply make a new file in movements and copy the code, the you add it to movements.xml (code below).
How to use it?
You use it by adding the uid 8700 to any tile or teleport that you want this on. Then you add your required level + 1000 as actionid on your tile or teleport.
ex. I have a teleport that will teleport a player to a quest, but he needs to be atleast level 100.
I open my mapeditor then I add 8700(uid) to the teleport and after that i add 1100 on to action id (required level + 1000). If you're using a teleport(magic forcefield etc) then don't forget to write the destination on it as well.
Problems?
Just post a reply and I'll try to explain it more firmly.


Copy this code onto a new file in movements.
Code:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    local creature = Creature(cid)  
    if(item.actionid<2000 and item.actionid>1000) then
        local levelReq = item.actionid-1000
        if(player:getLevel() <= levelReq) then
            creature:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be atleast level "..levelReq.." to enter.")
            return false
        end
    end      
    return true
end

The copy this code to movements.xml (You can change the uid to whatever you like).
Code:
    <movevent event="StepIn" uniqueid="UID" script="Name of script.lua"/>




hello, i have a error in console :(

Code:
[19/11/2016 22:34:1] [Error - MoveEvents Interface]
[19/11/2016 22:34:1] data/movements/scripts/leveltile.lua:onStepIn
[19/11/2016 22:34:1] Description:
[19/11/2016 22:34:1] data/movements/scripts/leveltile.lua:2: attempt to call global 'Player' (a nil value)
[19/11/2016 22:34:1] stack traceback:
[19/11/2016 22:34:1]     data/movements/scripts/leveltile.lua:2: in function <data/movements/scripts/leveltile.lua:1>
 
Back
Top