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

request npc give outfitA or outfitB in exchange for 7 items

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
923
Location
Chile
Hii, well like i said in the tittle, i'm requesting an npc who will give either outfitA or outfitB, whatever the player choose (he can choose only one and then never talk to the npc, even if he gets the items again) in exchange for seven items (then the items dissapears)
plz if someone could do me an NPC for this i would be really grateful, i use OTX 2.52
 
I never used OTX 2.52 so I'm not sure, does it use the same Lua Functions as for example TFS 0.4?

Or maybe you can post an example of what a normal NPC script looks like in OTX 2.52?
 
I never used OTX 2.52 so I'm not sure, does it use the same Lua Functions as for example TFS 0.4?

Or maybe you can post an example of what a normal NPC script looks like in OTX 2.52?

OTX is based on 0.4/o.3.7 source code so a 0.4 script should work on OTx
 
I never used OTX 2.52 so I'm not sure, does it use the same Lua Functions as for example TFS 0.4?

Or maybe you can post an example of what a normal NPC script looks like in OTX 2.52?
here is a NPC i have
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 config = {
    storage_join = 15001,
    storage_dream = 15002,
    storage_rank = 15003,
    doors_aid = 15006,
    demonic_id = 6500,
    max_rank=4,
    shield_id = 6433;
}

local basic_rank = "Maggot"
local ranks = {
        [1] = {{500,"Hyaena"},{1000, "Death Dealer"},{1500,"Dread Lord"}}, --BB
        }

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, 'join') and getPlayerStorageValue(cid, config.storage_join) < 1 then
        if(getPlayerStorageValue(cid,config.storage_dream) < 1) then
        --npcHandler:say('The Brotherhood of Bones has suffered greatly in the past, but we did survive as we always will ...', cid)
        --addEvent(npcHandler:say,2000, "You have proven resourceful by beating the silly riddles the Nightmare Knights set up to test their candidates ...", cid)
        --addEvent(npcHandler:say,5000, "It's an amusing thought that after passing their test you might choose to join the ranks of their sworn enemies ... ", cid)
            npcHandler:say("For the irony of this I ask you, ".. getCreatureName(cid) ..": Do you want to join the Brotherhood of Bones?", cid)
            talkState[talkUser] = 1
        else
            npcHandler:say("You can not join my order. Sorry.",cid);
        end
                   
                       
    elseif msgcontains(msg, 'yes') then
        if(talkState[talkUser] == 1) then
            npcHandler:say('But know that your decision will be irrevocable. You will abandon the opportunity to join any order whose doctrine is incontrast to our own... Do you still want to join the Brotherhood?',cid)
            --addEvent(npcHandler:say,4000, "Do you still want to join the Brotherhood?",cid)
            talkState[talkUser] = 2
           
        elseif(talkState[talkUser] == 2) then
            npcHandler:say('Welcome to the Brotherhood! From now on you will walk the path of Bones. A life full of promises and power has just beenoffered to you. You can always ask me about your current rank and about the privileges the ranks grant to those who hold them.',cid)
            --addEvent(npcHandler:say,4000, "Take it, if you are up to that challenge ... or perish in agony if you deserve this fate ...",cid)
            --addEvent(npcHandler:say,7000, "You can always ask me about your current rank and about the privileges the ranks grant to those who hold them.",cid)
            setPlayerStorageValue(cid, config.storage_join, 1);
            setPlayerStorageValue(cid, config.storage_rank, 1);
        elseif(talkState[talkUser] == 3) then   
            local rank = getPlayerStorageValue(cid,config.storage_rank)
            if(getPlayerItemCount(cid,config.demonic_id)>= ranks[1][rank][1]) then
                doPlayerRemoveItem(cid, config.demonic_id ,ranks[1][rank][1])
                if(rank == 2) then
                    npcHandler:say('You are worthy of an advancement. I grand you the rank of a '.. ranks[1][rank][2] ..' of our order. Take this shield as a symbol of your new status.',cid)
                    doPlayerAddItem(cid, config.shield_id,1)
                elseif(rank == 3) then
                    npcHandler:say('You are worthy of an advancement. I grand you the rank of a '.. ranks[1][rank][2] ..' of our order. You are able now to enter this room and create documents.',cid)
                    setPlayerStorageValue(cid, config.doors_aid,1)
                else
                    npcHandler:say('You are worthy of an advancement. I grand you the rank of a '.. ranks[1][rank][2] ..' of our order.',cid)
                end
                setPlayerStorageValue(cid,config.storage_rank,rank+1)
            else
                npcHandler:say('You don\'t have enough demonic essences.',cid)
            end
           
        end
    elseif msgcontains(msg, 'advancement') then   
        local rank = getPlayerStorageValue(cid,config.storage_rank)
        if(rank < 1) then
            npcHandler:say('You are not member of our order.',cid)
        elseif(rank>= config.max_rank) then
            npcHandler:say('You are already master of our order.',cid);
        else
            npcHandler:say('To advance to rank '.. ranks[1][rank][2] ..', you have to bring me '.. ranks[1][rank][1] ..' demonic essences. Do you have it with yourself?',cid)
            talkState[talkUser] = 3
        end
   
    elseif (msgcontains(msg, 'rank')) then
        local rank = getPlayerStorageValue(cid,config.storage_rank)
        if(rank < 1) then
            npcHandler:say('You are not member of our order.',cid)
        elseif(rank == 1) then
            npcHandler:say('You are '.. basic_rank ..' of our order.',cid)
        else
            npcHandler:say('You are '.. ranks[1][rank-1][2] ..' of our order',cid)
        end

    elseif (msgcontains(msg, 'no') and talkState[talkUser] > 0)  then
        talkState[talkUser] = 0
        npcHandler:say('Suecide yourself.',cid)
    end   
   
    return TRUE   
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I tested it out on TFS 0.4 and it seems to be working fine.

You'll just have to replace some spots with actual item names and item ids.

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 completed = 9000
local addon1 = 9001
local addon2 = 9002

     if msg == "outfit" and getPlayerStorageValue(cid, completed) ~= 1 then
        npcHandler:say("Do you want {outfit A} or {outfit B}?", cid)
        talkState[cid] = 1
     elseif msgcontains(msg, "outfit A") and talkState[cid] == 1 then
        npcHandler:say("For Outfit A you need these items: Item1, Item2, Item3, Item4, Item5, Item6, and Item7. Do you have all the items?", cid) -- Replace with your Items Names
        talkState[cid] = 2
     elseif msgcontains(msg, "outfit B") and talkState[cid] == 1 then
        npcHandler:say("For Outfit B you need these items: Item1, Item2, Item3, Item4, Item5, Item6, and Item7. Do you have all the items?", cid) -- Replace with your Items Names
        talkState[cid] = 3
     elseif msgcontains(msg, "yes") and talkState[cid] == 2 then
        -- Replace the item ids with yours
        if getPlayerItemCount(cid, 2382) >= 1 and getPlayerItemCount(cid, 2398) >= 1 and getPlayerItemCount(cid, 2050) >= 1 and getPlayerItemCount(cid, 5710) >= 1 and getPlayerItemCount(cid, 2120) >= 1 and getPlayerItemCount(cid, 2550) >= 1 and getPlayerItemCount(cid, 2554) >= 1 then
            doPlayerRemoveItem(cid, 2382, 1)
            doPlayerRemoveItem(cid, 2398, 1)
            doPlayerRemoveItem(cid, 2050, 1)
            doPlayerRemoveItem(cid, 5710, 1)
            doPlayerRemoveItem(cid, 2120, 1)
            doPlayerRemoveItem(cid, 2550, 1)
            doPlayerRemoveItem(cid, 2554, 1)
            npcHandler:say("Enjoy your new outfit!", cid)
            doPlayerAddOutfit(cid, 128, 3) -- This is just the id for the citizen outfit and the 3 means FULL Addons, 0 = no addons, 1= addon 1, 2 = addon 2.
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
            setPlayerStorageValue(cid, completed, 1)
            setPlayerStorageValue(cid, addon1, 1)
            talkState[cid] = 0
        else
            npcHandler:say("You do not have all the items!", cid)
        end
    elseif msgcontains(msg, "yes") and talkState[cid] == 3 then
        -- Replace the item ids with yours
        if getPlayerItemCount(cid, 2382) >= 1 and getPlayerItemCount(cid, 2398) >= 1 and getPlayerItemCount(cid, 2050) >= 1 and getPlayerItemCount(cid, 5710) >= 1 and getPlayerItemCount(cid, 2120) >= 1 and getPlayerItemCount(cid, 2550) >= 1 and getPlayerItemCount(cid, 2554) >= 1 then
            doPlayerRemoveItem(cid, 2382, 1)
            doPlayerRemoveItem(cid, 2398, 1)
            doPlayerRemoveItem(cid, 2050, 1)
            doPlayerRemoveItem(cid, 5710, 1)
            doPlayerRemoveItem(cid, 2120, 1)
            doPlayerRemoveItem(cid, 2550, 1)
            doPlayerRemoveItem(cid, 2554, 1)
            setPlayerStorageValue(cid, completed, 1)
            setPlayerStorageValue(cid, addon2, 1)
            doPlayerAddOutfit(cid, 128, 3)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
            npcHandler:say("Enjoy your new outfit!", cid)
            talkState[cid] = 0
        else
            npcHandler:say("You do not have all the items!", cid)
        end
     elseif msgcontains(msg, "no") and (talkState[cid] == 2 or talkState[cid] == 3) then
         npcHandler:say("Ok then.", cid)
         talkState[cid] = 0
    elseif getPlayerStorageValue(cid, completed) == 1 then
        if getPlayerStorageValue(cid, addon1) == 1 then
        npcHandler:say("You have already received {Outfit A}.", cid)
        elseif getPlayerStorageValue(cid, addon2) == 1 then
        npcHandler:say("You have already received {Outfit B}.", cid)
        end
