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:
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
Se alguem puder ajudar,fico agradecido.