• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.X+ Teleport Scroll adding level restriction

CesarZ

Well-Known Member
Joined
Sep 20, 2012
Messages
272
Solutions
4
Reaction score
66
Hey guys i have been trying to put a restriction in my lua. it seems like im always failing.

This is the Teleport Scroll.lua
LUA:
local newpos = {x=781, y=1001, z=7}
local time = 1--in second
function onUse(cid, item, fromPosition, itemEx, toPosition)
local inFight = getCreatureCondition(cid, CONDITION_INFIGHT)
if exhaustion.check(cid, 1605) then
return doPlayerSendCancel(cid, "Please Wait "..exhaustion.get(cid,1605)..".") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end

if not inFight then
doSendMagicEffect(getPlayerPosition(cid), 73)
doTeleportThing(cid,newpos)
doCreatureSay(cid, "TELEPORTED!!" ,TALKTYPE_ORANGE_1)
exhaustion.set(cid, 1605, time)

else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You can't use the teleport scroll if you are PZ LOCKED!!")
end
return true
end

I have been trying to put this one.
Code:
if not  (player:getLevel() < 50) then
            player:say("This Teleport scroll can only be use by level 50 or higher.", TALKTYPE_MONSTER_SAY)
            return true
 
Solution
E
sorry, here is it:
LUA:
local newpos = {x=781, y=1001, z=7}
local time = 1--in second
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    if getPlayerLevel(cid) < 50 then
        doCreatureSay(cid, "This Teleport scroll can only be use by level 50 or higher." ,TALKTYPE_ORANGE_1)
        return true
    end
local inFight = getCreatureCondition(cid, CONDITION_INFIGHT)
if exhaustion.check(cid, 1605) then
return doPlayerSendCancel(cid, "Please Wait "..exhaustion.get(cid,1605)..".") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end

if not inFight then
doSendMagicEffect(getPlayerPosition(cid), 73)
doTeleportThing(cid,newpos)
doCreatureSay(cid, "TELEPORTED!!" ,TALKTYPE_ORANGE_1)
exhaustion.set(cid, 1605, time)...
LUA:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if player:getLevel() < 50 then
        player:sendCancelMessage("This Teleport scroll can only be use by level 50 or higher.")
        return true
    end
    if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:teleportTo(Position(781, 1001, 7))
        Position(fromPosition):sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:sendCancelMessage("You can't use this when you're in a fight.")
        Position(fromPosition):sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
Last edited by a moderator:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getLevel() < 50 then
        player:sendCancelMessage("This Teleport scroll can only be use by level 50 or higher.")
        return true
    end
    if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:teleportTo(Position(781, 1001, 7))
        Position(fromPosition):sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:sendCancelMessage("You can't use this when you're in a fight.")
        Position(fromPosition):sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
eded.PNG
 
LUA:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if player:getLevel() < 50 then
        player:sendCancelMessage("This Teleport scroll can only be use by level 50 or higher.")
        return true
    end
    if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:teleportTo(Position(781, 1001, 7))
        Position(fromPosition):sendMagicEffect(CONST_ME_TELEPORT)
    else
        player:sendCancelMessage("You can't use this when you're in a fight.")
        Position(fromPosition):sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
TFS 1.3 is passing player userData as first variable in onUse, check here. So the cid variable isn't the creatureId. Isn't needed the line 2, just rename the first variable and will work(im not saying your code isn't working), and checking if the userData is a Player isn't needed too, because only Players can use actions(call onUse).
 
I've edited my post, try again
Dude it worked fine, but you changed the whole thing Text and effects. i just wanted to add the lvl restriction with a little message in with the effect doCreatureSay(cid, "text" ,TALKTYPE_ORANGE_1) Text color to let them know the level restriction. i tried the same script i have and adding the restriction you did to this one and failed lol. these scripts are tricky. lol
 
sorry, here is it:
LUA:
local newpos = {x=781, y=1001, z=7}
local time = 1--in second
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    if getPlayerLevel(cid) < 50 then
        doCreatureSay(cid, "This Teleport scroll can only be use by level 50 or higher." ,TALKTYPE_ORANGE_1)
        return true
    end
local inFight = getCreatureCondition(cid, CONDITION_INFIGHT)
if exhaustion.check(cid, 1605) then
return doPlayerSendCancel(cid, "Please Wait "..exhaustion.get(cid,1605)..".") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end

if not inFight then
doSendMagicEffect(getPlayerPosition(cid), 73)
doTeleportThing(cid,newpos)
doCreatureSay(cid, "TELEPORTED!!" ,TALKTYPE_ORANGE_1)
exhaustion.set(cid, 1605, time)

else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You can't use the teleport scroll if you are PZ LOCKED!!")
end
return true
end
 
Solution
Back
Top