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

Solved NPC Only works for Gods?

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is his script

Code:
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
 
 
 
 
--------------------------------
------- NPC MISSION  2.0 --------
------ by Acubens - Otland.net -
--------------------------------
 
 
local first = {
-- Place true if you want to use the system of experience as a reward, false if you want to use items as a reward
useExpReward = true,
-- The experience that will get the player at the end of the mission
experience = 1000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 2320, 
-- Count of the item required
item_count = 1,  
-- id of the gift that going to obtain the player at finish the mission 
reward = 2152,
-- count of the gift item
reward_count = 5, 
-- storage
storage = 1004, 
-- name of the quest
questname = "Sewer Worker"
}

local skull = 2320
 
local npc_message ={
 
-- Proceed - message
"So did they overwhelm him and end up, err, killing... him?",
-- if you dont have items - message
"I need proof of what happened to my sewer worker.", 
-- thanks - message
"Well, that is unfortunately bad news, but thank you for telling me what happened and at least you did his original job for me by exterminating the rats.  Here is some cash, go buy some better gear and go exploring!",
-- already done - message
"Well we already know that the sewer worker is dead.  You can hone your skills more before you leave town by killing more rats down there though if you would like to.",
-- ready to go - message
"I sent him down into the sewer to get rid of the rats, but who knows, maybe they {overwhelmed} him and, well, killed him.",
-- congratulations - message
"Congratulations, you have finished the quest: Sewer Worker"
 
}
 
 
if(msgcontains(msg, 'sewer')) then
selfSay(npc_message[5], cid)
end

if(msgcontains(msg, 'key')) and getPlayerStorageValue(cid, 1005) == 1 then
talkState[talkUser] = 2
setPlayerStorageValue(cid, 1005, 2)
doItemSetAttribute(doPlayerAddItem(cid, 2089, 1), "aid", 2004)
elseif (msgcontains(msg, 'key')) and getPlayerStorageValue(cid, 1005) == 2 then
	selfSay("I already gave you the key", cid)
end
 
if(msgcontains(msg, 'overwhelmed')) then
	selfSay(npc_message[1], cid)
	talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
	if (getPlayerStorageValue(cid,first.storage) == 3) then
		selfSay(npc_message[4], cid)
	else
	--getPlayerItemById and getItenNameById     key.actionid == 2504 and
local key = getPlayerItemById(cid, true, skull)
				if key.actionid == 2504 and doPlayerRemoveItem(cid, skull, 1) then
				
			setPlayerStorageValue(cid,first.storage,3)
			if(useExpReward) then
				doPlayerAddExperience(cid,first.experience)
				doPlayerAddItem(cid, 2152, 5)
			else
				doPlayerAddItem(cid,first.reward,first.reward_count)
				doPlayerAddExp(cid, 4000)
			end
			selfSay(npc_message[3], cid)
			doSendMagicEffect(getCreaturePosition(cid), 10)
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
		else
			selfSay(npc_message[2], cid)
		end
	end
return true
end
 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

For some reason, on my God character when I say key to him he will give me the key, but on my normal character he just says nothing when I say key to him.

What is wrong with the script?

Solved: His storage was messed up.
 
Last edited:
Back
Top