Getting the positions of a bullet impact

I am trying to figure out how to access the impact positions of a bullet after it is fired, but I can’t seem to find the Native that would access those values.
The purpose for it is to make a noob gun for admin use, they will use a gun that isn’t commonly used in-game to shoot at the ground and it will spawn a panto for the lost new player to drive to the crucial points to get their character set up.

1 Like

Cast a raycast when they shoot a bullet. Here is something I made a while ago.

In LUA :

local function RotationToDirection(deg)
    local rad_x = deg['x'] * 0.0174532924
    local rad_z = deg['z'] * 0.0174532924

    local dir_x = -math.sin(rad_z) * math.cos(rad_x)
    local dir_y = math.cos(rad_z) * math.cos(rad_x)
    local dir_z = math.sin(rad_x)
    local dir = vector3(dir_x, dir_y, dir_z)
    return dir
end

local function RaycastFromPlayer()
    -- Results of the raycast
    local hit = false
    local endCoords = nil
    local surfaceNormal = nil
    local entityHit = nil

    local playerPed = PlayerPedId()
    local camCoord = GetGameplayCamCoord()
    local camRot = GetGameplayCamRot(0)

    local rayHandle = StartShapeTestRay(camCoord, camCoord + RotationToDirection(camRot) * 1000, -1, playerPed)
    local status, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(rayHandle)

    return hit, endCoords, surfaceNormal, entityHit
end
4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.