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

Edit npc script! help :)

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I have this npc script, the script sell ring for item id: 2258 and its be fine but my ring must have 100 charges left but when I buy it the ring have only 1 charge left... please edit my script and make 100 charges for the ring.

the code:
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 shopWindow = {}
local things = {
     {id = 7697, buy = 1, name = "Physical ring"},
}

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
     if doPlayerRemoveItem(cid, 2258, shopWindow[item].Price*amount) then
         if isItemStackable(item) then
             doPlayerAddItem(cid, item, amount)
         else
             for x = 1, amount do
                 doPlayerAddItem(cid, item, 1)
             end
         end
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought "..amount.."x "..shopWindow[item].Name.." for "..shopWindow[item].Price*amount.." gold nuggets.")
     else
         selfSay("Nie posiadasz Broken physical ring!.", cid)
     end
     return true
end


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

     if msgcontains(msg, 'trade') then
         for var, item in pairs(things) do
             shopWindow[item.id] = {Price = item.buy, Name = item.name}
         end
         openShopWindow(cid, things, onBuy, onSell)
     end
     return true
end

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



Thanks for help ++
 
Back
Top