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

Small Fix Need for Npc.

Lucenzo

The Way You Move :)
Joined
Jan 29, 2011
Messages
363
Reaction score
14
Location
UK
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

local config = {
	storage = 12256,
}

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, "mission")) then
			npcHandler:say({'My son was captured by trolls? Doesn\'t sound like him, but if you say so. Now you want a reward, huh?...'}, cid)
			setPlayerStorageValue(cid, config.storage, 1) then
      if (msgcontains(msg, "yes")) then
		npcHandler:say({'Look at these dwarven legs. They were forged years ago by a dwarf who was rather tall for our kind. I want you to have them. Thank you for rescuing my son Player.'} then
             doPlayerAddItem(cid, 2504, 1)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay("Bye.", cid)
	end

	return true
end

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

My scripting skills suck. :P
So hoping someone with more knowledge than me could fix this script.

Thanks in Advance x x
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t = {}

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
	elseif msgcontains(msg, 'mission') and getCreatureStorage(cid, 12256) == 1 then
		npcHandler:say('My son was captured by trolls? Doesn\'t sound like him, but if you say so. Now you want a reward, huh?...', cid)
		t[cid] = 1
	elseif t[cid] == 1 then
		if msgcontains(msg, 'yes') then
			doCreatureSetStorage(cid, 12256, 2)
			npcHandler:say('Look at these dwarven legs. They were forged years ago by a dwarf who was rather tall for our kind. I want you to have them. Thank you for rescuing my son ' .. getCreatureName(cid) .. '.', cid)
			doPlayerAddItem(cid, 2504, 1)
		else
			npcHandler:say('Bye.', cid)
		end
		t[cid] = nil
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
player needs the storage to be set at 1 to talk to him about the mission, after he takes the reward it's set to 2
 
LUA:
[20:34:43.886] [Error - LuaInterface::loadFile] data/npc/scripts/Emperor Rehal.lua:23: '}' expected near 't'
[20:34:43.886] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/Emperor Rehal.lua
[20:34:43.886] data/npc/scripts/Emperor Rehal.lua:23: '}' expected near 't'


Thanks for helping :)
 
Back
Top