• 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 Edit?

EagerBeaver

New Member
Joined
Jul 22, 2015
Messages
4
Reaction score
0
Hello!

I'm looking for someone who can make this script instead of require 10 gold, requires 10 small sapphires (ID: 2146)

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
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addBuyableItem({'assassin star'}, 7368, 10, 100,'assassin star')
 
 
npcHandler:addModule(FocusModule:new())

Would really love the help!
 
You can change gold nugget id for small sapphires id, although it will still show gold in the shop window, and only allow 1 item to be bought at a time.
https://otland.net/threads/npc-remove-gold-nugget-how-to-do.230184/#post-2218930

Alternatively you could make a custom npc which will sell it as you intend.
(below is mostly tested, but should work.)
(place it underneath the normal npc functions)
(note: This is for 0.3.7, as you never stated your TFS)
(note2: You could easily place it in a table so you don't have a million elseif statements)
Code:
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, "trade") then
     selfSay("Would you like to buy {10 assassin stars},{50 assassin stars}, or {100 assassin stars}?", cid) 
   
   elseif msgcontains(msg, "10 assassin star") then
     selfSay("Would you like to buy 10 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 1 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 10)) then
         if doPlayerAddItem(cid, 7368, 10, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 1)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 10 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 10)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
   
   elseif msgcontains(msg, "50 assassin star") then
     selfSay("Would you like to buy 50 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 2
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 5 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 50)) then
         if doPlayerAddItem(cid, 7368, 50, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 5)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 50 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 50)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
   
   elseif msgcontains(msg, "100 assassin star") then
     selfSay("Would you like to buy 100 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 3
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 10 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 100)) then
         if doPlayerAddItem(cid, 7368, 100, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 10)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 100 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 100)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
   
   elseif msgcontains(msg, "") and talkState[talkUser] >= 1 then
     selfSay("No then.", cid)
     talkState[talkUser] = 0 
   end
   
   return true 
end
 
Last edited:
You can change gold nugget id for small sapphires id, although it will still show gold in the shop window, and only allow 1 item to be bought at a time.
https://otland.net/threads/npc-remove-gold-nugget-how-to-do.230184/#post-2218930

Alternatively you could make a custom npc which will sell it as you intend.
(below is mostly tested, but should work.)
(place it underneath the normal npc functions)
(note: This is for 0.3.7, as you never stated your TFS)
(note2: You could easily place it in a table so you don't have a million elseif statements)
Code:
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, "trade") then
     selfSay("Would you like to buy {10 assassin stars},{50 assassin stars}, or {100 assassin stars}?", cid)
 
   elseif msgcontains(msg, "10 assassin star") then
     selfSay("Would you like to buy 10 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 1 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 10)) then
         if doPlayerAddItem(cid, 7368, 10, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 1)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 10 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 10)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
 
   elseif msgcontains(msg, "50 assassin star") then
     selfSay("Would you like to buy 50 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 2
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 5 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 50)) then
         if doPlayerAddItem(cid, 7368, 50, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 5)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 50 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 50)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
 
   elseif msgcontains(msg, "100 assassin star") then
     selfSay("Would you like to buy 100 assassin stars for 1 small sapphire?", cid)
     talkState[talkUser] = 3
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if getPlayerItemCount(cid, 2146) >= 10 then
       if getPlayerFreeCap(cid) >= (getItemWeightById(7368, 100)) then
         if doPlayerAddItem(cid, 7368, 100, false) == RETURNVALUE_NOERROR then
           doPlayerRemoveItem(cid, 2146, 10)
           selfSay("Here you are.", cid)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 100 assassin stars for 1 small sapphire.")
           talkState[talkUser] = 0
         else
           selfSay("You require free inventory space to obtain more items.", cid)
         end
       else
         selfSay("You require ".. (getItemWeightById(7368, 100)).." capacity to obtain this transaction.", cid)
       end
     else
       selfSay("You don't have enough small sapphires for this transaction.", cid)
     end
 
   elseif msgcontains(msg, "") and talkState[talkUser] >= 1 then
     selfSay("No then.", cid)
     talkState[talkUser] = 0
   end
 
   return true
