OR
pedido

Colocar range na pistola

Por OriGM, 16 de out. de 2013 em Scripts

resolvido
script
28
2.3k
lovenina12L
17 de outubro de 2013 às 00:46


function onUse(cid, item, fromPosition, itemEx, toPosition)

local need_target = true -- Precisa de target? (true / false) Se false, o sistema utilizará o Use With.

local bullet_id = 2160 -- ID da munição

local shots_amount = 1 -- Tiros por vez

local exhaustion_time = 1 -- Segundos de exhaustion

local exhaust = 19301 -- Storage da exhaustion

local dmg_min, dmg_max = -100, -200 -- Dano mínimo, dano máximo

local shot_effect = 10 -- Efeito do tiro

local shot_distance_effect = 1 -- Distance effect do tiro

local damage_type = COMBAT_PHYSICALDAMAGE -- Tipo de dano

local shots_delay = 200 -- Delay dos tiros (em milissegundos)

local alcance = 6 -- Alcance do tiro

 

 

if isCreature(itemEx.uid) then

if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(itemEx.uid)) > alcance then

doPlayerSendCancel(cid, "Longe demais!")

return TRUE

end

end

 

 

if need_target then

if getCreatureTarget(cid) <= 0 then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if getCreatureTarget(cid) <= 0 then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), shot_distance_effect)

doTargetCombatHealth(cid, getCreatureTarget(cid), damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

else

if not isCreature(itemEx.uid) then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if not isCreature(itemEx.uid) then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)

doTargetCombatHealth(cid, itemEx.uid, damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

end

return true

end

OriGMO
17 de outubro de 2013 às 00:56

Caramba mals o erro,tava falando que nao tinha munição porque nao tinha trocado o ID para minha munição...

Porém o script nao ta pegando,ele nao seta a distancia,ou seja ataco no final da tela mesmo estando 3 de distance lá.

Vou testar todos os scripts do post de novo,com o ID da munição correta,se funcionar algum ou nao ,edito aqui pra avisar.

 

 

---EDIT---

Do Keilost,nao setou a distancia,eu posso atacar em qualquer distance,esse ultimo do ProfissãoPK deu certo,porém está saindo um efeito de bola azul,tipo de teleport no monstro quando morre.

E tambem gostaria de saber aonde alterar no script pra eu poder atacar no chão,digo,invez de jogar o tiro no monstro,jogar no chao. Sei que é nesssa partes aqui,mas mudo pra oque?

 

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)

if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(itemEx.uid)) > alcance then

Editado Outubro 17 por OriGM

lovenina12L
17 de outubro de 2013 às 01:41

tipo como se errase o tiro???

OriGMO
17 de outubro de 2013 às 11:48

tipo como se errase o tiro???

Exatamente,desculpa nao responder ontem de madrugada,é que começou a chover e cair uns raios cabulosos,ai pra não queimar o PC desliguei correndo rsrs.

Mas é isso mesmo,gostaria que nao jogasse o tiro diretamente no alvo pois se nao fica muito facil,gostaria que o tiro fosse no tile onde clicar.

markindootM
17 de outubro de 2013 às 13:36

Meu caro amigo faça oq eu disser:

 

Exclua seu SCRIPT e Ponha este!

function onUse(cid, item, fromPosition, itemEx, toPosition)
local need_target = true -- Precisa de target? (true / false) Se false, o sistema utilizará o Use With.
local bullet_id = 2160 -- ID da munição
local shots_amount = 1 -- Tiros por vez
local exhaustion_time = 1 -- Segundos de exhaustion
local exhaust = 19301 -- Storage da exhaustion
local dmg_min, dmg_max = -100, -200 -- Dano mínimo, dano máximo
local shot_effect = 10 -- Efeito do tiro
local shot_distance_effect = 1 -- Distance effect do tiro
local damage_type = COMBAT_PHYSICALDAMAGE -- Tipo de dano
local shots_delay = 200 -- Delay dos tiros (em milissegundos)

if need_target then
if getCreatureTarget(cid) <= 0 then
return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")
elseif getPlayerItemCount(cid, bullet_id) < shots_amount then
return doPlayerSendCancel(cid, "Você não possui munição.")
elseif exhaustion.check(cid, exhaust) then
return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")
end

exhaustion
.set(cid, exhaust, exhaustion_time)
for i = 0, shots_amount-1 do
addEvent(function()
if getCreatureTarget(cid) <= 0 then
return true
elseif getPlayerItemCount(cid, bullet_id) < 1 then
return doPlayerSendCancel(cid, "Você não possui munição.")
end
doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), shot_distance_effect)
doTargetCombatHealth(cid, getCreatureTarget(cid), damage_type, dmg_min, dmg_max, shot_effect)
doPlayerRemoveItem(cid, bullet_id, 1)
end, shots_delay*i)
end
else
if not isCreature(itemEx.uid) then
return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")
elseif getPlayerItemCount(cid, bullet_id) < shots_amount then
return doPlayerSendCancel(cid, "Você não possui munição.")
elseif exhaustion.check(cid, exhaust) then
return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")
end

exhaustion
.set(cid, exhaust, exhaustion_time)
for i = 0, shots_amount-1 do
addEvent(function()
if not isCreature(itemEx.uid) then
return true
elseif getPlayerItemCount(cid, bullet_id) < 1 then
return doPlayerSendCancel(cid, "Você não possui munição.")
end
doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)
doTargetCombatHealth(cid, itemEx.uid, damage_type, dmg_min, dmg_max, shot_effect)
doPlayerRemoveItem(cid, bullet_id, 1)
end, shots_delay*i)
end
end
return true
end

 

 

 

 

 

TAG

 

 

 

<action itemid="xxxx" script="pistol.lua" allowfaruse="1"/>

 

Obs: allowfaruse = distance, 1 = 1sqm, 5 = 5sqm de distancia e assim sucessivamente!

 

 

Se Ajudei REP+

Se Não Ajudei REP+

Afinal, Eu Tentei.

Editado Outubro 17 por markindoot

lovenina12L
17 de outubro de 2013 às 13:42

Meu caro amigo faça oq eu disser:

 

Exclua seu SCRIPT e Ponha este!

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

local need_target = true -- Precisa de target? (true / false) Se false, o sistema utilizará o Use With.

local bullet_id = 2160 -- ID da munição

local shots_amount = 1 -- Tiros por vez

local exhaustion_time = 1 -- Segundos de exhaustion

local exhaust = 19301 -- Storage da exhaustion

local dmg_min, dmg_max = -100, -200 -- Dano mínimo, dano máximo

local shot_effect = 10 -- Efeito do tiro

local shot_distance_effect = 1 -- Distance effect do tiro

local damage_type = COMBAT_PHYSICALDAMAGE -- Tipo de dano

local shots_delay = 200 -- Delay dos tiros (em milissegundos)

 

if need_target then

if getCreatureTarget(cid) <= 0 then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if getCreatureTarget(cid) <= 0 then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), shot_distance_effect)

doTargetCombatHealth(cid, getCreatureTarget(cid), damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

else

if not isCreature(itemEx.uid) then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if not isCreature(itemEx.uid) then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)

doTargetCombatHealth(cid, itemEx.uid, damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

end

return true

end

 

 

 

 

 

TAG

 

 

 

<action itemid="xxxx" script="pistol.lua" allowfaruse="1"/>

 

Obs: allowfaruse = distance, 1 = 1sqm, 5 = 5sqm de distancia e assim sucessivamente!

 

 

Se Ajudei REP+

Se Não Ajudei REP+

Afinal, Eu Tentei.

eu axo que ta um pouco errado. pq se voce for no spells.xml vai notar que as runas usam allowfaruse="1" e elas possui uma distancia infinita! des de que o player esteja em sua visao. entao o certo seria tentar

<action itemid="xxxx" script="pistol.lua" allowfaruse="1" range="6"/>

Mais da mesma forma, ja criamos o script. eu vo pra escola agora, qnd chegar eu coloco pra errar o tiro! e o tp la, e o if not isCreature(cid) pra quem ta confuso e quer ajudar!

markindootM
17 de outubro de 2013 às 13:44

meu amigo, issu não é uma spell e sim uma Action!

OriGMO
17 de outubro de 2013 às 14:18

 

Meu caro amigo faça oq eu disser:

 

Exclua seu SCRIPT e Ponha este!

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

local need_target = true -- Precisa de target? (true / false) Se false, o sistema utilizará o Use With.

local bullet_id = 2160 -- ID da munição

local shots_amount = 1 -- Tiros por vez

local exhaustion_time = 1 -- Segundos de exhaustion

local exhaust = 19301 -- Storage da exhaustion

local dmg_min, dmg_max = -100, -200 -- Dano mínimo, dano máximo

local shot_effect = 10 -- Efeito do tiro

local shot_distance_effect = 1 -- Distance effect do tiro

local damage_type = COMBAT_PHYSICALDAMAGE -- Tipo de dano

local shots_delay = 200 -- Delay dos tiros (em milissegundos)

 

if need_target then

if getCreatureTarget(cid) <= 0 then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if getCreatureTarget(cid) <= 0 then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), shot_distance_effect)

