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
if(msgcontains(msg, 'rebirth')) then
selfSay('Ready for me to rebirth you?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
local level = 60000 -- Put here the level to rebirth
local cost = 5000000000 -- Put here the cost to rebirth in GP (20000 = 20k)
local id = getPlayerGUID(cid)
local name = getCreatureName(cid)
local vocation = getPlayerVocation(cid)
if getPlayerLevel(cid) >= level then
if doPlayerRemoveItem(cid,2157,5000) == TRUE then
if(isInArray({9,10,11,12,25,26,27,28}, getPlayerVocation(cid)) == TRUE) then
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
elseif vocation == 9 then
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
elseif vocation == 10 then
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
elseif vocation == 11 then
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
elseif vocation == 12 then
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
else
selfSay('Not a valid vocation. Contact administrator.', cid)
talkState[talkUser] = 0
end
else
selfSay('You need 5,000 GN to Reborn.', cid)
end
end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
talkState[talkUser] = 0
selfSay('Okey come back when you are ready.', cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())