• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC I would like to share an npc setup I've created nothing special but is of convenience

dchampag

Well-Known Member
Joined
Jul 15, 2008
Messages
679
Reaction score
55
Location
USA
I wanted to do this myself before and when I looked it up I was seeing all sorts of solutions with many complicated changes and what not which of course I just didn't feel like doing cause I didn't want to have to set up every single npc this way only specific ones =) sooo... here we are
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Test" script="data/npc/scripts/test.lua" walkinterval="0" floorchange="0">
    <health now="100" max="100"/>
	<look type="128" head="115" body="106" legs="125" feet="114" addons="3" /> 
    <parameters>
        <parameter key="message_farewell" value="Thank you."/>
    </parameters>
</npc>

and the lua for it

Lua:
local storage = 80001
local storagekills = 80002

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 onCreatureSay(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if getPlayerStorageValue(cid, 80000) > -1 then
		npcHandler:setMessage(MESSAGE_GREET, "Test for if players storage is greater than -1")
		npcHandler:releaseFocus(cid)
	else
		npcHandler:setMessage(MESSAGE_GREET, "hi {test} with me?")
	end
	npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()										npcHandler:onThink()									end

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if(msgcontains(msg, 'test')) then
			npcHandler:say("Testing yes yes", cid)
			setPlayerStorageValue(cid, 80000, 1)
			talkState[talkUser] = 0
	end
	return TRUE
end

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

So basically the point of this is having different greet messages based on the state of your character I used a storage value as if it were a quest but you can do whatever you like with it of course xD

But didn't see anything like it this simple so here you are =d cya later guys
 
Last edited:
Back
Top