Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- api_version = "1.10.0.0"
- -- Setting this higher will make the script pick up players aiming closer to others
- -- more often but will make the script highly inaccurate. Do not go above 0.015.
- autoaim_sensitivity = 0.04
- -- Setting this lower will change the minimum sensitivity to detect a player aiming at
- -- another player. Below 0.035 the script cannot read headshots accurately.
- -- DO NOT SET THIS HIGHER THAN autoaim_sensitivity EVER!
- autoaim_baseline_sensitivity = 0.004
- -- Minimum snap to trigger a snapped scoring event.
- snap_baseline_sensitivity = 6
- aimbot_max_score = 3000
- Mode = "k" -- name of command
- Reason = "Aimbot!"
- standing_height = 0.64
- crouch_height = 0.35
- camera_table = {}
- aimbot_score = {}
- aiming_at = {}
- spawned = {}
- function OnScriptLoad()
- register_callback(cb['EVENT_TICK'], "OnEventTick")
- register_callback(cb['EVENT_DIE'], "OnPlayerDeath")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
- for i = 1,16 do
- aiming_at[i] = 0
- aimbot_score[i] = 0
- end
- end
- function OnScriptUnload() end
- function OnPlayerLeave(PlayerIndex)
- aimbot_score[tonumber(PlayerIndex)] = 0
- end
- function OnPlayerSpawn(PlayerIndex)
- spawned[tonumber(PlayerIndex)] = true
- end
- function OnPlayerDeath(VictimIndex, KillerIndex)
- camera_table[tonumber(VictimIndex)] = nil
- end
- function OnEventTick()
- for i = 1,16 do
- if player_present(i) then
- if aimbot_score[i] > 1 then
- aimbot_score[i] = aimbot_score[i] - 0.25
- end
- end
- if player_alive(i) then
- local m_object = get_dynamic_player(i)
- if m_object ~= 0 then
- OnAimbotCheck(i, m_object)
- end
- end
- end
- end
- function OnAimbotCheck(PlayerIndex, m_object)
- local scoring = false
- local x, y, z = read_vector3d(m_object + 0x230)
- local stop_angle = get_stop_angle(PlayerIndex, m_object)
- if spawned[PlayerIndex] then stop_angle = 0 spawned[PlayerIndex] = false end
- local team = get_team(PlayerIndex)
- for j = 0,16 do
- if j ~= PlayerIndex and get_team(j) ~= team then
- local TargetIndex, Distance, vx, vy, vz = IsLookingAt(PlayerIndex, j)
- if TargetIndex ~= nil then
- local player_hit = intersect_to_player(m_object, PlayerIndex, vx, vy, vz)
- local score = math.floor(aiming_at[PlayerIndex] * Distance) * 0.0015
- if stop_angle > snap_baseline_sensitivity then
- aiming_at[PlayerIndex] = aiming_at[PlayerIndex] + 1
- scoring = true
- if player_hit then
- score = score + stop_angle * 5
- else
- score = score + stop_angle * 15
- end
- else
- local moving = velocity(PlayerIndex)
- if moving > 0 and stop_angle > 0 and stop_angle < 0.4 then
- aiming_at[PlayerIndex] = aiming_at[PlayerIndex] + 1
- scoring = true
- if player_hit then
- score = score + 4
- else
- score = score + 10
- end
- end
- end
- aimbot_score[PlayerIndex] = aimbot_score[PlayerIndex] + score
- break
- end
- end
- end
- if aimbot_score[PlayerIndex] > aimbot_max_score then
- execute_command(Mode .. " " .. PlayerIndex .. ' "'..Reason..'"')
- end
- if not scoring then
- aiming_at[PlayerIndex] = 0
- end
- end
- function get_team(PlayerIndex)
- local m_player = get_player(PlayerIndex)
- if m_player ~= 0 then
- return read_byte(m_player + 0x20)
- end
- return -1
- end
- function velocity(PlayerIndex)
- local m_object = get_dynamic_player(PlayerIndex)
- if m_object ~= 0 then
- local xv, yv, zv = read_vector3d(m_object + 0x278)
- return math.abs(xv) + math.abs(yv)
- end
- return 0
- end
- function get_stop_angle(PlayerIndex, m_object)
- local x_aim, y_aim, z_aim = read_vector3d(m_object + 0x230)
- if camera_table[PlayerIndex] == nil then
- camera_table[PlayerIndex] = {x_aim, y_aim, z_aim}
- return 0
- end
- local last_camera_x = camera_table[PlayerIndex][1]
- local last_camera_y = camera_table[PlayerIndex][2]
- local last_camera_z = camera_table[PlayerIndex][3]
- camera_table[PlayerIndex] = {x_aim, y_aim, z_aim}
- if last_camera_x == 0 and
- last_camera_y == 0 and
- last_camera_z == 0 then
- return 0
- end
- local movement = math.sqrt(
- (x_aim - last_camera_x) ^ 2 +
- (y_aim - last_camera_y) ^ 2 +
- (z_aim - last_camera_z) ^ 2)
- local angle = math.acos((2 - movement ^ 2) / 2)
- stop_angle = angle * 180 / math.pi
- return stop_angle
- end
- function intersect_to_player(m_object, PlayerIndex, vx, vy, vz)
- local crouch_state = read_float(m_object + 0x50C)
- local x, y, z = read_vector3d(m_object + 0x5c) -- Player Location
- if (crouch_state == 0) then
- z = z + standing_height
- else
- z = z + crouch_height
- end
- local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
- local hit, cx, cy, cz, ObjectID = intersect(x, y, z, vx*250, vy*250, vz*250, player_object_id)
- for i = 1,16 do
- if player_alive(i) and i ~= PlayerIndex then -- Can they be aimed at?
- if get_object_memory(ObjectID) == get_dynamic_player(i) then -- Are we aiming at a player
- return true
- end
- end
- end
- return false
- end
- function IsLookingAt(PlayerIndex, TargetIndex)
- local m_player = get_player(PlayerIndex)
- local m_target = get_player(TargetIndex)
- local m_object = get_dynamic_player(PlayerIndex)
- local m_target_object = get_dynamic_player(TargetIndex)
- if m_object == 0 or m_target_object == 0 then
- return
- end
- -- PlayerIndex
- local crouch_state = read_float(m_object + 0x50C)
- local camera_x, camera_y, camera_z = read_vector3d(m_object + 0x230)
- local player_x, player_y, player_z = read_vector3d(m_object + 0x5c) -- Player Location
- if (crouch_state == 0) then -- We need to adjust for crouching and standing heights.
- player_z = player_z + standing_height
- else
- player_z = player_z + crouch_height
- end
- -- TargetIndex
- local target_x, target_y, target_z = read_vector3d((m_target_object + 0x7C0) + 0x28) -- Player Location
- local radius = math.sqrt((target_x - player_x)^2 + (target_y - player_y)^2 + (target_z - player_z)^2)
- local local_x = target_x - player_x
- local local_y = target_y - player_y
- local local_z = target_z - player_z
- local point_x = 1 / radius * local_x
- local point_y = 1 / radius * local_y
- local point_z = 1 / radius * local_z
- local x_diff = math.abs(camera_x - point_x)
- local y_diff = math.abs(camera_y - point_y)
- local z_diff = math.abs(camera_z - point_z)
- local scaler = 0
- if radius > 10 then
- scaler = tonumber("0.00" .. math.floor(radius)) * 10
- end
- local auto_aim = autoaim_sensitivity - scaler
- if auto_aim < autoaim_baseline_sensitivity then auto_aim = autoaim_baseline_sensitivity end
- if x_diff <= auto_aim and y_diff <= auto_aim and z_diff <= auto_aim then
- return TargetIndex, radius, point_x, point_y, point_z
- end
- return nil, 0, 0, 0, 0
- end
- function getname(PlayerIndex)
- if get_player(PlayerIndex) then
- local name = get_var(PlayerIndex, "$name")
- return name
- end
- return nil
- end
Advertisement
Add Comment
Please, Sign In to add comment