[Encerrado] [PEDIDO] TalkAction de Comprar SKILLs

yagoshira004
em Tópicos Sem Resposta

yagoshira004

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/02/10Posts: 55Char no Tibia: Ynu

Olá rapaziada como estamos?

 

Encontrei um script super bacana de comprar SKILLS via talkaction (ex: !comprar club)

Ele remove uma quantidade de certo item e te da skills pro char

 

Porém esse script nao está funcionando corretamente, ele está removendo o item, está deslogando o char mas nao está dando os skills

 

 

SCRIPT

  Citar

skill = {
   item = 2157, -- Item
   quantidade = 10, -- Quantidade
   quantidadeskill = 10, -- Skill adicionada
   limiteskill = 350 -- Limite
}

magicLevel = {
   item = 2157,
   quantidade = 15,
   quantidademl = 5,
   limitedeml = 200
}

skillID = {
   ["club"] = SKILL_CLUB,
   ["sword"]= SKILL_SWORD,
   ["axe"] = SKILL_AXE,
   ["distance"] = SKILL_DISTANCE,
   ["shielding"] = SKILL_SHIELD
}

vocationSkill = { -- Vocações - SKILL
   ["club"] = {4, 8, 13, 14},
   ["sword"] = {4, 8, 13, 14},
   ["axe"] = {4, 8, 13, 14},
   ["distance"] = {3, 7},
   ["shielding"] = {4, 8, 3, 7, 13, 14}
}

vocationMagicLevel = {1, 2, 5, 6} -- Vocações - MAGIC LEVEL
protectZone = "sim"
function onSay(cid, words, param, channel)
   local pid = getPlayerGUID(cid)
   if (protectZone == "sim") and (not getTilePzInfo(getCreaturePosition(cid))) then
       doPlayerSendCancel(cid, "Você precisa estar em protection zone pra poder comprar.")
   end

   if (param == '') then
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club; !comprar magiclevel.")
       return true
   end

   local storage, duration = 5, 5
   if (param == 'magiclevel') then
       if getPlayerMagLevel(cid) < magicLevel.limitedeml then
           if isInArray(vocationMagicLevel, getPlayerVocation(cid)) then
               if doPlayerRemoveItem(cid, magicLevel.item, magicLevel.quantidade) then
                   if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                       setPlayerStorageValue(cid, storage, os.time())
                       doRemoveCreature(cid, true)
                       db.query("UPDATE `players` SET `maglevel` = `maglevel` + ".. magicLevel.quantidademl .." WHERE `id` = ".. pid)
                   else
                       doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                   end
               else
                   doPlayerSendCancel(cid, "Você não tem o item requerido.")
               end
           else
               doPlayerSendCancel(cid, "Voce não pode comprar magic level.")
           end
       else
           doPlayerSendCancel(cid, "Você chegou no limite de magic level.")
       end
       return true
   end

   if(skillID[param:lower()]) then
       if(getPlayerSkill(cid, skillID[param:lower()]) < skill.limiteskill) then
           if isInArray(vocationSkill[param:lower()], getPlayerVocation(cid)) then
               if doPlayerRemoveItem(cid, skill.item, skill.quantidade) then
                   if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                       setPlayerStorageValue(cid, storage, os.time())
                       doRemoveCreature(cid, true)
                       db.query("UPDATE `player_skills` SET `value` = `value` + ".. skill.quantidadeskill .." WHERE `player_id` = ".. pid .. " and `skillID[` = ".. skillID[param:lower()])
                   else
                       doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                   end
               else
                   doPlayerSendCancel(cid, "Você não tem o item requerido.")
               end
           else
               doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
           end
       else
           doPlayerSendCancel(cid, "Você chegou no limite de skill.")
       end
   else
       doPlayerSendCancel(cid, "Skill desconhecida.")
   end
   return true
end
 

alguem que manja consegue me ajudar? qual o erro

JME Connection !

Togumelo

Togu
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 11/09/06Posts: 22Gênero: Masculino
function Player:addSkillLevels(skill)
    if isInArray({SKILL_VITALITY, SKILL_STRENGHT, SKILL_FAITH, SKILL_INTELLIGENCE, SKILL_DEXTERITY, SKILL_RESISTANCE, SKILL_ENDURANCE}, skill) then
        local xp = math.ceil(self:getVocation():getRequiredSkillTries(skill, self:getSkillLevel(skill) + 1) / configManager.getNumber(configKeys.RATE_SKILL))
        self:addSkillTries(skill, xp)
        return true
    end
    if skill == SKILL_MAGLEVEL then
        local xp = math.ceil(self:getVocation():getRequiredManaSpent(self:getBaseMagicLevel() + 1) / configManager.getNumber(configKeys.RATE_MAGIC))
        self:addManaSpent(xp)
        return true
    end
