Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado
  • Autor
20 horas atrás, Sttorm disse:

@peterson18


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 money = 1000 -- Custo
local id = 7122 --  id do Book
local text = "Livro misterioso" 

local item = doPlayerAddItem(cid, id, 1)


	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'yes')) then
	
                        if doPlayerRemoveMoney(cid, money) then
                           doSetItemText(item, text)
						   selfSay('Obrigado', cid)
                        else
                            selfSay('Você precisa de '.. money ..' de money para comprar esse livro', cid)
                        end


    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 


Esta com um bug, depois que falo "Hi" ele começa a criar o item 7122, para qualquer coisa que eu fale ele cria o item....

  • Respostas 13
  • Visualizações 706
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tava faltando uns parametros , aqui vai : local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} f

Posted Images

Postado
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 money = 1000 -- Custo
local id = 7122 --  id do Book
local text = "Livro misterioso" 

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'yes')) then
	
                        if doPlayerRemoveMoney(cid, money) then
                           doSetItemText(doPlayerAddItem(cid, id, 1), text)
						   selfSay('Obrigado', cid)
                        else
                            selfSay('Você precisa de '.. money ..' de money para comprar esse livro', cid)
                        end


    end
end

Vamos ver se isso resolve , você quer que o player compre o item somente uma vez ?

Postado
  • Autor
1 hora atrás, Sttorm disse:

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 money = 1000 -- Custo
local id = 7122 --  id do Book
local text = "Livro misterioso" 

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'yes')) then
	
                        if doPlayerRemoveMoney(cid, money) then
                           doSetItemText(doPlayerAddItem(cid, id, 1), text)
						   selfSay('Obrigado', cid)
                        else
                            selfSay('Você precisa de '.. money ..' de money para comprar esse livro', cid)
                        end


    end
end

Vamos ver se isso resolve , você quer que o player compre o item somente uma vez ?

 

Não, ele pode comprar quantas vezes quiser

 

@Sttorm
Não esta funcionando falo "Hi" e ele não responde

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

Postado

XML

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Bookero" script="book.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="142" head="114" body="0" legs="95" feet="114" corpse="2212"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell book, say {yes}."/>
	</parameters>
</npc>

Script

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 money = 1000 -- Custo
local id = 7122 --  id do Book
local text = "Livro misterioso" 

	if(msgcontains(msg, 'yes')) then
	
                        if doPlayerRemoveMoney(cid, money) then
                           doSetItemText(doPlayerAddItem(cid, id, 1), text)
						   selfSay('Obrigado', cid)
                        else
                            selfSay('Você precisa de '.. money ..' de money para comprar esse livro', cid)
                        end


    end
end

 

Postado
  • Autor
21 horas atrás, Sttorm disse:

XML


<?xml version="1.0" encoding="UTF-8"?>
<npc name="Bookero" script="book.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="142" head="114" body="0" legs="95" feet="114" corpse="2212"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell book, say {yes}."/>
	</parameters>
</npc>

Script


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 money = 1000 -- Custo
local id = 7122 --  id do Book
local text = "Livro misterioso" 

	if(msgcontains(msg, 'yes')) then
	
                        if doPlayerRemoveMoney(cid, money) then
                           doSetItemText(doPlayerAddItem(cid, id, 1), text)
						   selfSay('Obrigado', cid)
                        else
                            selfSay('Você precisa de '.. money ..' de money para comprar esse livro', cid)
                        end


    end
end

 


Não responde, acho que ela é tímida hueheuheh
 

Spoiler

image.thumb.png.1205b38cb69b397f4969efd204c69c85.png

 

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.6k

Informação Importante

Confirmação de Termo