Erro Numa Script De Npc

lukas8118
em Lixeira Pública

lukas8118

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/07Posts: 1

Olha eu tentei tentei e saiu isso dae é minha primeira script :

 

	if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then
	   elseif getPlayerLevel >= 9 then
		  selfSay('Você deseja comprar a magia {Light Healing} ?', cid)
		  talkState[talkUser] = 1
	   else
		  selfSay('Você não tem level suficiente.', cid)
	end

 if talkState[talkUser] == 1 then		  
	   elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') then
		  elseif pay(cid,1) then
		  doPlayerLearnInstantSpell(cid, 'Light Healing')
		  selfSay('Você aprendeu a magia {Light healing}.', cid)
	   else
		  selfSay('Você não tem dinheiro suficiente!', cid)
	end

 

O executavel do ot nao da nenhum detalhe sobre o erro so fala que nao foi possivel carregar...

 

Eu colokei talk state pq eu não tava entendendo mtu bem como posicionar os else sem os talk state , entao queria saber como posicionar eles sem o talk state.

 

Outra duvida é como fasso para os char que criarem conta no acc manager nao virem com todas as magias ( essa duvida só to dizendo aki pra ver se alguem sabe se nao souberem eu posto la na area certa ) .

 

vlw

lucasjockey

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 30/07/07Posts: 101
local cost = 1000

if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then

if doPlayerRemoveMoney(cid, cost) == TRUE then

doPlayerLearnInstantSpell(cid, 'Light Healing')

selfSay('Você aprendeu a magia {Light healing}.', cid)

else

selfSay('Você não tem dinheiro suficiente!', cid)

end

end

 

Preço da magia em vermelho.

x[sup]2[/sup]=-1
x=i
:D

lukas8118

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/07Posts: 1

Eu adiciono isso com a primeira parte ( que vai até o primeiro end ) e removo a segunda?

satan666

Antichrist Superstar
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 07/05/08Posts: 612Char no Tibia: leviana luciferiana

pelo visto sim porque ele esta usando o talkstate entao seria a segunda parte do script.

 

vai em spells.xml e la procura por isso:

 

needlearn="x"

 

se tiver 0 e porque nao necessita aprender a magia se tiver 1 precisa aprender a magia.

creationb.jpg

"Um Deus que usasse seu poder para criar seres humanos que de antemão sabia que seriam atormentados eternamente, e que os predestinasse a isso,



não poderia ser sábio, nem justo e tampouco amoroso.

Além de nos submeter a isso vim a nos julgar e condenar por nossos atos aos tormentos do inferno.

pra minha pessoa isso não é um Deus Pai amoroso e bondoso como o chaman, seu padrão seria muito mais inferior do que o de muitos homens."

lukas8118

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/07Posts: 1

@Marcryzius

Obrigado não sabia disso de learnspells xD

 

@TOPIC

 

O alguem pode me ajudar agora o problema é que o npc não responde quando eu falo hi >.< quando eu mechia em 8.1 ( raramente.. ) tinha la os negocios de hi mas eu olhei scripts de varios npc do ot 8.40 aki e nenhum eu encherguei algo com hi nem nada parecido vo manda a script do npc :

 

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, 'Light Healing') or msgcontains(msg, 'light healing') then
	   elseif getPlayerLevel >= 9 then
		  selfSay('Você deseja comprar a magia {Light Healing} ?', cid)
		  talkState[talkUser] = 1
	   else
		  selfSay('Você não tem level suficiente.', cid)
	end
	end

local cost = 1000
if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then 
if doPlayerRemoveMoney(cid, cost) == TRUE then
doPlayerLearnInstantSpell(cid, 'Light Healing')
selfSay('Você aprendeu a magia {Light healing}.', cid)
else
selfSay('Você não tem dinheiro suficiente!', cid)
end
end

 

Alias, muito obrigado lucasjockey!

satan666

Antichrist Superstar
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 07/05/08Posts: 612Char no Tibia: leviana luciferiana

uma pequena correçao no 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

 

if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then

if getPlayerLevel >= 9 then

selfSay('Você deseja comprar a magia {Light Healing} ?', cid)

talkState[talkUser] = 1

else

selfSay('Você não tem level suficiente.', cid)

end

end

 

local cost = 1000

if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then

