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
function Viper(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if doPlayerRemoveItem(cid,parameters.item,parameters.count) then
if (parameters.gender == true) then
doPlayerSetSex(cid, getPlayerSex(cid) == 0 and 1 or 0)
npcHandler:say('Pronto, pode trocar seu outfit!', cid)
npcHandler:resetNpc()
return true
end
local days = parameters.days
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13540)
local timenow = os.time()
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
if string.find(tostring(getCreatureName(cid)),"[[Vip]]") then
setPlayerStorageValue(cid, 13540, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60))
npcHandler:say('Foram adicionados '.. parameters.days ..' dias de VIP no seu character e agora você tem Você tem '.. quantity ..' dias de VIP restantes', cid)
npcHandler:resetNpc()
else
setPlayerStorageValue(cid, 13540, time)
local name = getCreatureName(cid)
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(cid)..";")
doRemoveCreature(cid)
end
return true
end
npcHandler:say('Desculpe, voce nao tem '..parameters.count..' Treiner Coin!', cid)
return true
end
keywordHandler:addKeyword({'ofertas'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Posso trocar seu {gender} e tambem vendo {vip}'})
local node1 = keywordHandler:addKeyword({'vip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Quer comprar vip por 8 Treiner Coins?'})
node1:addChildKeyword({'yes'}, Viper, {gender = false,item = 2159,count = 8,days = 30})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, then.', reset = true})
local node2 = keywordHandler:addKeyword({'gender'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Quer trocar de sexo por 1 Treiner Coin??'})
node2:addChildKeyword({'yes'}, Viper, {gender = true,item = 2159,count = 1})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, then.', reset = true})
npcHandler:addModule(FocusModule:new())