Booker
New Member
- Joined
- Apr 2, 2015
- Messages
- 46
- Reaction score
- 4
I have the following script of an NPC who changes my vocation:
It works well, but i want the NPC to give my instantly and outfit and take another one from me. Note that it needs to change by the time the words "yes" are said (to accept the vocation).
Should i use a string like "DoChangeCreatureOutfit" or something like that? I want him to take the outfit 250 away and give me the outfit 460.
Thanks fellas
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
local stg = 57894
if getPlayerStorageValue(cid, stg) < 1 then
if msgcontains(msg:lower(), 'sorcerer') then
npcHandler:say('A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid)
talkState[talkUser] = 1
elseif msgcontains(msg:lower(), 'druid') then
npcHandler:say('A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid)
talkState[talkUser] = 2
elseif msgcontains(msg:lower(), 'paladin') then
npcHandler:say('A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid)
talkState[talkUser] = 3
elseif msgcontains(msg:lower(), 'knight') then
npcHandler:say('A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid)
talkState[talkUser] = 4
elseif msgcontains(msg:lower(), 'yes') then
if talkState[talkUser] == 1 then
doPlayerSetVocation(cid, 1)
npcHandler:say('SO BE IT!', cid)
setPlayerStorageValue(cid, stg, 1)
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
doPlayerSetVocation(cid, 2)
npcHandler:say('SO BE IT!', cid)
setPlayerStorageValue(cid, stg, 1)
talkState[talkUser] = 0
elseif talkState[talkUser] == 3 then
doPlayerSetVocation(cid, 3)
npcHandler:say('SO BE IT!', cid)
setPlayerStorageValue(cid, stg, 1)
talkState[talkUser] = 0
elseif talkState[talkUser] == 4 then
doPlayerSetVocation(cid, 4)
setPlayerStorageValue(cid, stg, 1)
npcHandler:say('SO BE IT!', cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg:lower(), 'no') then
npcHandler:say(getCreatureName(cid) .. ', WHAT KIND OF PROFESSIONAL DO YOU WANNA BE? KNIGHT, PALADIN, SORCERER, OR DRUID?', cid)
talkState[talkUser] = 0
elseif msgcontains(msg:lower(), 'bye') then
npcHandler:say('Good bye.', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('YOU ALREADY HAVE VOCATION!', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It works well, but i want the NPC to give my instantly and outfit and take another one from me. Note that it needs to change by the time the words "yes" are said (to accept the vocation).
Should i use a string like "DoChangeCreatureOutfit" or something like that? I want him to take the outfit 250 away and give me the outfit 460.
Thanks fellas