end
    
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I tested it out on TFS 0.4 and it seems to be working fine.

You'll just have to replace some spots with actual item names and item ids.

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 completed = 9000
local addon1 = 9001
local addon2 = 9002

     if msg == "outfit" and getPlayerStorageValue(cid, completed) ~= 1 then
        npcHandler:say("Do you want {outfit A} or {outfit B}?", cid)
        talkState[cid] = 1
     elseif msgcontains(msg, "outfit A") and talkState[cid] == 1 then
        npcHandler:say("For Outfit A you need these items: Item1, Item2, Item3, Item4, Item5, Item6, and Item7. Do you have all the items?", cid) -- Replace with your Items Names
        talkState[cid] = 2
     elseif msgcontains(msg, "outfit B") and talkState[cid] == 1 then
        npcHandler:say("For Outfit B you need these items: Item1, Item2, Item3, Item4, Item5, Item6, and Item7. Do you have all the items?", cid) -- Replace with your Items Names
        talkState[cid] = 3
     elseif msgcontains(msg, "yes") and talkState[cid] == 2 then
        -- Replace the item ids with yours
        if getPlayerItemCount(cid, 2382) >= 1 and getPlayerItemCount(cid, 2398) >= 1 and getPlayerItemCount(cid, 2050) >= 1 and getPlayerItemCount(cid, 5710) >= 1 and getPlayerItemCount(cid, 2120) >= 1 and getPlayerItemCount(cid, 2550) >= 1 and getPlayerItemCount(cid, 2554) >= 1 then
            doPlayerRemoveItem(cid, 2382, 1)
            doPlayerRemoveItem(cid, 2398, 1)
            doPlayerRemoveItem(cid, 2050, 1)
            doPlayerRemoveItem(cid, 5710, 1)
            doPlayerRemoveItem(cid, 2120, 1)
            doPlayerRemoveItem(cid, 2550, 1)
            doPlayerRemoveItem(cid, 2554, 1)
            npcHandler:say("Enjoy your new outfit!", cid)
            doPlayerAddOutfit(cid, 128, 3) -- This is just the id for the citizen outfit and the 3 means FULL Addons, 0 = no addons, 1= addon 1, 2 = addon 2.
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
            setPlayerStorageValue(cid, completed, 1)
            setPlayerStorageValue(cid, addon1, 1)
            talkState[cid] = 0
        else
            npcHandler:say("You do not have all the items!", cid)
        end
    elseif msgcontains(msg, "yes") and talkState[cid] == 3 then
        -- Replace the item ids with yours
        if getPlayerItemCount(cid, 2382) >= 1 and getPlayerItemCount(cid, 2398) >= 1 and getPlayerItemCount(cid, 2050) >= 1 and getPlayerItemCount(cid, 5710) >= 1 and getPlayerItemCount(cid, 2120) >= 1 and getPlayerItemCount(cid, 2550) >= 1 and getPlayerItemCount(cid, 2554) >= 1 then
            doPlayerRemoveItem(cid, 2382, 1)
            doPlayerRemoveItem(cid, 2398, 1)
            doPlayerRemoveItem(cid, 2050, 1)
            doPlayerRemoveItem(cid, 5710, 1)
            doPlayerRemoveItem(cid, 2120, 1)
            doPlayerRemoveItem(cid, 2550, 1)
            doPlayerRemoveItem(cid, 2554, 1)
            setPlayerStorageValue(cid, completed, 1)
            setPlayerStorageValue(cid, addon2, 1)
            doPlayerAddOutfit(cid, 128, 3)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
            npcHandler:say("Enjoy your new outfit!", cid)
            talkState[cid] = 0
        else
            npcHandler:say("You do not have all the items!", cid)
        end
     elseif msgcontains(msg, "no") and (talkState[cid] == 2 or talkState[cid] == 3) then
         npcHandler:say("Ok then.", cid)
         talkState[cid] = 0
    elseif getPlayerStorageValue(cid, completed) == 1 then
        if getPlayerStorageValue(cid, addon1) == 1 then
        npcHandler:say("You have already received {Outfit A}.", cid)
        elseif getPlayerStorageValue(cid, addon2) == 1 then
        npcHandler:say("You have already received {Outfit B}.", cid)
        end
