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

Lua Trying to get into scripting, help needed

Xianji

New Member
Joined
May 7, 2014
Messages
17
Reaction score
0
I'm adding onto a script what I'd like to be a restriction of a specific level and up. Basically the Island of Destiny on RL, where if you're level 10 or up the dungeon won't allow you to enter again.

Original:

Code:
function onStepIn(cid, item, frompos, item2, topos)

local vocation = getPlayerVocation(cid)
local nvtp = {x=677, y=1176, z=6}
local vtp = {x=546, y=1213, z=7}

    if vocation == 2 then
        doCreatureSay(cid, "Good luck!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, vtp, TRUE)
    else
        doCreatureSay(cid, "You\'re the wrong vocation!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp, FALSE)
    end
end

What I'm trying to get to work:

Code:
function onStepIn(cid, item, frompos, item2, topos)

local level = getPlayerLevel(cid)
local vocation = getPlayerVocation(cid)
local nvtp = {x=677, y=1176, z=6}
local vtp = {x=546, y=1213, z=7}

    if level >= 10 then
        doCreatureSay(cid, "Your level is too high.", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp, FALSE)
    end
    if vocation == 2 then
        doCreatureSay(cid, "Good luck!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, vtp, TRUE)
    else
        doCreatureSay(cid, "You\'re the wrong vocation!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp, FALSE)
    end
end

The script doesn't change at all, I neither get a message or a teleport. What is the problem here?

Thanks!
 
Code:
function onStepIn(cid, item, frompos, item2, topos)

local level = getPlayerLevel(cid)
local vocation = getPlayerVocation(cid)
local nvtp = {x=677, y=1176, z=6}
local vtp = {x=546, y=1213, z=7}

    if level >= 10 then
        doCreatureSay(cid, "Your level is too high.", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp)
    else
        if vocation == 2 then
            doCreatureSay(cid, "Good luck!", TALKTYPE_ORANGE_1)
            doTeleportThing(cid, vtp)
            return true
        else
            doCreatureSay(cid, "You\'re the wrong vocation!", TALKTYPE_ORANGE_1)
            doTeleportThing(cid, nvtp)
        end
    end
end
 
try this

Code:
function onStepIn(cid, item, frompos, item2, topos)

local level = getPlayerLevel(cid)
local vocation = getPlayerVocation(cid)
local nvtp = {x=677, y=1176, z=6}
local vtp = {x=546, y=1213, z=7}

    if level >= 10 then
        doCreatureSay(cid, "Your level is too high.", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp, FALSE)
    elseif vocation == 2 then
        doCreatureSay(cid, "Good luck!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, vtp, TRUE)
    else
        doCreatureSay(cid, "You\'re the wrong vocation!", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, nvtp, FALSE)
    end
return true
end
 
Thanks both of you! Cadyan's idea worked. So I simply had misplaced the end and had to add an else in its place.

Scripting is really fun!
 
It's not a matter of simply misplacing the "end", or replacing it with "else". You must check each outcome and give an answer for each outcome. I simply checked for level 10 first, and gave an error message if you are 10 or higher. But if you are lower than 10, then you "else" into the next part of the script. Each "if" needs an "end", and "elseif" can be used to prolong the script without an "end".
 
but i think this will be more better because if monster
It's not a matter of simply misplacing the "end", or replacing it with "else". You must check each outcome and give an answer for each outcome. I simply checked for level 10 first, and gave an error message if you are 10 or higher. But if you are lower than 10, then you "else" into the next part of the script. Each "if" needs an "end", and "elseif" can be used to prolong the script without an "end".

:)
but i was thinking to add if isPlayer(cid) but i don't think he will put this tile on monster's area :P
 
It's not a matter of simply misplacing the "end", or replacing it with "else". You must check each outcome and give an answer for each outcome. I simply checked for level 10 first, and gave an error message if you are 10 or higher. But if you are lower than 10, then you "else" into the next part of the script. Each "if" needs an "end", and "elseif" can be used to prolong the script without an "end".
Ah, I see. I used to think scripting was just a clutter of text, but it's 100% logical isn't it?

but i think this will be more better because if monster


:)
but i was thinking to add if isPlayer(cid) but i don't think he will put this tile on monster's area :p
Yeah, it's intended to be outside of mobs. Good point though, I'll keep that in mind.
 
Back
Top