doTargetCombatHealth(cid, getCreatureTarget(cid), damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

else

if not isCreature(itemEx.uid) then

return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")

elseif getPlayerItemCount(cid, bullet_id) < shots_amount then

return doPlayerSendCancel(cid, "Você não possui munição.")

elseif exhaustion.check(cid, exhaust) then

return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")

end

 

exhaustion.set(cid, exhaust, exhaustion_time)

for i = 0, shots_amount-1 do

addEvent(function()

if not isCreature(itemEx.uid) then

return true

elseif getPlayerItemCount(cid, bullet_id) < 1 then

return doPlayerSendCancel(cid, "Você não possui munição.")

end

doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)

doTargetCombatHealth(cid, itemEx.uid, damage_type, dmg_min, dmg_max, shot_effect)

doPlayerRemoveItem(cid, bullet_id, 1)

end, shots_delay*i)

end

end

return true

end

 

 

 

 

 

TAG

 

 

 

<action itemid="xxxx" script="pistol.lua" allowfaruse="1"/>

 

Obs: allowfaruse = distance, 1 = 1sqm, 5 = 5sqm de distancia e assim sucessivamente!

 

 

Se Ajudei REP+

Se Não Ajudei REP+

Afinal, Eu Tentei.

eu axo que ta um pouco errado. pq se voce for no spells.xml vai notar que as runas usam allowfaruse="1" e elas possui uma distancia infinita! des de que o player esteja em sua visao. entao o certo seria tentar

<action itemid="xxxx" script="pistol.lua" allowfaruse="1" range="6"/>

Mais da mesma forma, ja criamos o script. eu vo pra escola agora, qnd chegar eu coloco pra errar o tiro! e o tp la, e o if not isCreature(cid) pra quem ta confuso e quer ajudar!

 

Exatamente! Markindoot o allowfaruse é só pra dizer se pode usar de longe ou não ou seja 0= nao ,e 1=sim. Não é range,e mesmo fazendo conforme o ProfissaoPk disse,nao funciona colocando o range no actions.xml ,como ja disse o script está funcionando ,só quero que erre o alvo agora.

Fico aguardando ProfissaoPk e agradeço novamente.

lovenina12L
17 de outubro de 2013 às 19:12

mais da mesma forma, ja usei essa funcao em mts tags de action. e isso deixa o alcance infinito ( do tamanho da sua visao )

 

@edit

