newTask(function()
while true do
wait(100)
local closestPlayer, closestDistance = nil, math.huge
local botPosX, botPosY = getBotPosition()
for id, player in pairs(getAllPlayers()) do
if id ~= getBotId() and player.exist and player.nick ~= "Mato_Rindo" then
local distance = getDistanceBetweenCoords3d(player.position.x, player.position.y, player.position.z, getBotPosition())
if distance <= 70 and distance < closestDistance then
closestPlayer, closestDistance = player, distance
closestPlayer.id = id
end
end
end
isAiming = closestPlayer ~= nil
if closestPlayer then
local angle = math.deg(math.atan2(botPosY - closestPlayer.position.y, botPosX - closestPlayer.position.x)) + 90
if angle < 0 then angle = angle + 360 end
setBotRotation(angle)
newTask(function()
local bs = bitStream.new()
bs:writeBool(false)
bs:writeUInt16(closestPlayer.id)
bs:writeFloat(math.random(0, 9))
bs:writeUInt32(31)
bs:writeUInt32(math.random(0, 5))
bs:sendRPC(115)
bs:reset()
end)
end
end
end)