end

Sorry it's for 1.1/1.2 :S I was hoping it could remain a table too for multiple options incase I add other ammo's
 
Well I don't know 1.1/1.2, but you'd want to do something similar to this.. you'd just need to convert it.

Code:
local xmsg = {} -- somewhere up with the other functions
.
.
.
function creatureSayCallback(cid, type, msg)
  if(not npcHandler:isFocused(cid)) then
  return false
  end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

   local currency      = 2146
   local player_money   = getPlayerItemCount(cid,currency)

   local config = {
     ["item"] = {itemID = 11111111, price = 1, amount = 1, name = "item"},
     ["item2"] = {itemID = 111111111, price = 100, amount = 100, name = "item2"},
   }

   local x = config[msg:lower()]
   if msgcontains(msg, "trade") then
  local text = ""
  for i, x in pairs(config) do
  if text ~= "" then
  text = text.. " | "
  end
  text = text..config[i].name
  end
  selfSay("I sell items for ".. getItemNameById(currency) ..". The items I have for sale are | " ..text.. ".", cid)

   elseif x then
     selfSay("Would you like to buy "..x.amount.." "..x.name.." for "..x.price.." ".. getItemNameById(currency) .."?", cid)
     talkState[talkUser] = 1
     xmsg[cid] = msg
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     local x = config[xmsg[cid]:lower()]
     if player_money >= x.price then
       doPlayerRemoveItem(cid,6500,x.price)
       doPlayerAddItem(cid,x.itemID,x.amount)
       selfSay("Thank you kind sir. Here is your "..x.name..".", cid)
       talkState[talkUser] = 0
     else
       selfSay("You do not have enough ".. getItemNameById(currency) .." for this item.", cid)
       talkState[talkUser] = 0
     end

   elseif msgcontains(msg, "") and talkState[talkUser] >= 1 then
     selfSay("No then.", cid)
     talkState[talkUser] = 0

   end

   return true
end

Anyways good luck!
 
Last edited:
Would anyone be so kind to convert that to 1.1 :)?
test it and tell me what problem you get
Code:
local xmsg = {} -- somewhere up with the other functions

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

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

   local currency      = 2146
   local player_money   = getPlayerItemCount(cid,currency)

   local config = {
     ["item"] = {itemID = 11111111, price = 1, amount = 1, name = "item"},
     ["item2"] = {itemID = 111111111, price = 100, amount = 100, name = "item2"},
   }

   local x = config[msg:lower()]
   if msgcontains(msg, "trade") then
  local text = ""
  for i, x in pairs(config) do
  if text ~= "" then
  text = text.. " | "
  end
  text = text..config[i].name
  end
  selfSay("I sell items for ".. getItemName(currency) ..". The items I have for sale are | " ..text.. ".", cid)

   elseif x then
     selfSay("Would you like to buy "..x.amount.." "..x.name.." for "..x.price.." ".. getItemName(currency) .."?", cid)
     talkState[talkUser] = 1
     xmsg[cid] = msg
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     local x = config[xmsg[cid]:lower()]
     if player_money >= x.price then
       doPlayerRemoveItem(cid,6500,x.price)
       doPlayerAddItem(cid,x.itemID,x.amount)
       selfSay("Thank you kind sir. Here is your "..x.name..".", cid)
       talkState[talkUser] = 0
     else
       selfSay("You do not have enough ".. getItemName(currency) .." for this item.", cid)
       talkState[talkUser] = 0
     end

   elseif msgcontains(msg, "") and talkState[talkUser] >= 1 then
     selfSay("No then.", cid)
     talkState[talkUser] = 0

   end

   return true
end
 
Back
Top