Ir para conteúdo

Featured Replies

Postado
  • Autor

 

Não testei:

local money = xxxx -- Quanto vai custar
local storage = 14542 -- Não mexer

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

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local player = Player(cid)

	if player:getStorageValue(storage) == 1 then
		npcHandler:say('you have already received the promotion', cid)
		return true
	end

	if msgcontains(msg:lower(), 'promotion') then
		npcHandler:say('you are sure?', cid)
		npcHandler.topic[cid] = 1
	end

	if msgcontains(msg:lower(), 'yes') and npcHandler.topic[cid] == 1 then
		if player:getPromotion() == 1 then
		    if player:getVipDays() >= 1 then
		       	if player:removeMoney(money) then
		       		npcHandler:say('you just received a new promotion', cid)
		       		player:setVocation(player:getVocation() + 4)
		       		player:setStorageValue(storage, 1)
		       		npcHandler.topic[cid] = 0
		       	else
		       		npcHandler:say('you no have money', cid)
		       		npcHandler.topic[cid] = 0
		       	end
		    else
		       	npcHandler:say('You do not have any vip days.', cid)
		       	npcHandler.topic[cid] = 0
		    end
		else
		   	npcHandler:say('you no have first promotion', cid)
		   	npcHandler.topic[cid] = 0
		end
    elseif msgcontains(msg:lower(), 'no') and npcHandler.topic[cid] == 1 then
    	npcHandler:say('Bye!!', cid)
    	npcHandler.topic[cid] = 0
    end

	return true
end

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

Opa amigo testei aqui, quando fala promotion, o npc responde are you sure ai vc fala "yes" ela não responde, e aparece isso no distro:

Lua Script Error: [Npc interface]

data/npc/scripts/Queen Alice.lua:onCreatureSay

data/npc/scripts/Queen Alice.lua:31: attempt to call method 'getPromotion' (a nil value)

stack traceback:

    [C]: in function 'getPromotion'

    data/npc/scripts/Queen Alice.lua:31: in function 'callback'

    data/npc/lib/npcsystem/npchandler.lua:410: in function 'onCreatureSay'

    data/npc/scripts/Queen Alice.lua:10: in function <data/npc/scripts/Queen Alice.lua:10>

 

Up

Poxa alguem poderia ajudar o summ aqui, o pc dele nao roda tfs 1.0, por favor preciso mto desse script :(

poxa muita gente sabe mas poucos ajudam, complicado..

1545517_5.png

  • Respostas 42
  • Visualizações 2.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcH

  • local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcH

  • Tenta isso: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parse

Postado

Tenta isso:

local money = xxxx -- Quanto vai custar
local storage = 14542 -- Não mexer

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

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local player = Player(cid)

	if player:getStorageValue(storage) == 1 then
		npcHandler:say("You have already received the promotion.", cid)
		return true
	end

	if msgcontains(msg:lower(), "promotion") then
		npcHandler:say("You are sure?", cid)
		npcHandler.topic[cid] = 1
	end

	if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then
		if player:getVocation():getPromotion() then
		    if player:getVipDays() >= 1 then
		       	if player:removeMoney(money) then
		       		npcHandler:say("You just received a new promotion.", cid)
		       		player:setVocation(player:getVocation():getPromotion())
		       		player:setStorageValue(storage, 1)
		       		npcHandler.topic[cid] = 0
		       	else
		       		npcHandler:say("You don't have money.", cid)
		       		npcHandler.topic[cid] = 0
		       	end
		    else
		       	npcHandler:say("You don't have any vip days.", cid)
		       	npcHandler.topic[cid] = 0
		    end
		else
		   	npcHandler:say("You don't have the first promotion.", cid)
		   	npcHandler.topic[cid] = 0
		end
    elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then
    	npcHandler:say('Bye!', cid)
    	npcHandler.topic[cid] = 0
    end

	return true
end

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

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

                              _
                          .-'` `}
                  _./)   /       }
                .'o   \ |       }
                '.___.'`.\    {`
                /`\_/  , `.    }                                      ME DA UMA NOZ!
                \=' .-'   _`\  {
                 `'`;/      `,  }
                    _\   @   ;  }
                   /__`;-...'--'

Cluck!

Postado
  • Autor

Tenta isso:

local money = xxxx -- Quanto vai custar
local storage = 14542 -- Não mexer

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

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local player = Player(cid)

	if player:getStorageValue(storage) == 1 then
		npcHandler:say("You have already received the promotion.", cid)
		return true
	end

	if msgcontains(msg:lower(), "promotion") then
		npcHandler:say("You are sure?", cid)
		npcHandler.topic[cid] = 1
	end

	if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then
		if player:getVocation():getPromotion() then
		    if player:getVipDays() >= 1 then
		       	if player:removeMoney(money) then
		       		npcHandler:say("You just received a new promotion.", cid)
		       		player:setVocation(player:getVocation():getPromotion())
		       		player:setStorageValue(storage, 1)
		       		npcHandler.topic[cid] = 0
		       	else
		       		npcHandler:say("You don't have money.", cid)
		       		npcHandler.topic[cid] = 0
		       	end
		    else
		       	npcHandler:say("You don't have any vip days.", cid)
		       	npcHandler.topic[cid] = 0
		    end
		else
		   	npcHandler:say("You don't have the first promotion.", cid)
		   	npcHandler.topic[cid] = 0
		end
    elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then
    	npcHandler:say('Bye!', cid)
    	npcHandler.topic[cid] = 0
    end

	return true
end

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

Ola amigo, obrigado pela ajuda, na pratica funcionou sem erros, porem quando da look no personagem pra ver se mudou a promotion aparece "you have no vocation" ou seja o player ficou sem vocaçao hehehe acho que estamos próximos de resolver :)

aguardo respostas!

1545517_5.png

Postado

Ola amigo, obrigado pela ajuda, na pratica funcionou sem erros, porem quando da look no personagem pra ver se mudou a promotion aparece "you have no vocation" ou seja o player ficou sem vocaçao hehehe acho que estamos próximos de resolver :)

aguardo respostas!

Desculpe, acho que isso resolve:

 

local money = xxxx -- Quanto vai custar
local storage = 14542 -- Não mexer

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

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local player = Player(cid)

	if player:getStorageValue(storage) == 1 then
		npcHandler:say("You have already received the promotion.", cid)
		return true
	end

	if msgcontains(msg:lower(), "promotion") then
		npcHandler:say("You are sure?", cid)
		npcHandler.topic[cid] = 1
	end

	if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then
		if player:getVocation():getPromotion() then
		    if player:getVipDays() >= 1 then
		       	if player:removeMoney(money) then
		       		npcHandler:say("You just received a new promotion.", cid)
		       		player:setVocation(player:getVocation():getPromotion():getId())
		       		player:setStorageValue(storage, 1)
		       		npcHandler.topic[cid] = 0
		       	else
		       		npcHandler:say("You don't have money.", cid)
		       		npcHandler.topic[cid] = 0
		       	end
		    else
		       	npcHandler:say("You don't have any vip days.", cid)
		       	npcHandler.topic[cid] = 0
		    end
		else
		   	npcHandler:say("You don't have the first promotion.", cid)
		   	npcHandler.topic[cid] = 0
		end
    elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then
    	npcHandler:say('Bye!', cid)
    	npcHandler.topic[cid] = 0
    end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
                              _
                          .-'` `}
                  _./)   /       }
                .'o   \ |       }
                '.___.'`.\    {`
                /`\_/  , `.    }                                      ME DA UMA NOZ!
                \=' .-'   _`\  {
                 `'`;/      `,  }
                    _\   @   ;  }
                   /__`;-...'--'

Cluck!

Postado
  • Autor

Desculpe, acho que isso resolve:

 

local money = xxxx -- Quanto vai custar
local storage = 14542 -- Não mexer

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

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	local player = Player(cid)

	if player:getStorageValue(storage) == 1 then
		npcHandler:say("You have already received the promotion.", cid)
		return true
	end

	if msgcontains(msg:lower(), "promotion") then
		npcHandler:say("You are sure?", cid)
		npcHandler.topic[cid] = 1
	end

	if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then
		if player:getVocation():getPromotion() then
		    if player:getVipDays() >= 1 then
		       	if player:removeMoney(money) then
		       		npcHandler:say("You just received a new promotion.", cid)
		       		player:setVocation(player:getVocation():getPromotion():getId())
		       		player:setStorageValue(storage, 1)
		       		npcHandler.topic[cid] = 0
		       	else
		       		npcHandler:say("You don't have money.", cid)
		       		npcHandler.topic[cid] = 0
		       	end
		    else
		       	npcHandler:say("You don't have any vip days.", cid)
		       	npcHandler.topic[cid] = 0
		    end
		else
		   	npcHandler:say("You don't have the first promotion.", cid)
		   	npcHandler.topic[cid] = 0
		end
    elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then
    	npcHandler:say('Bye!', cid)
    	npcHandler.topic[cid] = 0
    end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Que isso cara, o que importa eh vc estar me ajudando hehehe, bom, fiz o teste com 1 sorcerer e um master sorcerer, ambos recebiam a promotion, mas não muda nada.. Continua como sorcerer/master sorcerer, no caso o que eu queria era que so quem tiver a primeira promotion (master sorcerer etc..) possa ter a segunda que seria a promotion vip.. Mas ambos estao recebendo a promotion, porem nao muda nada.. Continua como sorcerer e master sorcerer, mas já é um começo obrigado pela ajuda e aguardo respostas..

up

1545517_5.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.7k

Informação Importante

Confirmação de Termo