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())
- Fórum
- xTibia - Notícias e Suporte
- Soluções
- Archived
- [Npc] Vip - Problemas
3
970
info
Grupo: Campones
Registrado: 26/02/11
Posts: 20
Reputação: 0

27 de fevereiro de 2011 às 14:18


info
Grupo: Campones
Registrado: 27/02/11
Posts: 0
Reputação: 0
Ola,
Criei um npc que o objetivo era retirar o itens 2195 em troca de algumas vantagens. Até ai tudo bem, só que na hora de executar acontece um erro.
Segue abaixo informações
The Forgotten Server, version 0.3.6 (Crying Damson)
Versão 8,54
treiner.lua
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, 'vip')) then selfSay('Quer comprar vip por 8 Treiner Coins?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(getPlayerItemCount(cid, 2159) >= 8) then if(doPlayerRemoveItem(cid, 2159, 8)) then local item = getPlayerItemById(cid, true, 6530) selfSay('Here you are.', cid) local price = 8 if doPlayerRemoveItem(cid, 2159, price) == TRUE then local days = 30 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 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.") setPlayerStorageValue(cid, 13540, time) local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60)) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.") setPlayerStorageValue(cid, 13540, time) local name = getCreatureName(cid) db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(cid)..";") doRemoveCreature(cid) end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." Treiner Coins para colocar vip.") end else selfSay('Desculpe, você não tem Treiner Coins suficientes.', cid) end else selfSay('Desculpe, você não tem Treiner Coins suficientes.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'gender')) then selfSay('Quer comprar trocar de sexo por 1 Treiner Coin?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerItemCount(cid, 2159)) >= 1 then if doPlayerRemoveItem(cid, 2159, 1) == TRUE then doPlayerSetSex(cid, getPlayerSex(cid) == 0 and 1 or 0) selfSay('Pronto, pode trocar seu outfit.', cid) talkState[talkUser] = 0 end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerItemCount(cid, 2159)) < 1 then selfSay('Voce não tem o Treiner Coin.', cid) talkState[talkUser] = 0 elseif(msgcontains(msg, 'ofertas')) then selfSay('Posso trocar seu { gender } e tambem vendo { vip }.', cid) elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then talkState[talkUser] = 0 selfSay('Ok então.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())treiner.xml
<?xml version="1.0" encoding="UTF-8"?> <npc name="Treiner Seller" script="treiner.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="128" head="17" body="54" legs="114" feet="0" addons="2"/> <parameters> <parameter key="message_greet" value="Oi |PLAYERNAME|, vendo artigos por Treiner Coins. Veja minhas { ofertas }."/> </parameters> </npc>O erro apresentado é(aparece na gui):
Então é isso, seria bom se vocês me ajudassem a resolver essa gambiarra esse npc que estou fazendo.
Aguardo Respostas,
Coyoty