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

Lua Addoner npc, keep buying addon if player says "yes"

ohman

Member
Joined
Oct 24, 2008
Messages
294
Reaction score
8
Location
Sweden
Hi! I got this addoner NPC. When a player buys "first nobleman addon" and then "yes" he gets the addon.
And right after the player writes "second nobleman addon" and the NPC answers "Not interested? Maybe other addon?" and if a player says "yes" he will buy first nobleman addon again.

"Easy example":

player - Hi
Addoner - Greetings blablabla.
player - first nobleman addon
Addoner - Did you bring me and 150000 gp for second nobleman addon?
Player - yes
Addoner - Here you are.

and if a player writes Yes again the player will be 150000 gps less rich. And again, and again...

If a player says bye after buying the first addon he cant buy it again. (storage id). Is there any way that make the npc says goodbye after buying a addon? It will fix the problem.

I'm using 0.3.6 rev 5969 client 8.6

Thanks!

here is the addon.lua:

http://pastebin.com/ReipeNSn (to big for this thread)
 
man i m not doing this for you !
i want to teach you, ok ?
  • 1 check how the NPC act when the player doesnt have the needed item, or he says not ( not willing to buy )
PHP:
-------  some SCRIPT CODE  ------
        else
            npcHandler:say('You do not have needed items or cash!', cid)
        end
        npcHandler:resetNpc()
        return true
    elseif (parameters.decline == true) then
        npcHandler:say('Not interested? Maybe other addon?', cid)
        npcHandler:resetNpc()
        return true
    end
we have this that repeat.
  1. Code:
    npcHandler:resetNpc()
  2. Code:
    return true
  • 2 check where the player buy it. we have this.
PHP:
-------- ssome SCRIPT CODE  --------
            npcHandler:say('Here you are.', cid)
end
just add what miss, then the npc will say good bay just after selling it.
PHP:
            npcHandler:say('Here you are.', cid)
            npcHandler:resetNpc()
            return true
end
EASY DONT ?
 
man i m not doing this for you !
i want to teach you, ok ?
  • 1 check how the NPC act when the player doesnt have the needed item, or he says not ( not willing to buy )
PHP:
-------  some SCRIPT CODE  ------
        else
            npcHandler:say('You do not have needed items or cash!', cid)
        end
        npcHandler:resetNpc()
        return true
    elseif (parameters.decline == true) then
        npcHandler:say('Not interested? Maybe other addon?', cid)
        npcHandler:resetNpc()
        return true
    end
we have this that repeat.
  1. Code:
    npcHandler:resetNpc()
  2. Code:
    return true
  • 2 check where the player buy it. we have this.
PHP:
-------- ssome SCRIPT CODE  --------
            npcHandler:say('Here you are.', cid)
end
just add what miss, then the npc will say good bay just after selling it.
PHP:
            npcHandler:say('Here you are.', cid)
            npcHandler:resetNpc()
            return true
end
EASY DONT ?

Thanks for your reply! But it didnt work :S

Code:
        if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
            doPlayerRemoveMoney(cid, addoninfo.cost)
            if table.maxn(addoninfo.items) > 0 then
                for i = 1, table.maxn(addoninfo.items) do
                    local item = addoninfo.items[i]
                    doPlayerRemoveItem(cid,item[1],item[2])
                end
            end
            doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
            doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
            setPlayerStorageValue(cid,addoninfo.storageID,1)
            npcHandler:say('Here you are.', cid)
        npcHandler:resetNpc()
            return true
        else
            npcHandler:say('You do not have needed items or cash!', cid)
        end
        npcHandler:resetNpc()
        return true
    elseif (parameters.decline == true) then
        npcHandler:say('Not interested? Maybe other addon?', cid)
        npcHandler:resetNpc()
        return true
    end
    return false
end

I tried to do that before I posted it. But I didnt write "return true". So I was close ;) haha. I have no Idea why it didnt worked :S

EDIT: There is something that is really wrong with this npc. When I say bye myself and go to the npc again and try to buy a addon I allready got, the npc says: "You allready got that addon". If the player say "yes" he can buy it again.. hmm
 
Last edited:
the problem pointed is that, there is no control when the player say YES after buying a outfit. ( code above )
PHP:
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})
the easy and not recomended way is ...
look for ( CTRL+F )
elseif (parameters.confirm == true) then
and past all the content in the square line after it.
Code:
    elseif (parameters.confirm == true) then  -- this next line its for exemple only delete it
-------------------------------------------------------------------------------------
        if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
            npcHandler:say('You already have this addon!', cid)
            npcHandler:resetNpc()
            return true
        end
------------------------------------------------------------------------------------
       local addonNode = node:getParent()  -- this next line its for exemple only delete it
 
the problem pointed is that, there is no control when the player say YES after buying a outfit. ( code above )
PHP:
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})
the easy and not recomended way is ...
look for ( CTRL+F )

and past all the content in the square line after it.
Code:
    elseif (parameters.confirm == true) then  -- this next line its for exemple only delete it
-------------------------------------------------------------------------------------
        if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
            npcHandler:say('You already have this addon!', cid)
            npcHandler:resetNpc()
            return true
        end
------------------------------------------------------------------------------------
       local addonNode = node:getParent()  -- this next line its for exemple only delete it

It dont work :/

This code allready exist in the script.
if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
npcHandler:say('You already have this addon!', cid)
npcHandler:resetNpc()
return true
end

This also allready exist.
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})

Look at the link in the first post ^^
 
You can add storage and then check for this storage under: if(getPlayerMoney(cid)...
Code:
if(getPlayerStorageValue(cid, addoninfo.storageID) == 1) then
      return npcHandler:say('You already have this addon.', cid)
end
 
Last edited:
You can add storage and then check for this storage under: if(getPlayerMoney(cid)...
Code:
if(getPlayerStorageValue(cid, 52356) == 1) then
      return npcHandler:say('You already have this addon.', cid)
end
setPlayerStorageValue(cid, 52356, 1)
the thing is if u do it, the player can never more buy any others addons.
 
Back
Top