local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
-------------local shot
local GUILD1 = guildname
local GUILD1TYPE = guild
----------------localshit
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'guild') or msgcontains(msg, 'found') or msgcontains(msg, 'join') then
if getPlayerGuildId(cid) == 0 then
if getPlayerLevel(cid) >= 50 then
selfSay('Do you want to join in ' .. GUILD1 .. '?')
talk_state = 10
else
selfSay('You must be level 50 or more to join in the guild.')
return false
end
else
selfSay('You already are in a guild.')
return false
end
elseif talk_state == 10 then
if msgcontains(msg, GUILD1TYPE) then
selfSay('' .. GUILD1 .. ', are you sure? This decision is irreversible!')
talk_state = 11
end
elseif talk_state == 11 then
if msgcontains(msg, 'yes') then
cname = getPlayerName(cid)
selfSay('Congratulations ' .. cname .. ', you are now a member of the ' .. GUILD1 .. '!')
guildid1 = getGuildId(GUILD1)
doPlayerSetGuildId(cid, guildname)
doPlayerSetGuildRank(cid,1)
doPlayerSendTextMessage(cid,19,"You can now enter in your guild channel.")
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())