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

Bounty Hunter NPC

ScorpiOOn93

etherno.net
Joined
Jun 19, 2008
Messages
662
Reaction score
1
Location
CookieLand :DDD
Hello, I have a little request. I'm using this NPC:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
msg = string.lower(msg)

if (msgcontains(msg, 'hi')) then
selfSay('Hello ' .. getCreatureName(cid) .. '!.',cid)
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.',cid)

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'help') then
selfSay('i can set you a mission.',cid)
talk_state = 0

elseif msgcontains(msg, 'quest') then
if getPlayerStorageValue(cid,2500) == 1 then
selfSay('You have already started this quest.',cid)
talk_state = 0
else
selfSay('I need help with something if you could do that for me?',cid)
talk_state = 2
end

elseif msgcontains(msg, 'bounty') or msgcontains(msg, 'report') then
if getPlayerStorageValue(cid,2505) == -1 then
selfSay('Go and kill the five bountys first!',cid)
talk_state = 0
elseif getPlayerStorageValue(cid,2505) == 1 then
selfSay('Ok all i need now is your list back.',cid)
talk_state = 0
else
selfSay('Ok all i need now is your list back.',cid)
setPlayerStorageValue(cid,2505,1)
end
elseif msgcontains(msg, 'list') then
if getPlayerStorageValue(cid,2505) == -1 then
selfSay('Sorry, you need to kill the five bountys first.',cid)
talk_state = 0

elseif getPlayerItemCount(cid, 1969) == 0 then
selfSay('Sorry, you dont have the item.')
talk_state = 0
else
selfSay('Really have you killed the five bountys and come back with my list?',cid)
talk_state = 1
end
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(cid,1969) >= 1 then
if doPlayerTakeItem(cid,1969,1) == 0 then
selfSay('Thank you and here is your reward.',cid)
doPlayerAddItem(cid,2160,100) -- 100 Crystal Coins.
setPlayerStorageValue(cid,2506,1)
else
selfSay('Sorry, you dont have the item.',cid)
talk_state = 0
end
else
selfSay('Sorry, you dont have the item.',cid)
talk_state = 0
end
end

elseif talk_state == 2 then
if msgcontains(msg, 'yes') then
if getPlayerLevel(cid) >= 50 then -- Level 50
selfSay('Ok good, now go and kill the five bountys and come back with your report',cid)
doPlayerAddItem(cid, 1969, 1)
setPlayerStorageValue(cid,2500,1)
else
selfSay('Sorry, you need level 50 or more to start this quest.',cid)
talk_state = 0
end
end

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good Bye ' .. getCreatureName(cid) .. '',cid)
focus = 0
talk_start = 0
end
end
end

function onCreatureChangeOutfit(creature)
end

function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...',cid)
end
focus = 0
talk_start = 0
end

end

and I need someone who can edit this NPC to working in 100% on TFS 0.3.4, because now it have a bug. NPC is taking the item (id 1969) but he is saying "Sorry, you dont have the item" and he is not giving any reward even when player have everything.
I don't have realy a lot of time so I'll realy appreciate it and give you rep++
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
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, 'help') or msgcontains(msg, 'job') and talkState[talkUser] < 1) then
		npcHandler:say('I can give you bounty hunter mission.', cid)
	elseif(msgcontains(msg, 'mission') or msgcontains(msg, 'quest')) then
		if(getPlayerStorageValue(cid, 2500) == 1) then
			npcHandler:say('Sorry, you have already started quest.', cid)
		else
			npcHandler:say('I need help with.. cleaning few guys, are you interested?', cid)
			talkState[talkUser] = 2
		end
	elseif(msgcontains(msg, 'bounty') or msgcontains(msg, 'report')) then
		if getPlayerStorageValue(cid, 2505) < 1 then
			npcHandler:say('First go and kill five bountys.', cid)
		elseif getPlayerStorageValue(cid, 2505) == 1 then
			npcHandler:say('Okay. All I need is your list back.', cid)
		else
			npcHandler:say('Okay. All I need is your list back.', cid)
			setPlayerStorageValue(cid, 2505, 1)
		end
	elseif msgcontains(msg, 'list') then
		if getPlayerStorageValue(cid, 2505) < 1 then
			npcHandler:say('Okay. All I need is your list back.', cid)
		elseif getPlayerItemCount(cid, 1969) == 0 then
			npcHandler:say('Sorry, you don\'t have the item.', cid)
		else
			npcHandler:say('Do you really killed five bountys and came back with my list?!', cid)
			talkState[talkUser] = 1
		end
	elseif msgcontains(msg, 'yes') then
		if talkState[talkUser] == 1 then
			if doPlayerRemoveItem(cid, 1969, 1) == TRUE then
				npcHandler:say('THANK YOU! Here is your reward.', cid)
				doPlayerAddItem(cid, 2160, 100)
				setPlayerStorageValue(cid, 2506, 1)
				talkState[talkUser] = 0
			else
				npcHandler:say('Sorry! You don\'t have the item.', cid)
				talkState[talkUser] = 0
			end
		elseif talkState[talkUser] = 2 then
			if getPlayerLevel(cid) < 50 then
				npcHandler:say('Sorry! You need 50 level to handle my request.', cid)
				talkState[talkUser] = 0
			else
				npcHandler:say('Good! Now go and kill five bountys, then come back and report me.', cid)
				doPlayerAddItem(cid, 1969, 1)
				setPlayerStorageValue(cid, 2500, 1)
				talkState[talkUser] = 0
			end
		end
	elseif msgcontains(msg, 'no') then
		talkState[talkUser] = 0
		selfSay('Then not.', cid)
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
happy? GM? fri itens? :D
 
Back
Top