• 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 Little NPC problem.

Sane Mei

New Member
Joined
Feb 21, 2010
Messages
56
Reaction score
0
Hello everyone.

My problem is that I have made a NPC'er, and you can change soul orbs for stone skins, but when I change soul orbs for stone skin, I am getting ssa so it works good, but it has got only 1 charge, and I have setted already in items.xml charge 5 for stone skin amulet. Same problem for might rings.

Does anyone know how to fix it?

My code, not all of the script but the part where you change soul orbs for ss'a etc.

Code:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local config = {
				[1] = {co_trzeba_mowic = "Stone Skin Amulet", ile_soul_orbow = 20, co_sie_dostaje = 2197, talkstate = 1},
				[2] = {co_trzeba_mowic = "Time Ring", ile_soul_orbow = 10, co_sie_dostaje = 2169, talkstate = 2},
				[3] = {co_trzeba_mowic = "Might Ring", ile_soul_orbow = 25, co_sie_dostaje = 2164, talkstate = 3},
				[4] = {co_trzeba_mowic = "Blue Robe", ile_soul_orbow = 11, co_sie_dostaje = 2656, talkstate = 4}
				}
for i=1, #config do
if msgcontains(msg, config[i].co_trzeba_mowic) then
	selfSay("So, you want to buy from me 1 "..getItemNameById(config[i].co_sie_dostaje).." for "..config[i].ile_soul_orbow.." soul orbs?", cid) 
	talkState[talkUser] = config[i].talkstate
elseif msgcontains(msg, "yes") and talkState[talkUser] == config[i].talkstate then 
	if getPlayerItemCount(cid, 5944) >= config[i].ile_soul_orbow then
		selfSay("Here you are.", cid) 
        doPlayerRemoveItem(cid, 5944, config[i].ile_soul_orbow)
		doPlayerAddItem(cid, config[i].co_sie_dostaje, 1)
    else
        selfSay("You don't have enough soul orbs.", cid)
    end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

co_trzeba_mowic = what_to_say

co_sie_dostaje = what_you_get

Thanks in advance :)
 
Lua:
	local t = {
		['Stone Skin Amulet']= {orbs = 20, item = 2197},
		['Time Ring'] = {orbs = 10, item = 2169},
		['Might Ring'] = {orbs = 25, item = 2164},
		['Blue Robe'] = {orbs = 11, item = 2656}
	}
	if talkState[cid] then
		if msgcontains(msg, 'yes') then 
			local v = t[talkState[cid]]
			if doPlayerRemoveItem(cid, 5944, v.orbs) then
				selfSay('Here you are.', cid)
				doPlayerAddItem(cid, v.item, math.max(1, getItemInfo(v.item).charges))
			else
				selfSay('You don\'t have enough soul orbs.', cid)
			end
		else
			selfSay('Maybe later.', cid)
		end
		talkState[cid] = nil
	else
		for k,v in pairs(t) do
			if msgcontains(msg, k) then
				selfSay('So, you want to buy from me 1 '..getItemInfo(v.item).name..' for '..v.orbs..' soul orbs?', cid) 
				talkState[cid] = k
				break
			end
		end
	end
	return true
end

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