end
   
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
wow man thanks!!! i can't test it untill sunday, but i was looking, and i have a question, is there the thing that the npc won't give you another outfit if you already gave him the 7 items? for example, i have the items, go and get outfitA, then i collect all items again to get outfitB. I want that to be impossible, like te quests where you can have 1 item only, you know? is that on the npc you made?
 
wow man thanks!!! i can't test it untill sunday, but i was looking, and i have a question, is there the thing that the npc won't give you another outfit if you already gave him the 7 items? for example, i have the items, go and get outfitA, then i collect all items again to get outfitB. I want that to be impossible, like te quests where you can have 1 item only, you know? is that on the npc you made?

Yes that is the way it was made. If you already took outfit A or outfit B then the next time you ask for an outfit he will say "You have already received Outfit A/B."

If you have already used these storage values: 9000 - 9002 then you can replace those numbers with any un-used storage values.
local completed = 9000
local addon1 = 9001
local addon2 = 9002

If you find any errors on Sunday please let me know. Good Luck buddy :D
 
Yes that is the way it was made. If you already took outfit A or outfit B then the next time you ask for an outfit he will say "You have already received Outfit A/B."

If you have already used these storage values: 9000 - 9002 then you can replace those numbers with any un-used storage values.
local completed = 9000
local addon1 = 9001
local addon2 = 9002

If you find any errors on Sunday please let me know. Good Luck buddy :D
thank you very much! :D i will let you know :)
 
Yes that is the way it was made. If you already took outfit A or outfit B then the next time you ask for an outfit he will say "You have already received Outfit A/B."

If you have already used these storage values: 9000 - 9002 then you can replace those numbers with any un-used storage values.
local completed = 9000
local addon1 = 9001
local addon2 = 9002

If you find any errors on Sunday please let me know. Good Luck buddy :D
maaan!!! it worked perfectly!! thank you so much man :)!!
 
Back
Top