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

npc who exchange item for another item that gives storage only once exchange TFS 1.5 NEKIRO

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,337
Solutions
71
Reaction score
697
Location
ლ(ಠ益ಠლ)
can someone put storage on it please.


Lua:
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, 'item') or msgcontains(msg, 'item2')) then
                selfSay('want to exchange item for another item', cid)
                talkState[talkUser] = 1

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(getPlayerItemCount(cid, 13685) >= 20) then
                doPlayerRemoveItem(cid, 13685, 20)
                doPlayerAddItem(cid, 6527, 100)
                selfSay('Thank you and come back often.', cid)
        else
                selfSay('You dont have item.', cid)
        end
            talkState[talkUser] = 0

               
-------------------------------------------------------------------------------------------------------------------------------------------------        
         
         
elseif(msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
                selfSay('teste teste teste.', cid)
                selfSay('heloo heloo.',cid)
        end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
just tell chatgpt to do that?
Post automatically merged:

Lua:
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, 'item') or msgcontains(msg, 'item2')) then
        if (getCreatureStorage(cid, 64001) ~= 1) then
            selfSay('Want to exchange item for another item.', cid)
            talkState[talkUser] = 1
        else
            selfSay('You have already exchanged the item.', cid)
        end
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerItemCount(cid, 13685) >= 20) then
            doPlayerRemoveItem(cid, 13685, 20)
            doPlayerAddItem(cid, 6527, 100)
            selfSay('Thank you, and come back often.', cid)
            setCreatureStorage(cid, 64001, 1) -- Set storage to 1 indicating the item has been exchanged
        else
            selfSay('You don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
        selfSay('Teste teste teste.', cid)
        selfSay('Hello, hello.', cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
just tell chatgpt to do that?
Post automatically merged:

Lua:
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, 'item') or msgcontains(msg, 'item2')) then
        if (getCreatureStorage(cid, 64001) ~= 1) then
            selfSay('Want to exchange item for another item.', cid)
            talkState[talkUser] = 1
        else
            selfSay('You have already exchanged the item.', cid)
        end
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerItemCount(cid, 13685) >= 20) then
            doPlayerRemoveItem(cid, 13685, 20)
            doPlayerAddItem(cid, 6527, 100)
            selfSay('Thank you, and come back often.', cid)
            setCreatureStorage(cid, 64001, 1) -- Set storage to 1 indicating the item has been exchanged
        else
            selfSay('You don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
        selfSay('Teste teste teste.', cid)
        selfSay('Hello, hello.', cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Lua Script Error: [Npc interface]
data/npc/scripts/teste.lua:eek:nCreatureSay
data/npc/scripts/teste.lua:30: attempt to call global 'getCreatureStorage' (a nil value)
stack traceback:
[C]: in function 'getCreatureStorage'
data/npc/scripts/teste.lua:30: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:384: in function 'onCreatureSay'
data/npc/scripts/teste.lua:15: in function <data/npc/scripts/teste.lua:14>
 
Lua Script Error: [Npc interface]
data/npc/scripts/teste.lua:eek:nCreatureSay
data/npc/scripts/teste.lua:30: attempt to call global 'getCreatureStorage' (a nil value)
stack traceback:
[C]: in function 'getCreatureStorage'
data/npc/scripts/teste.lua:30: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:384: in function 'onCreatureSay'
data/npc/scripts/teste.lua:15: in function <data/npc/scripts/teste.lua:14>
Lua:
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, 'item') or msgcontains(msg, 'item2')) then
        if (getPlayerStorageValue(cid, 64001) ~= 1) then
            selfSay('Want to exchange item for another item.', cid)
            talkState[talkUser] = 1
        else
            selfSay('You have already exchanged the item.', cid)
        end
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerItemCount(cid, 13685) >= 20) then
            doPlayerRemoveItem(cid, 13685, 20)
            doPlayerAddItem(cid, 6527, 100)
            selfSay('Thank you, and come back often.', cid)
            setPlayerStorageValue(cid, 64001, 1) -- Set storage to 1 indicating the item has been exchanged
        else
            selfSay('You don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
        selfSay('Teste teste teste.', cid)
        selfSay('Hello, hello.', cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
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, 'item') or msgcontains(msg, 'item2')) then
        if (getPlayerStorageValue(cid, 64001) ~= 1) then
            selfSay('Want to exchange item for another item.', cid)
            talkState[talkUser] = 1
        else
            selfSay('You have already exchanged the item.', cid)
        end
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerItemCount(cid, 13685) >= 20) then
            doPlayerRemoveItem(cid, 13685, 20)
            doPlayerAddItem(cid, 6527, 100)
            selfSay('Thank you, and come back often.', cid)
            setPlayerStorageValue(cid, 64001, 1) -- Set storage to 1 indicating the item has been exchanged
        else
            selfSay('You don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
        selfSay('Teste teste teste.', cid)
        selfSay('Hello, hello.', cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
yes it works now thanks brother
 
Lua:
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, 'item') or msgcontains(msg, 'item2')) then
        if (getPlayerStorageValue(cid, 64001) ~= 1) then
            selfSay('Want to exchange item for another item.', cid)
            talkState[talkUser] = 1
        else
            selfSay('You have already exchanged the item.', cid)
        end
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerItemCount(cid, 13685) >= 20) then
            doPlayerRemoveItem(cid, 13685, 20)
            doPlayerAddItem(cid, 6527, 100)
            selfSay('Thank you, and come back often.', cid)
            setPlayerStorageValue(cid, 64001, 1) -- Set storage to 1 indicating the item has been exchanged
        else
            selfSay('You don\'t have the item.', cid)
        end
        talkState[talkUser] = 0
    elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
        selfSay('Teste teste teste.', cid)
        selfSay('Hello, hello.', cid)
    end

    return true
end

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

nvm. I'm blind.
 

Similar threads

Back
Top