nao sei se vai funfar usei a funcao getDistance(pos1, pos2)
info
Grupo: Campones
Registrado: 29/03/11
Posts: 90
Reputação: +15
Char no Tibia: Zoaklen

Editado Outubro 16 por ProfissaoPK
info
Grupo: Banidos
Registrado: 25/12/07
Posts: 152
Reputação: +24
Char no Tibia: Tony Scott

----edit-----
não vi que vc postou, profissão pk, foi no mesmo momento que eu postei, e acho que está incorreto o seu código.
----edit-----
Testa isso
local distance_target = 3
é a distancia.
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 distance_target = 3
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
if getDistanceBetween(getPlayerPosition(cid), getPlayerPosition((getCreatureTarget(cid))) > distance_target then
return true
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
Editado Outubro 16 por Keilost
Deu erro Keilost, e do profissãoPK nem deu certo,nem ataca.
'>' expected near 'then' linha 24
info
Grupo: Banidos
Registrado: 25/12/07
Posts: 152
Reputação: +24
Char no Tibia: Tony Scott

mals kk..
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 distance_target = 3
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
if getDistanceBetween(cid, getPlayerPosition(cid), getPlayerPosition(getCreatureTarget(cid))) > distance_target then
return true
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
Keilost:
Não dá erro,mas simplesmente fala que nao tem munição,mesmo tendo.
info
Grupo: Campones
Registrado: 29/03/11
Posts: 90
Reputação: +15
Char no Tibia: Zoaklen

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 getDistance(fromPosition, toPosition) > alcance then
doPlayerSendCancel(cid, "Longe demais, atire mais perto!")
return TRUE
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
info
Grupo: Banidos
Registrado: 25/12/07
Posts: 152
Reputação: +24
Char no Tibia: Tony Scott

ué que estranho.. tenta assim:
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 distance_target = 3
if need_target then
if getCreatureTarget(cid) <= 0 then
return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")
elseif getDistanceBetween(getPlayerPosition(cid), getPlayerPosition(getCreatureTarget(cid))) > distance_target then
return doPlayerSendCancel(cid, "Você está longe do alvo.")
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
Editado Outubro 17 por Keilost
Keilost: continua dando a mesma coisa,fala que nao te munição ao clicar no monstro. =/
ProfissãoPK deu erro ao clicar no monstro,lembrando que estou usando script com Use With:
attemp to call global 'getDistance' a nil value linha 14
Editado Outubro 17 por OriGM
info
Grupo: Banidos
Registrado: 25/12/07
Posts: 152
Reputação: +24
Char no Tibia: Tony Scott

@ProfissãoPK, nunca irá dar certo o toposition, fromposition..
Você tem que informar de que posição a posição.. O código não entende isso.
________________________________________________________________
@OriGM testa o meu lá..
@ProfissãoPK, nunca irá dar certo o toposition, fromposition..
Você tem que informar de que posição a posição.. O código não entende isso.
________________________________________________________________
@OriGM testa o meu lá..
Keilost: continua dando a mesma coisa,fala que nao te munição ao clicar no monstro. =/
info
Grupo: Banidos
Registrado: 25/12/07
Posts: 152
Reputação: +24
Char no Tibia: Tony Scott

@OriGM
Tente em outro char, vê se não tem algo errado..
Porque o script funciona assim, quando executado, ele lê de cima para baixo, e a minha checagem fica a cima da checagem da munição, ou seja, ele já passou por ela..
Keilost,nada continua na mesma. =/ Puts que tenso.
info
Grupo: Campones
Registrado: 29/03/11
Posts: 90
Reputação: +15
Char no Tibia: Zoaklen

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 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
fiz oq vc pediu pra mim fazer '-'
Keilost, ACHO que achei o erro do seu
vc colocou getPlayerPosition mais o certo seria getCreaturePosition so tenta isso. nao questione '-' ficaria algo assim:
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 distance_target = 3
if need_target then
if getCreatureTarget(cid) <= 0 then
return doPlayerSendCancel(cid, "Selecione um alvo primeiro.")
elseif getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid))) > distance_target then
return doPlayerSendCancel(cid, "Você está longe do alvo.")
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
Editado Outubro 17 por ProfissaoPK




info
Grupo: Cavaleiro
Registrado: 24/09/13
Posts: 199
Reputação: +25
Olá galera.
Peguei este codigo na Fabrica de Scripts que fechou,e gostaria que ao usar a pistola como Use With,tivesse uma range configuravel.
Por exemplo: só usar no maximo 3 sqm do player.
Abaixo o script:
Se alguem puder ajudar,fico agradecido.