• 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 NPC Mission (experience for mission)

It's nice, but I will check this script on my server.
Signed,
Roki
 
I wrote this script for TFS 0.4 and I use only TFS 0.4.
Please, you put error from console..

Thank you for comments :)
Greetings
 
:S that dont works in 0.4

wtJDnu9r.png


Here is better version:
PHP:
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 
local config = {
				{item = 11198, count = 100, storage = 700, value = 1, percent_lv = 5}, --tarantula egg
				{item = 11226, count = 150, storage = 701, value = 1, percent_lv = 7}, --strands of medusa hair
				{item = 5882, count = 300, storage = 702, value = 1, percent_lv = 6}, --red dragon scales
				{item = 5920, count = 400, storage = 703, value = 1, percent_lv = 5} --green dragon scales
				}
if(msgcontains(msg, 'quest')) then 
	selfSay('To start this quest tell {mission}', cid) --This is just an example, In this script added 4 mission for you ;) 
end
    if(msgcontains(msg, 'mission')) then 
		for i = 1, #config do
			if getPlayerStorageValue(cid, config[i].storage) == -1 then 
				selfSay('Your mission will be to get '..config[i].count..' {'..getItemNameById(config[i].item)..'}.', cid) 
				talkState[talkUser] = i
			elseif (getPlayerStorageValue(cid,703) == 1) then --zmieniac w zaleznosci od ostatniego storage!! 
				selfSay('You have done all missions.', cid)
				return true
			end 
        --------------------------------------- 
			if msgcontains(msg, getItemNameById(config[i].item)) and talkState[talkUser] == i then 
				if doPlayerRemoveItem(cid, config[i].item, config[i].count) then 
					doPlayerSetStorageValue(cid, config[i].storage, config[i].value) 
					doPlayerAddPercentLevel(cid, config[i].percent_lv)  
					selfSay('Thank you.', cid) 
					return true
				else 
					selfSay('To end mission you need have '..config[i].count..' {'..getItemNameById(config[i].item)..'}.', cid) 
				end
			end
		end
    end 
end     
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
I do not test it.
neither this one
PTMKHIRZni.png

/no console errors
 
Shit nvm i forgot to add the new lua function :p!!
 
I used this as a base for my quest NPC's that I made recently. Works well, although certain aspects of mine make more sense, but much of them are based off the functions and structures and such of yours :3
 
im new to scripting, I want to make working addon npcs for TFS 8.7, but only do one npc for each set of addons and have more npcs. Could I turn this into one of these npc's? I've tried shortening addon npcs on forums but doesnt work xD
 
I would suggest replacing all 'if msgcontains(msg, '<msg>') then', with 'if msgcontains(msg:lower(), '<msg>') then'. This allows players to say the message with any mix of lowercase and capital letters. If you don't use msg:lower(), they can only say the keyword as it is in the script. Just helps for noobs who think caps lock is cruise-control to cool ;)
 
I would suggest replacing all 'if msgcontains(msg, '<msg>') then', with 'if msgcontains(msg:lower(), '<msg>') then'. This allows players to say the message with any mix of lowercase and capital letters. If you don't use msg:lower(), they can only say the keyword as it is in the script. Just helps for noobs who think caps lock is cruise-control to cool ;)
isn't this supposed to be handled in the function itself, or what the hell are you using?
Code:
function doMessageCheck(message, keyword)
	if(type(keyword) == "table") then
		return table.isStrIn(keyword, message)
	end

	local a, b = message:lower():find(keyword:lower())
	if(a ~= nil and b ~= nil) then
		return true
	end

	return false
end
 
I assume it is supposed to, but in my revision of 0.4 (somewhere in the 3700-3800s I believe), it does not, and it's required to use msg:lower().
 
Back
Top