• 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 buying vials custom script [Need Help]

pawelzion

New Member
Joined
May 5, 2009
Messages
132
Reaction score
0
Location
Poland
Hello

Here's NPC who buys vials script:
Code:
local keywordHandler = KeywordHandler:new()   
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys

		if msgcontains(msg, 'job') or msgcontains(msg, 'help') then
			selfSay('I can give you a "lottery ticket" for empty vials.')
------------------------------------------------ addon ------------------------------------------------
		elseif msgcontains(msg, 'lottery ticket') then
			if isPremium(cid) then
			selfSay('Do you want to exchange great or divine empty potions?')
			talk_state = 1
				elseif msgcontains(msg, 'great') and talk_state == 1 then	
					if getPlayerItemCount(cid,7635) >= 50 then
						selfSay('Did you bring me 50 empty great potions for a lottery ticket?')
						talk_state = 2
					else
						selfSay('I need 50 empty great potions, to give you the lottery ticket. Come back when you have them.')
						talk_state = 0
					end
				elseif msgcontains(msg, 'divine') and talk_state == 1 then
					if getPlayerItemCount(cid, 7634) >= 200 then
						selfSay('Did you bring me 200 empty divine potions for a lottery ticket?')
						talk_state = 3
					else
						selfSay('I need 200 empty great potions, to give you the lottery ticket. Come back when you have them.')
						talk_state = 0
					end
				else 
					selfSay('Ok, then.')
					talk_state = 0
				end
			else
				selfSay('I will deal only with premium characters.')
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,7635) >= 200 then
					if doPlayerRemoveItem(cid,2006,200) then
                    	doPlayerAddItem(cid,5957,1)
					end
			end
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if getPlayerItemCount(cid,7634) >= 200 then
					if doPlayerRemoveItem(cid,7634,200) then
                    	doPlayerAddItem(cid,5957,1)
					end
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
			selfSay('Ok than.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

I have error's in console , can anyone help me ?

Code:
[05/07/2009 01:25:50] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/ticket.lua
[05/07/2009 01:25:50] data/npc/scripts/ticket.lua:55: 'end' expected (to close 'function' at line 12) near 'elseif'
 
Back
Top