Ir para conteúdo
  • 0

[Resolvido] AK GOLD


Matador18

Pergunta

Boa Tarde Xtibianos,

venho aqui hoje pedir a ajuda de vocês, tenho um sistema de Spell e Talkaction que é uma arma que ao usar comando !ak ele troca de munição, só que ele continua tirando a mesma quantidade de vida dos monstros nao importa o level nem a munição, gostaria de pedir a vocês que no nivel 8 tirasse 100 com Bala 1 150 com a Bala 2 e ao upar nivel 10 por exemplo tirasse 120 com bala 1 e 180 com bala 2

AK GOLD em Spells:
<rune name="AK-47" id="2088" allowfaruse="1" charges="1" lvl="1" maglv="0" exhaustion="1000" blocktype="solid" script="ak_ammo.lua"/>
E em "ak_ammo.lua" da pasta scripts de spells, adicione o script abaixo:
Spoiler
local arma = 2088
local bullets = 2298
local chumbos = 2299
local storage = 30012
local msg = "Equipe a %s na mao esquerda e a municao na mae direita para poder atirar."
local attackmin, attackmax = 600, 900 -- attack minimo, attack maximo

function onCastSpell(cid, var)
local left = getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid
local shoot = getPlayerItemCount(cid, bullets)
local shoot2 = getPlayerItemCount(cid, chumbos)
local permissao = getPlayerStorageValue(cid, storage)
local target = getCreatureTarget(cid)
local hit = (math.random(attackmin,attackmax) + getPlayerSkillLevel(cid, SKILL_DISTANCE) / 3)

if isInArray({left}, arma) then
else
return doPlayerSendCancel(cid, msg:format(getItemNameById(arma)))
end
if (permissao == 1) then
if (shoot <= 0) then
return doPlayerSendCancel(cid, 'Voce precisa de bullets para usar sua AK-47.')
else
if (target <= 0) then
return doPlayerSendCancel(cid, 'Selecione um alvo.')
else
doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -hit, -hit, CONST_ME_MORTAREA)
doSendDistanceShoot(getCreaturePos(cid), getCreaturePos(target), 15)
doPlayerRemoveItem(cid, bullets, 1)
end
end
else
if (shoot2 <= 0) then
return doPlayerSendCancel(cid, 'Voce precisa de chumbos para usar sua AK-47.')
else
if (target <= 0) then
return doPlayerSendCancel(cid, 'Selecione um alvo.')
else
doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -hit, -hit, CONST_ME_MORTAREA)
doSendDistanceShoot(getCreaturePos(cid), getCreaturePos(target), 15)
doPlayerRemoveItem(cid, chumbos, 1)
end
end
end
return TRUE
end
Ak gold em TALKACTION:
<talkaction words="!ak" event="script" value="ak_ammo.lua"/>
Agora crie um arquivo chamado "ak_ammo.lua" em scripts e adicione o código abaixo:
local storage = 30012

function onSay(cid, words, param)

if getPlayerStorageValue(cid, storage) == 1 then
setPlayerStorageValue(cid, storage, 2)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Agora sua Ak-47 pode atirar chumbos.")
else
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Agora sua Ak-47 pode atirar bullets.")
end
return true
end

 

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

Cara fiz uma gambiarra aqui porque faz bastante tempo que não mexo com scripts e a preguiça de refazer o código é grande, mas acho que vai funcionar xD

 

Spoiler

local arma = 2088
local bullets = 2298
local chumbos = 2299
local storage = 30012
local msg = "Equipe a %s na mao esquerda e a municao na mae direita para poder atirar."
local atkminc, atkmaxc = 600, 900 -- attack minimo, attack maximo chumbos
local atkminb, atkmaxb = 800, 1100 -- attack minimo, attack maximo bullets

function onCastSpell(cid, var)
	local left = getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid
	local shoot = getPlayerItemCount(cid, bullets)
	local shoot2 = getPlayerItemCount(cid, chumbos)
	local permissao = getPlayerStorageValue(cid, storage)
	local target = getCreatureTarget(cid)
	local hitc = (math.random(atkminc,atkmaxc) + getPlayerSkillLevel(cid, SKILL_DISTANCE) / 3 + getPlayerLevel(cid) / 3) -- dano chumbo (aleatorio(600-900) + distance do player/3 + level do player/3)
	local hitb = (math.random(atkminb,atkmaxb) + getPlayerSkillLevel(cid, SKILL_DISTANCE) / 3 + getPlayerLevel(cid) / 3) -- dano chumbo (aleatorio(800-1100) + distance do player/3 + level do player/3)

	if isInArray({left}, arma) then
	else
		return doPlayerSendCancel(cid, msg:format(getItemNameById(arma)))
	end
	if (permissao == 1) then
		if (shoot <= 0) then
			return doPlayerSendCancel(cid, 'Voce precisa de bullets para usar sua AK-47.')
		else
			if (target <= 0) then
				return doPlayerSendCancel(cid, 'Selecione um alvo.')
			else
				doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -hitb, -hitb, CONST_ME_MORTAREA)
				doSendDistanceShoot(getCreaturePos(cid), getCreaturePos(target), 15)
				doPlayerRemoveItem(cid, bullets, 1)
			end
		end
	else
		if (shoot2 <= 0) then
			return doPlayerSendCancel(cid, 'Voce precisa de chumbos para usar sua AK-47.')
		else
			if (target <= 0) then
				return doPlayerSendCancel(cid, 'Selecione um alvo.')
			else
				doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -hitc, -hitc, CONST_ME_MORTAREA)
				doSendDistanceShoot(getCreaturePos(cid), getCreaturePos(target), 15)
				doPlayerRemoveItem(cid, chumbos, 1)
			end
		end
	end
return TRUE
end

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

Estou no celular então é difícil editar o código, mas basicamente o dano é definido na variável "hit", o que você precisa fazer é alterar o dano de acordo com a munição que está usando e aumentar o dano conforme o level do player

Link para o comentário
Compartilhar em outros sites

  • 0

@SirDubstep

 

Em 21/10/2017 at 20:11, SirDubstep disse:

Estou no celular então é difícil editar o código, mas basicamente o dano é definido na variável "hit", o que você precisa fazer é alterar o dano de acordo com a munição que está usando e aumentar o dano conforme o level do player

 

Poderia fazer isso para mim? 

Agradeço deis de já!

Link para o comentário
Compartilhar em outros sites

  • 0
2 horas atrás, Gabrieltxu disse:

 

você colocou 2x a mesma variavel, seria -hitc, -hitb

Nunca mexi com spells, mas no código original estava assim:

doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -hit, -hit, CONST_ME_MORTAREA)

Eu apenas dividi a variável "hit" em 2, tendo assim "hitb" (hit bullet) e "hitc" (hit chumbo), ai quando a arma estiver usando bullets irá usar o hitb e quando estiver usando chumbos irá usar o hitc, o motivo de estar escrito hit duas vezes no código original eu já não sei porque não sei como funciona a função doTargetCombatHealth xD

 

@edit

Dei uma procurada e as entradas dessa função são as seguintes:

doTargetCombatHealth(cid, target, type, min, max, effect)

Logo o código esta certo, a váriavel hitX irá gerar 2 números aleatórios (entre 600-900 na hitc e 800-1100 na hitb) para preencher min e max :smile:

Editado por SirDubstep
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...