local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
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)
local s = getPlayerStorageValue(cid, storage)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
local voc = 6000
local ilosc = 1
local item = 2160
local storage = 5000
if msgcontains(msg, 'promocja') then
if getPlayerItemCount(cid, item) >= ilosc and getPlayerStorageValue(storage) == -1 then
if getPlayerVocation(cid) == 1 then
selfSay("Jaka chcesz otrzymac profesje?", second, cid)
talkState[talkUser] = 1
elseif getPlayerVocation(cid) == 4 then
selfSay("Jaka chcesz otrzymac profesje?", second, cid)
talkState[talkUser] = 2
elseif getPlayerVocation(cid) == 7 then
selfSay("Jaka chcesz otrzymac profesje?", second, cid)
talkState[talkUser] = 3
end
end
elseif msgcontains(msg, 'numer 2') then
if talkState[talkUser] == 1 then
doPlayerSetVocation(cid, 2)
selfSay("Profesja numer 2", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, 'numer 3') then
if talkState[talkUser] == 1 then
doPlayerSetVocation(cid, 3)
selfSay("Profesja numer 3", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, 'numer 5') then
if talkState[talkUser] == 2 then
doPlayerSetVocation(cid, 5)
selfSay("Profesja numer 5", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, 'numer 6') then
if talkState[talkUser] == 2 then
doPlayerSetVocation(cid, 6)
selfSay("Profesja numer 6", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, 'numer 8') then
if talkState[talkUser] == 3 then
doPlayerSetVocation(cid, 8)
selfSay("Profesja numer 8", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, 'numer 9') then
if talkState[talkUser] == 3 then
doPlayerSetVocation(cid, 9)
selfSay("Profesja numer 9", second, cid)
doPlayerRemoveItem(cid, item, ilosc)
setPlayerStorageValue(cid, storage, 1)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())