UIA quase cometi double post.

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local need_target = true -- Precisa de target? (true / false) Se false, o sistema utilizará o Use With.
    local bullet_id = 2160 -- ID da munição
    local shots_amount = 1 -- Tiros por vez
    local exhaustion_time = 1 -- Segundos de exhaustion
    local exhaust = 19301 -- Storage da exhaustion
    local dmg_min, dmg_max = -100, -200 -- Dano mínimo, dano máximo
    local shot_effect = 10 -- Efeito do tiro
    local shot_distance_effect = 1 -- Distance effect do tiro
    local damage_type = COMBAT_PHYSICALDAMAGE -- Tipo de dano
    local shots_delay = 200 -- Delay dos tiros (em milissegundos)
    local alcance = 6 -- Alcance do tiro
 
	if isCreature(itemEx.uid) then
		if getDistance(getCreaturePosition(cid), getCreaturePosition(itemEx.uid)) > alcance then
			doPlayerSendCancel(cid, "Longe demais!")
			return TRUE
		end
	end

    if need_target then
        if getCreatureTarget(cid) <= 0 then
            return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")
        elseif getPlayerItemCount(cid, bullet_id) < shots_amount then
            return doPlayerSendCancel(cid, "Você não possui munição.")
        elseif exhaustion.check(cid, exhaust) then
            return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")
        end

        exhaustion.set(cid, exhaust, exhaustion_time)
        for i = 0, shots_amount-1 do
            addEvent(function()
                    if getCreatureTarget(cid) <= 0 then
                        return true
                    elseif getPlayerItemCount(cid, bullet_id) < 1 then
                        return doPlayerSendCancel(cid, "Você não possui munição.")
                    end
                    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), shot_distance_effect)
                    doTargetCombatHealth(cid, getCreatureTarget(cid), damage_type, dmg_min, dmg_max, shot_effect)
                    doPlayerRemoveItem(cid, bullet_id, 1)
                end, shots_delay*i)
        end
    else
	if getPlayerItemCount(cid, bullet_id) < shots_amount then
            return doPlayerSendCancel(cid, "Você não possui munição.")
        elseif exhaustion.check(cid, exhaust) then
            return doPlayerSendCancel(cid, "Aguarde "..(exhaustion.get(cid, exhaust)).." segundos para usar a arma novamente.")
        end
        
        exhaustion.set(cid, exhaust, exhaustion_time)
        for i = 0, shots_amount-1 do
            addEvent(function()
                    if getPlayerItemCount(cid, bullet_id) < 1 then
                        return doPlayerSendCancel(cid, "Você não possui munição.")
                    end
                    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(itemEx.uid), shot_distance_effect)
                    doTargetCombatHealth(cid, itemEx.uid, damage_type, dmg_min, dmg_max, shot_effect)
                    doPlayerRemoveItem(cid, bullet_id, 1)
                end, shots_delay*i)
        end
    end
return true
end

mano, eu to com uma duvida na cabeca. o seu item é de use with, certo? entao o need_target deveria ser falso. '-'

 

e sobre o efeito do teleport, voce tem que alterar aqui

    local shot_effect = 10 -- Efeito do tiro

Editado Outubro 17 por ProfissaoPK

OriGMO
17 de outubro de 2013 às 19:34

Então ProfissãoPK sobre o efeito,eu sempre usei o efeito 10,e não era de teleport antes Oo

E sim uso como false no target,voce mudou algo neste script acima?

 

 

---EDIT---

Consegui pra jogar no chão,trocando o getCreaturePosition por getThingPosition,mas mesmo assim,se clico no monstro,ele vai no monstro,se eu jogo no chao vai normalmente no chão mesmo.

 

---EDIT---

Vo sai com a minha mulher agora,dai pode postar ae quando der,e eu vejo depois se deu certo. xP Abração e valeus!

Editado Outubro 17 por OriGM

lovenina12L
21 de outubro de 2013 às 01:52

nossa, voce deve ter se esquecido que eu existo =x, faz 3 dias, mas... eu nao entendi oq voce disse:

Consegui pra jogar no chão,trocando o getCreaturePosition por getThingPosition,mas mesmo assim,se clico no monstro,ele vai no monstro,se eu jogo no chao vai normalmente no chão mesmo.

 

Editado Outubro 21 por ProfissaoPK

OriGMO
21 de outubro de 2013 às 03:03

Que isso cara,agradeço demais mesmo por você estar me ajudando,te mandei um MP se puder dar uma olhada lá.

Por exemplo,configurei o script para dar 5 tiros com delay.

Eu atiro no chão ,ele vai indo 1 tiro por vez,se um monstro vai naquele Tile que atirei,nao dá dano os tiros que for naquele Tile.

Se eu atiro diretamente no monstro,e ele andar os 5 tiros vai seguir o monstro,e no caso eu gostaria que o tiro fosse naquele Tile que joguei,se o monstro sair dali,ou algum outro entrar ali naquele Tile,ele leva o dano entendeu?

rsrs desculpa sou bem ruim pra explicar.

2 meses depois...
OmegaO
05 de dezembro de 2013 às 22:59

Tópico movido para a seção de dúvidas e pedidos resolvidos.