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

can someone remake npc script

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,398
Reaction score
165
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if(msgcontains(msg, 'pass') or msgcontains(msg, 'mission')) then
        selfSay('If you want pass that door next to me , then you need you to get claw of the noxious spawn from Serpent Spawn Boss , meyby you got it?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if(getPlayerItemCount(cid, 10309) >= 1) and getPlayerStorageValue(cid,5066) == -1 then
                if(doPlayerRemoveItem(cid, 10309, 1) == TRUE) then
                setPlayerStorageValue(cid,5066,1)
                selfSay('Thank you! You can now pass the door now!', cid)
        else
            selfSay('Sorry, you don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end
    end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

thats npc if you bring x item it gives you x storage , i want to to change it i bring 100x or 1000x for XXXX item .
 
if(getPlayerItemCount(cid, 10309) >= 1) (checks if player have 1 or more if item 10309)

should be for example:
if(getPlayerItemCount(cid, 10309) >= 1000) - 1000x (checks if player have 1000 or more if item 10309)


if(doPlayerRemoveItem(cid, 10309, 1) == TRUE) then (removes 1 item of id 10309 from player)
10309 = itemId
1 = number

example 1000 of one item:
if(doPlayerRemoveItem(cid, 10309, 1000) == TRUE) then (removes 1000 items of id 10309 from player)
 
can you fully remake it? and how about if players gives x xxx item and gets as reward YYYY item?
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

local storage = xxxx
local itemIdToGive = xxxx
local amountToGive = xxxx
local reward = xxxx
local rewardCount = xxxx

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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if(msgcontains(msg, 'pass') or msgcontains(msg, 'mission')) then
        selfSay('If you want pass that door next to me , then you need you to get claw of the noxious spawn from Serpent Spawn Boss , meyby you got it?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if(getPlayerItemCount(cid, itemIdToGive) >= amountToGive) and getPlayerStorageValue(cid,storage) == -1 then
                if(doPlayerRemoveItem(cid, itemIdToGive, amountToGive) == TRUE) then
                setPlayerStorageValue(cid,storage,1)
                doPlayerAddItem(cid, reward, rewardCount)
                selfSay('Thank you! You can now pass the door now!', cid)
        else
            selfSay('Sorry, you don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end
    end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Just change the xxxx at the top to the ids and amounts you want. You could also change the selfSays and msgcontains so the NPC say something different, if you want to ofc.
 
Back
Top