end
function Player:assignSkillPoints(skill)

	if getPlayerLevel(self) > 8 then
		maxSkillformula = getPlayerLevel(self) * (3 - (0.02 * (getPlayerLevel(self) - 8)))
    	maxMagic = maxSkillformula * 0.5
		maxVitality = maxSkillformula
		maxStrenght = maxSkillformula
		maxIntelligence = maxSkillformula
		maxFaith = maxSkillformula
		maxDexterity = maxSkillformula * 0.75
		maxResistance = maxSkillformula
		maxEndurance = maxSkillformula
	end

	if maxDexterity < 1 then maxDexterity = 1 end

	if (skill == SKILL_MAGLEVEL) then
		if self:getMagicLevel() < maxMagic then
			self:addSkillLevels(SKILL_MAGLEVEL)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[1][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_VITALITY) then
		if self:getSkillLevel(SKILL_VITALITY) < maxVitality then
			self:addSkillLevels(SKILL_VITALITY, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[2][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_STRENGHT) then
		if self:getSkillLevel(SKILL_STRENGHT) < maxStrenght then
    		self:addSkillLevels(SKILL_STRENGHT, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[3][3])
			--self:messageOnAdvance(SKILL_STRENGHT)
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_INTELLIGENCE) then
		if self:getSkillLevel(SKILL_INTELLIGENCE) < maxIntelligence then
        	self:addSkillLevels(SKILL_INTELLIGENCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[4][3])
			--self:messageOnAdvance(SKILL_INTELLIGENCE)
	    	return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_FAITH) then
		if self:getSkillLevel(SKILL_FAITH) < maxFaith then
        	self:addSkillLevels(SKILL_FAITH, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[5][3])
			--self:messageOnAdvance(SKILL_FAITH)
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_DEXTERITY) then
		if self:getSkillLevel(SKILL_DEXTERITY) < maxDexterity then
        	self:addSkillLevels(SKILL_DEXTERITY, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[6][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_RESISTANCE) then
		if self:getSkillLevel(SKILL_RESISTANCE) < maxResistance then
        	self:addSkillLevels(SKILL_RESISTANCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[7][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_ENDURANCE) then
		if self:getSkillLevel(SKILL_ENDURANCE) < maxEndurance then
        	self:addSkillLevels(SKILL_ENDURANCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[8][3])
			return true
	    else
	    	return false
	    end
	end
end

 

The Forgotten Tibia Project

 

Porque todo mundo esqueceu que o Tibia podia ser assim

Sem vocações, sem treino, apenas level up

Aumente seu magic, vitality, strenght, dexterity, intelligence, faith, resistance e endurance para ficar mais forte.

 

http://theforgottentibia.servegame.com:8090/                                  test server acontecendo!

build_sorc_60_2.png

yagoshira004

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/02/10Posts: 55Char no Tibia: Ynu
13 horas atrás, Gugu Z.S disse:
function Player:addSkillLevels(skill)
    if isInArray({SKILL_VITALITY, SKILL_STRENGHT, SKILL_FAITH, SKILL_INTELLIGENCE, SKILL_DEXTERITY, SKILL_RESISTANCE, SKILL_ENDURANCE}, skill) then
        local xp = math.ceil(self:getVocation():getRequiredSkillTries(skill, self:getSkillLevel(skill) + 1) / configManager.getNumber(configKeys.RATE_SKILL))
        self:addSkillTries(skill, xp)
        return true
    end
    if skill == SKILL_MAGLEVEL then
        local xp = math.ceil(self:getVocation():getRequiredManaSpent(self:getBaseMagicLevel() + 1) / configManager.getNumber(configKeys.RATE_MAGIC))
        self:addManaSpent(xp)
        return true
    end
end
function Player:assignSkillPoints(skill)

	if getPlayerLevel(self) > 8 then
		maxSkillformula = getPlayerLevel(self) * (3 - (0.02 * (getPlayerLevel(self) - 8)))
    	maxMagic = maxSkillformula * 0.5
		maxVitality = maxSkillformula
		maxStrenght = maxSkillformula
		maxIntelligence = maxSkillformula
		maxFaith = maxSkillformula
		maxDexterity = maxSkillformula * 0.75
		maxResistance = maxSkillformula
		maxEndurance = maxSkillformula
	end

	if maxDexterity < 1 then maxDexterity = 1 end

	if (skill == SKILL_MAGLEVEL) then
		if self:getMagicLevel() < maxMagic then
			self:addSkillLevels(SKILL_MAGLEVEL)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[1][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_VITALITY) then
		if self:getSkillLevel(SKILL_VITALITY) < maxVitality then
			self:addSkillLevels(SKILL_VITALITY, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[2][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_STRENGHT) then
		if self:getSkillLevel(SKILL_STRENGHT) < maxStrenght then
    		self:addSkillLevels(SKILL_STRENGHT, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[3][3])
			--self:messageOnAdvance(SKILL_STRENGHT)
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_INTELLIGENCE) then
		if self:getSkillLevel(SKILL_INTELLIGENCE) < maxIntelligence then
        	self:addSkillLevels(SKILL_INTELLIGENCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[4][3])
			--self:messageOnAdvance(SKILL_INTELLIGENCE)
	    	return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_FAITH) then
		if self:getSkillLevel(SKILL_FAITH) < maxFaith then
        	self:addSkillLevels(SKILL_FAITH, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[5][3])
			--self:messageOnAdvance(SKILL_FAITH)
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_DEXTERITY) then
		if self:getSkillLevel(SKILL_DEXTERITY) < maxDexterity then
        	self:addSkillLevels(SKILL_DEXTERITY, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[6][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_RESISTANCE) then
		if self:getSkillLevel(SKILL_RESISTANCE) < maxResistance then
        	self:addSkillLevels(SKILL_RESISTANCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[7][3])
			return true
	    else
	    	return false
	    end

	elseif (skill == SKILL_ENDURANCE) then
		if self:getSkillLevel(SKILL_ENDURANCE) < maxEndurance then
        	self:addSkillLevels(SKILL_ENDURANCE, 1)
			self:setStorageValue(pointsStorage, self:getStorageValue(pointsStorage) - skills[8][3])
			return true
	    else
	    	return false
	    end
	end
end

 

Como coloco no script mano?

 

Obrigado pela ajuda!

JME Connection !

Togumelo

Togu
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 11/09/06Posts: 22Gênero: Masculino
14 minutos atrás, yagoshira004 disse:

Como coloco no script mano?

 

Obrigado pela ajuda!

Então... aqui no meu server tá na pasta /data/lib/core/skillpoints.lua
Em /data/lib/core/core.lua vc tem que adicionar:

dofile('data/lib/core/skillpoints.lua')

Nas minhas sources eu alterei todos nomes dos skills como voce pode ver no código, então voce vai ter que alterar de novo pro nome original (vitality = SKILL_FIST, strenght = SKILL_CLUB, faith = SKILL_SWORD, intelligence = SKILL_AXE, resistance = SKILL_SHIELDING, endurance = SKILL_FISHING, magic acho que é SKILL_MAGLEVEL).

Com a primeira função você pode passar 1 skill inteiro só mandando o skill pra função (nota que a função é da classe Player), dessa forma você pode criar uma talkaction ou colocar ela em um npc. Tenta entender ela. Ela pega a quantidade de "required skill tries" pro proximo skill e "adiciona skill tries" até o proximo skill.

 

Com a segunda função você pode chamar a primeira função pra fazer a mesma coisa só que com mais detalhezinhos.

The Forgotten Tibia Project

 

Porque todo mundo esqueceu que o Tibia podia ser assim

Sem vocações, sem treino, apenas level up

Aumente seu magic, vitality, strenght, dexterity, intelligence, faith, resistance e endurance para ficar mais forte.

 

http://theforgottentibia.servegame.com:8090/                                  test server acontecendo!

build_sorc_60_2.png

Marshmello

Alone ~ [✖‿✖]
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 21/04/16Posts: 831Gênero: Masculino
A questão neste suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.

placa1.png.90a184502351cebe72cd7b69751e551d.png

Meu Facebook

INFOS:

Citar

CIDADE: Rio de janeiro

Idade: 22 anos
SOU: {"Scripter(lua)", "WebMaster", "ProgramadorC++"}
 

local config = {
	delrey = getPlayerCarValue(cid, DELREY),
	cigarro = getPlayerCancer(cid, DERBY),
	prostituta = getPlayerAIDS(cid, cracuda),
	tresOitao = getPlayerRevorvi(cid, 38)
}
if(delrey == "Ligado" and cigarro == "Aceso" and prostituta == "No Colo" and tresOitao == "Carregado") then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Começou o fim de semana. #PAS")
end