Hello guys, could someone help me with my script? It is my first npc ever, so dont be rude
Engine message :
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
firstpromotionlevel = 'You have to be at least 30 level to become warrior! Come back when you got stronger.'
cantskippromo = 'You specialize in something else, Bye!'
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "Warrior") then
selfSay("So you want to know more about us? Okay! We specialize in close combat battle, our weapon are swords, axes or clubs. Warriors are always in the first line in battle. To become one of us you have to be tough and brave. Are you intrested about joining us?", cid)
talkState[talkUser] = 1
else if msgcontains(msg,"yes") and talkState[talkUser] == 1 and player:getLevel() < promolevel than
selfSay(firstpromotionlevel, cid)
talkState[talkUser] = 2
return false
else if msgcontains(msg, "Warrior") and talkState[talkUser] == 2 then
selfSay("So you got stronger, i see your fighting spirit, you remaind me of myself from young ages. Are you ready for becoming warrior?", cid)
talkState[talkUser] = 3
else if msgcontains(msg,"yes") and talkState[talkUser] == 3 then
selfSay("So, from now on you are one of us, wear this outfit with proud.",cid)
doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 134 or 142, 2)
player:setVocation(2)
talkState[talkUser] = 4
else if msgcontains(msg,"no") and talkState[talkUser] == 1 than
selfSay("So i hope that you will find specialization that suits you. Good Luck !", cid)
talkState[talkUser] = 0
else if msgcontains(msg,"no") and talkState[talkUser] == 3
selfSay("Okay, take your time, come back when you be ready !", cid)
talkState[talkUser] = 2
else if msgcontains(msg,"Warrior") and talkState[talkUser] == 4 than
selfSay("I hope that you feel good among us, my friend", cid)
return false
else if msgcontains(msg,"yes") and player:getVocation():getId() == 5 or player:getVocation():getId() == 8 or player:getVocation():getId() == 11 than
selfSay(cantskippromo, cid)
return false
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Engine message :