if doPlayerRemoveMoney(cid, cost) == TRUE then

doPlayerLearnInstantSpell(cid, 'Light Healing')

selfSay('Você aprendeu a magia {Light healing}.', cid)

else

selfSay('Você não tem dinheiro suficiente!', cid)

end

end

return TRUE

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

e verifique se o xml do npc tem esse parametro.

 

<parameters>

<parameter key="message_greet" value="Hello, |PLAYERNAME| bla bla bla" />

<parameter key="message_walkaway" value="ate mais." />

</parameters>

creationb.jpg

"Um Deus que usasse seu poder para criar seres humanos que de antemão sabia que seriam atormentados eternamente, e que os predestinasse a isso,



não poderia ser sábio, nem justo e tampouco amoroso.

Além de nos submeter a isso vim a nos julgar e condenar por nossos atos aos tormentos do inferno.

pra minha pessoa isso não é um Deus Pai amoroso e bondoso como o chaman, seu padrão seria muito mais inferior do que o de muitos homens."

lukas8118

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/07Posts: 1

Então cara agora o npc até fala hi mas depois não fala nada! Ta ai a SS :

 

errotxn.jpg

 

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

 

if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then

if getPlayerLevel >= 9 then

selfSay('Você deseja comprar a magia {Light Healing} ?', cid)

talkState[talkUser] = 1

else

selfSay('Você não tem level suficiente.', cid)

end

end

 

local cost = 1000

if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then

if doPlayerRemoveMoney(cid, cost) == TRUE then

doPlayerLearnInstantSpell(cid, 'Light Healing')

selfSay('Você aprendeu a magia {Light healing}.', cid)

else

selfSay('Você não tem dinheiro suficiente!', cid)

end

end

return TRUE

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

XML do NPC pra qualquer coisa :

 

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Eremo" script="data/npc/scripts/pow.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="142" head="79" body="118" legs="115" feet="114" corpse="2212" />

<parameters><parameter key="message_greet" value="Ola |PLAYERNAME|, eu vendo magias!"/>

<parameter key="message_walkaway" value="Adeus |PLAYERNAME|." />

</parameters>

</npc>

 

Ah , e muito obrigado tambem pela ajuda que estão dando!

 

@@EDIT

 

Então só to com mais uma duvida é em questão de posicionamento dos else vo posta uma script em portugues ( só um exemplo sem os comandos certos .. ) só pra vc me dizer se to fazendo certo :

 

Se mensagem conter light healing faça

Se lvl do player >= 9 Faça

Senão

fale Você não tem level suficiente

end

fale Você deseja comprar light healing?

Se mensagem conter sim faça

Senao

fale 'eu não entendi por favor começe tudo denovo!'

end

fale É 200 gps deseja mesmo comprar?

Se mensagem conter sim faça

Senao

fale 'Desculpe eu não entendi comece tudo denovo!'

end

Checar dinheiro do player >= 200 faça

Senao

fale ' você nao tem dinheiro suficiente por favor consiga mais!'

end

Remova 200 gps do player

Adiciona a magia light healing ao player

fale 'Você comprou a magia Light Healing'

end

end

joaohd

Neox Boy
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 03/02/09Posts: 361Char no Tibia: Fearless Man

esse servidor é o styller yurots?? Tenta esse aki ó :

 

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, 'Light Healing') or msgcontains(msg, 'light healing') then
if getPlayerLevel >= 9 then
selfSay('Você deseja comprar a magia {Light Healing} ?', cid)
talk_state = 1
else
selfSay('Você não tem level suficiente.', cid)
talk_state = 0
end


local cost = 1000
elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talk_state == 1 then
if doPlayerRemoveMoney(cid, cost) then
doPlayerLearnInstantSpell(cid, 'Light Healing')
selfSay('Você aprendeu a magia {Light healing}.', cid)
else
selfSay('Você não tem dinheiro suficiente!', cid)
talk_state = 0
end


elseif msgcontains(msg, 'no') then
           selfSay('Ok than.', cid)
           talk_state = 0
       end

   -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
   return true
end




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



 

 

esse eu acho que funciona. eu acho que o erro todo tava na linha "if doPlayerRemoveMoney(cid,cost) == true then

se n me engano n precisava dakele == true porque o if ja faz a condição só ocorrer se for verdadeira.

 

flws