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

Need add limit lvl use to npc

Exactly

New Member
Joined
Jul 14, 2014
Messages
119
Reaction score
4
Hello i need add on this script limit lvl for use can help me?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end


function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local items = {
        [1] = 2190,
        [2] = 2182,
        [5] = 2190,
        [6] = 2182
    }

    if msgcontains(msg, 'reborn') then
        player:doRebirth()
        local vocationId = player:getVocation():getId()
        if isInArray({1, 2, 5, 6}, vocationId) then
            if player:getStorageValue(30002) == -1 then
                selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your advanture?', cid)
                npcHandler.topic[cid] = 1
            else
                selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif msgcontains(msg, 'yes') then
        if npcHandler.topic[cid] == 1 then
            player:addItem(items[vocationId], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            player:setStorageValue(30002, 1)
        end
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
        selfSay('Ok then.', cid)
        npcHandler.topic[cid] = 0
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Dont work can u add me line :(?
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end


function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local items = {
        [1] = 2190,
        [2] = 2182,
        [5] = 2190,
        [6] = 2182
    }
    local requiredLevel = 100
   
    if getPlayerLevel(cid) >= requiredLevel then
        if msgcontains(msg, 'reborn') then
            player:doRebirth()
            local vocationId = player:getVocation():getId()
            if isInArray({1, 2, 5, 6}, vocationId) then
                if player:getStorageValue(30002) == -1 then
                    selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your advanture?', cid)
                    npcHandler.topic[cid] = 1
                else
                    selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
                end
            else
                selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
            end
        elseif msgcontains(msg, 'yes') then
            if npcHandler.topic[cid] == 1 then
                player:addItem(items[vocationId], 1)
                selfSay('Here you are young adept, take care yourself.', cid)
                player:setStorageValue(30002, 1)
            end
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
            selfSay('Ok then.', cid)
            npcHandler.topic[cid] = 0
        end
    else
        selfSay('Sorry, You need to be '.. requiredLevel .. ' or higher to be reborn.', cid)
        npcHandler.topic[cid] = 0
        return false
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Code:
local levelNeeded = 300
if player:getLevel() < levelNeeded then
    npcHandler:say("You need to be above level ".. levelNeeded .." to talk with me.", cid)
    npcHandler.topic[cid] = 0
    return true
end

Add that above the line if msgcontains(msg, 'reborn') then
 
Back
Top