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
and the lua for it
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
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: