Ir para conteúdo

Featured Replies

Postado

Boa noite

 

eu tenho esse script de um npc que vende uma promoção

 

Mostrar conteúdo oculto

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
local price = 1000000
local vocations = {5,6,7,8}
if(msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion')) then
selfSay('Você quer ser promovido vip por '..price..' moedas? {yes} ', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(vocations, getPlayerVocation(cid)) then
if doPlayerRemoveMoney(cid,price) == TRUE then
if getPlayerVocation(cid) == 5 then doPlayerSetVocation(cid, 9)
end

if getPlayerVocation(cid) == 6 then doPlayerSetVocation(cid, 10)
end


if getPlayerVocation(cid) == 7 then doPlayerSetVocation(cid, 11)
end

if getPlayerVocation(cid) == 8 then doPlayerSetVocation(cid, 12)
end
selfSay('Parabens! Você foi promovido vip! ', cid)
talkState[talkUser] = 0
else
selfSay('Você não tem ' .. price .. ' moedas para ser promovido vip...', cid)
talkState[talkUser] = 0
end
else
selfSay('Desculpe, você precisa ter a member promotion para ser promovido vip.', cid)
talkState[talkUser] = 0
end
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

no caso vc precisa desse valor 1000000 para comprar, no caso eu queria trocar esse valor (gold) por item por exemplo: vc so pode comprar a vocação se tiver  10 majore cristaline.

 

alguem consegue me ajudar... ??

 

Rep++

Obrigado

Editado por maper007 (veja o histórico de edições)

Resolvido por Wakon

Ir para solução
Postado
  • Solução

Modifiquei pra você, testa ai:

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
local item = 2159 -- ID Do item a ser cobrado.
local price = 10 -- Quantidade a ser cobrada.
local vocations = {5,6,7,8}
if(msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion')) then
selfSay('Você quer ser promovido vip por '..price..' moedas? {yes} ', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(vocations, getPlayerVocation(cid)) then
if getPlayerItemCount(cid, item) >= price then
if getPlayerVocation(cid) == 5 then doPlayerSetVocation(cid, 9)
doPlayerRemoveItem(cid, item, price)
end

if getPlayerVocation(cid) == 6 then doPlayerSetVocation(cid, 10)
doPlayerRemoveItem(cid, item, price)
end


if getPlayerVocation(cid) == 7 then doPlayerSetVocation(cid, 11)
doPlayerRemoveItem(cid, item, price)
end

if getPlayerVocation(cid) == 8 then doPlayerSetVocation(cid, 12)
doPlayerRemoveItem(cid, item, price)
end
selfSay('Parabens! Você foi promovido vip! ', cid)
talkState[talkUser] = 0
else
selfSay('Você não tem ' .. price .. ' moedas para ser promovido a vip...', cid)
talkState[talkUser] = 0
end
else
selfSay('Desculpe, você precisa ter a member promotion para ser promovido vip.', cid)
talkState[talkUser] = 0
end
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

EDIT:

Esqueci de colocar pra cobrar o item, mals.

Editado por Wakon (veja o histórico de edições)

Postado
  • Autor
  Em 24/03/2015 em 22:31, Wakon disse:

Modifiquei pra você, testa ai:

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
local item = 2159 -- ID Do item a ser cobrado.
local price = 10 -- Quantidade a ser cobrada.
local vocations = {5,6,7,8}
if(msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion')) then
selfSay('Você quer ser promovido vip por '..price..' moedas? {yes} ', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(vocations, getPlayerVocation(cid)) then
if getPlayerItemCount(cid, item) >= price then
if getPlayerVocation(cid) == 5 then doPlayerSetVocation(cid, 9)
doPlayerRemoveItem(cid, item, price)
end

if getPlayerVocation(cid) == 6 then doPlayerSetVocation(cid, 10)
doPlayerRemoveItem(cid, item, price)
end


if getPlayerVocation(cid) == 7 then doPlayerSetVocation(cid, 11)
doPlayerRemoveItem(cid, item, price)
end

if getPlayerVocation(cid) == 8 then doPlayerSetVocation(cid, 12)
doPlayerRemoveItem(cid, item, price)
end
selfSay('Parabens! Você foi promovido vip! ', cid)
talkState[talkUser] = 0
else
selfSay('Você não tem ' .. price .. ' moedas para ser promovido a vip...', cid)
talkState[talkUser] = 0
end
else
selfSay('Desculpe, você precisa ter a member promotion para ser promovido vip.', cid)
talkState[talkUser] = 0
end
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

EDIT:

Esqueci de colocar pra cobrar o item, mals.

blz vo testa aki ja volto

 

 

edit 2 deu certinho aki ... vlw... rep+

Editado por maper007 (veja o histórico de edições)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo