Ir para conteúdo

Featured Replies

Postado

Galera no meu server algumas magias têm de ser compradas, e eu queria um sistema que não deixasse o player ter duas magias semelhantes, exemplo : Se o player comprar Exevo Gran Mas Vis ele não pode comprar Exevo Gran Mas Flam, nem Exevo Gran Mas Tera, nem Exevo Gran Mas Frigo.

 

 

Resolvido por Garou

Ir para solução
  • Respostas 5
  • Visualizações 716
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Eu testei superficialmente, mas acho que funciona. local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkStat

Postado

Olá,

 

Possível, é sim.

 

Mas seria necessário fazer um pequeno trecho de código, no script de compra de magias (seja NPC, Talkaction, etcétera), para essa verificação se o jogador já comprou magia semelhante a quer comprar.

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

Postado
  • Autor

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 moeda = 2157
local t = {
["rage of the skies"] = {price = 5,vocations = {1},level = 60},
["hells core"] = {price = 5,vocations = {1},level = 60},
["eternal winter"] = {price =5,vocations = {1},level = 60},
["wrath of nature"] = {price =5,vocations = {1},level = 60}
}
if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then
local str = ""
str = str .. "Eu vendo estas Magias: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos.price.." Moedas /"
end
str = str .. "."
npcHandler:say(str, cid)
elseif t[msg] then
if not getPlayerLearnedInstantSpell(cid, msg) then
if getPlayerLevel(cid) >= t[msg].level then
if isInArray(t[msg].vocations, getPlayerVocation(cid)) then
if doPlayerRemoveItem(cid,moeda,t[msg].price) then
doPlayerLearnInstantSpell(cid, msg)
npcHandler:say("Você aprendeu uma nova magia chamada ".. msg .."!", cid)
else
npcHandler:say("você não tem "..t[msg].price.." ".. getItemNameById(moeda), cid)
end
else
npcHandler:say("você não tem a vocação para comprar está spell.", cid)
end
else
npcHandler:say("você precisa ter level "..t[msg].level.." ou mais para comprar essa magia.", cid)
end
else
npcHandler:say("você já aprendeu essa magia.", cid)
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Spell Exemple :

 

<instant name="Rage of the Skies" words="exevo gran mas vis" lvl="55" mana="600" prem="1" selftarget="1" exhaustion="2000" groups="4,2000" icon="119" needlearn="1" event="script" value="attack/rage of the skies.lua">
<vocation id="1"/>
</instant>
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_BIGCLOUDS)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 12)


local area = createCombatArea(AREA_CROSS6X6)
setCombatArea(combat, area)


function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
Postado
  • Solução

Eu testei superficialmente, mas acho que funciona.

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

local spells = {
	["rage of the skies"] = {price = 5, vocations = {1}, level = 60, storage = 17501},
	["hells core"] = {price = 5, vocations = {1}, level = 60, storage = 17501},
	["eternal winter"] = {price = 5, vocations = {1}, level = 60, storage = 17501},
	["wrath of nature"] = {price = 5, vocations = {1}, level = 60, storage = 17501},
}

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 moeda = 2157
	
	if msgcontains(msg, "spells") then
		local text = "Eu vendo essas magias: "
		
		local name, values = next(spells, nil)
		while name do
			text = text .." {".. name .."}: ".. values.price .." moedas"
			name, values = next(spells, name)
			if not name then
				text = text .."."
			else
				text = text ..","
			end
		end
		
		selfSay(text, cid)
	elseif spells[msg:lower()] then
		local spell = msg:lower()
		if not getPlayerLearnedInstantSpell(cid, spell) then
			if getPlayerLevel(cid) >= spells[spell].level then
				if isInArray(spells[spell].vocations, getPlayerVocation(cid)) then
					if doPlayerRemoveItem(cid, moeda, spells[spell].price) then
						if getCreatureStorage(cid, spells[spell].storage) == -1 then
							doPlayerLearnInstantSpell(cid, spell)
							selfSay("Você aprendeu uma nova magia chamada ".. spell .."!", cid)
							doCreatureSetStorage(cid, spells[spell].storage, 1)
						else
							selfSay("Você aprendeu uma magia desse tipo", cid)
						end
					else
						selfSay("Você não possui ".. spells[spell].price .." ".. getItemNameById(moeda) ..".", cid)
					end
				else
					selfSay("Sua vocação não pode aprender essa magia.", cid)
				end
			else
				selfSay("Você não possui o level necessário para aprender essa magia.", cid)
			end
		else
			selfSay("Você já aprendeu essa magia.", cid)
		end
	end					
	return true
end

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

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

Postado
  • Autor

Não deu nenhum erro no distro, mas ainda é possível comprar mais de uma dessas spells, obrigado por tentar me ajudar


Agora foi, não sei se tinha feito errado ontem ou se você editou, tá reputado.

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