Skip to content

Instantly share code, notes, and snippets.

  • Save blackboxaiapp/5686727f0ef97d87ecc8a782539670d7 to your computer and use it in GitHub Desktop.
Save blackboxaiapp/5686727f0ef97d87ecc8a782539670d7 to your computer and use it in GitHub Desktop.
Powered by https://www.blackbox.ai: لتحقيق ما تريده، يجب تعديل الكود بحيث يتم التحكم في الـ "بوت" (الذي يقود السيارة) بدلاً من السيارة ن

Question:

انا لدي كود lua fivem cantrol car ولكن الكود يصنع بوت داخل المركبه لكن المشكله هي مو هنا المشكله انه التحكم يكون في السياره ليس في البوت انا اريد التحكم في البوت والبوت نفسه يطير بالسياره MachoInjectResource("spawnmanager", [[ local cam = nil local isFreeCam = false local speed = 0.5 local minSpeed = 0.1 local maxSpeed = 5.0

-- Weapon definitions local weapons = { {name = "RPG", hash = "weapon_rpg", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}, {name = "Firework", hash = "weapon_firework", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}, {name = "Grenade", hash = "weapon_grenade", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}, {name = "Sticky Bomb", hash = "weapon_stickybomb", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}, {name = "Minigun", hash = "weapon_minigun", firingPattern = "FIRING_PATTERN_FULL_AUTO"}, {name = "Railgun", hash = "weapon_railgun", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"} }

-- Popular vehicle list local popularVehicles = { {name = "Adder", hash = "adder"}, {name = "Entity XF", hash = "entityxf"}, {name = "Oppressor", hash = "oppressor"}, {name = "Deluxo", hash = "deluxo"}, {name = "T20", hash = "t20"}, {name = "Zentorno", hash = "zentorno"}, {name = "Nightshark", hash = "nightshark"}, {name = "Hydra", hash = "hydra"}, {name = "Akuma", hash = "akuma"}, {name = "Pariah", hash = "pariah"}, {name = "Vigilante", hash = "vigilante"}, {name = "Scramjet", hash = "scramjet"}, {name = "Bati 801", hash = "bati"}, {name = "Insurgent", hash = "insurgent"}, {name = "Kuruma", hash = "kuruma"}, {name = "Faggio", hash = "faggio"} }

-- Random objects list (20 objects) local randomObjects = { {name = "Container", hash = "prop_container_ld2"}, {name = "ATM", hash = "prop_atm_02"}, {name = "Bench", hash = "prop_bench_01a"}, {name = "Traffic Cone", hash = "prop_roadcone01a"}, {name = "Barrier", hash = "prop_barrier_work05"}, {name = "TV", hash = "prop_tv_flat_02"}, {name = "Toilet", hash = "prop_ld_toilet_01"}, {name = "Chair", hash = "prop_chair_01a"}, {name = "Traffic Light", hash = "prop_traffic_01a"}, {name = "Dumpster", hash = "prop_dumpster_01a"}, {name = "Safe", hash = "prop_ld_int_safe_01"}, {name = "Basketball", hash = "prop_bskball_01"}, {name = "Telescope", hash = "prop_t_telescope_01b"}, {name = "Trailer", hash = "prop_trailer_01"}, {name = "Oil Can", hash = "prop_oilcan_01a"}, {name = "Fire Hydrant", hash = "prop_fire_hydrant_1"}, {name = "Parking Meter", hash = "prop_parkingpay"}, {name = "Traffic Sign", hash = "prop_sign_road_01a"}, {name = "Wheelchair", hash = "prop_wheelchair_01"}, {name = "Beach Ball", hash = "prop_bskball_01"} }

local currentWeaponIndex = 1 local currentVehicleIndex = 1 local currentObjectIndex = 1 local options = { "TP", "Control Car", "Shot Weapon", "Shot Weapon 2", "Spawn Vehicle", "Shot Car", "Spawn Wade", "bot kiil Player", "TP Car", "Delete Car", "Attach Car", "Attach Car All", "Attach Cars Randomly", "Spawn Object", "Teleport Cars To Player", "Lock", "Delete All Cars", "Close Free Cam", "Spawn Barrier", "Attach Carv1", "Delete All Objects", "none" }

local selectedOption = 1 local weaponFiring = false local attachedVehicle = nil local attachedVehiclesAll = {} local randomAttachedCars = {} local lockEnabled = false local attachedCarV1 = nil local controlledVehicle = nil local botDriver = nil

function CreateInvisibleBot(vehicle) local model = GetHashKey("s_m_y_blackops_01") RequestModel(model) while not HasModelLoaded(model) do Wait(0) end

local bot = CreatePed(4, model, 0, 0, 0, 0.0, true, false)

SetEntityVisible(bot, false, false)
SetEntityAlpha(bot, 0, false)
SetEntityInvincible(bot, true)
SetEntityCollision(bot, false, false)
SetPedCanRagdoll(bot, false)
DisablePedPainAudio(bot, true)
StopPedSpeaking(bot, true)
SetPedMute(bot, true)
SetBlockingOfNonTemporaryEvents(bot, true)

TaskWarpPedIntoVehicle(bot, vehicle, -1)
return bot

end

function StartFreeCam() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) -- Increased height from +1.0 to +3.0 for better view SetCamCoord(cam, coords.x, coords.y, coords.z + 3.0) SetCamRot(cam, 0.0, 0.0, 2) RenderScriptCams(true, false, 0, true, true) FreezeEntityPosition(playerPed, true) isFreeCam = true end

function StopFreeCam() if cam then RenderScriptCams(false, false, 0, true, true) DestroyCam(cam, false) cam = nil end FreezeEntityPosition(PlayerPedId(), false) isFreeCam = false attachedVehicle = nil attachedVehiclesAll = {} randomAttachedCars = {} attachedCarV1 = nil

-- Clean up controlled vehicle
if botDriver and DoesEntityExist(botDriver) then
    DeleteEntity(botDriver)
end
controlledVehicle = nil
botDriver = nil

end

function DrawOptions() local baseY = 0.5 for i, option in ipairs(options) do local label = option if option == "Shot Weapon" then label = "Shot "..weapons[currentWeaponIndex].name elseif option == "Shot Weapon 2" then label = "Shot "..weapons[currentWeaponIndex].name.." 2" elseif option == "Spawn Vehicle" then label = "Spawn "..popularVehicles[currentVehicleIndex].name elseif option == "Shot Car" then label = "Shoot "..popularVehicles[currentVehicleIndex].name elseif option == "Spawn Object" then label = "Spawn "..randomObjects[currentObjectIndex].name elseif option == "Lock" then label = lockEnabled and "Unlock" or "Lock" elseif option == "Control Car" then label = controlledVehicle and "Release Car" or "Control Car" end

    local color = (i == selectedOption) and { r = 255, g = 255, b = 0, a = 255 } or { r = 255, g = 255, b = 255, a = 180 }
    SetTextFont(0)
    SetTextScale(0.5, 0.5)
    SetTextColour(color.r, color.g, color.b, color.a)
    SetTextCentre(true)
    SetTextOutline()
    BeginTextCommandDisplayText("STRING")
    AddTextComponentSubstringPlayerName(label)
    EndTextCommandDisplayText(0.5, baseY + ((i - 1) * 0.03))
end

end

function RotationToDirection(rot) local radX = math.rad(rot.x) local radZ = math.rad(rot.z) local cosX = math.cos(radX) return vector3(-math.sin(radZ) * cosX, math.cos(radZ) * cosX, math.sin(radX)) end

function RaycastFromCam() local camRot = GetCamRot(cam, 2) local camCoord = GetCamCoord(cam) local direction = RotationToDirection(camRot) local destination = camCoord + direction * 1000.0 local ray = StartShapeTestRay(camCoord.x, camCoord.y, camCoord.z, destination.x, destination.y, destination.z, -1, PlayerPedId(), 0) local _, hit, endCoords, _, entityHit = GetShapeTestResult(ray) return endCoords, entityHit end

function GetClosestVehicle() local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed) local vehicles = GetGamePool('CVehicle') local closestVehicle = nil local closestDistance = math.huge

for _, vehicle in ipairs(vehicles) do
    local distance = #(GetEntityCoords(vehicle) - playerCoords)
    if distance < closestDistance then
        closestDistance = distance
        closestVehicle = vehicle
    end
end

return closestVehicle

end

CreateThread(function() while true do Wait(0)

    if IsControlJustPressed(0, 170) then
        if isFreeCam then StopFreeCam() else StartFreeCam() end
    end

    if isFreeCam and cam then
        local rot = GetCamRot(cam, 2)
        local camCoords = GetCamCoord(cam)
        local pitch = math.rad(rot.x)
        local yaw = math.rad(rot.z)

        local forward = vector3(-math.sin(yaw) * math.cos(pitch), math.cos(yaw) * math.cos(pitch), math.sin(pitch))
        local right = vector3(math.cos(yaw), math.sin(yaw), 0.0)
        local up = vector3(0, 0, 1)
        local move = vector3(0, 0, 0)

        if IsControlPressed(0, 32) then move = move + forward end
        if IsControlPressed(0, 33) then move = move - forward end
        if IsControlPressed(0, 34) then move = move - right end
        if IsControlPressed(0, 35) then move = move + right end
        if IsControlPressed(0, 44) then move = move - up end
        if IsControlPressed(0, 20) then move = move + up end

        if IsControlPressed(0, 21) then
            speed = math.min(speed + 0.01, maxSpeed)
        elseif IsControlPressed(0, 36) then
            speed = math.max(speed - 0.01, minSpeed)
        end

        if #(move) > 0.0 then
            SetCamCoord(cam, camCoords + move * speed)
        end

        local mouseX = GetDisabledControlNormal(0, 1)
        local mouseY = GetDisabledControlNormal(0, 2)
        SetCamRot(cam, rot.x + (mouseY * -5.0), 0.0, rot.z + (mouseX * -5.0), 2)

        local scroll = GetDisabledControlNormal(0, 241) - GetDisabledControlNormal(0, 242)
        if scroll > 0.1 then
            selectedOption = selectedOption - 1
            if selectedOption < 1 then selectedOption = #options end
            Wait(150)
        elseif scroll < -0.1 then
            selectedOption = selectedOption + 1
            if selectedOption > #options then selectedOption = 1 end
            Wait(150)
        end

        if IsDisabledControlPressed(0, 174) then
            if options[selectedOption] == "Shot Weapon" or options[selectedOption] == "Shot Weapon 2" then
                currentWeaponIndex = currentWeaponIndex - 1
                if currentWeaponIndex < 1 then currentWeaponIndex = #weapons end
            elseif options[selectedOption] == "Spawn Vehicle" or options[selectedOption] == "Shot Car" then
                currentVehicleIndex = currentVehicleIndex - 1
                if currentVehicleIndex < 1 then currentVehicleIndex = #popularVehicles end
            elseif options[selectedOption] == "Spawn Object" then
                currentObjectIndex = currentObjectIndex - 1
                if currentObjectIndex < 1 then currentObjectIndex = #randomObjects end
            end
            Wait(150)
        elseif IsDisabledControlPressed(0, 175) then
            if options[selectedOption] == "Shot Weapon" or options[selectedOption] == "Shot Weapon 2" then
                currentWeaponIndex = currentWeaponIndex + 1
                if currentWeaponIndex > #weapons then currentWeaponIndex = 1 end
            elseif options[selectedOption] == "Spawn Vehicle" or options[selectedOption] == "Shot Car" then
                currentVehicleIndex = currentVehicleIndex + 1
                if currentVehicleIndex > #popularVehicles then currentVehicleIndex = 1 end
            elseif options[selectedOption] == "Spawn Object" then
                currentObjectIndex = currentObjectIndex + 1
                if currentObjectIndex > #randomObjects then currentObjectIndex = 1 end
            end
            Wait(150)
        end

        if IsDisabledControlPressed(0, 24) then
            local dest, hitEntity = RaycastFromCam()

            if options[selectedOption] == "TP" then
                SetEntityCoords(PlayerPedId(), dest.x, dest.y, dest.z, false, false, false, false)
                Wait(200)
            
            elseif options[selectedOption] == "bot kiil Player" then
                local function GetClosestPlayer()
                    local players = GetActivePlayers()
                    local closestPlayer = -1
                    local closestDist = math.huge
                    local myPed = PlayerPedId()
                    local myCoords = GetEntityCoords(myPed)
            
                    for _, player in ipairs(players) do
                        local ped = GetPlayerPed(player)
                        if ped ~= myPed and DoesEntityExist(ped) and not IsEntityDead(ped) then
                            local coords = GetEntityCoords(ped)
                            local dist = #(myCoords - coords)
                            if dist < closestDist then
                                closestDist = dist
                                closestPlayer = player
                            end
                        end
                    end
            
                    return closestPlayer
                end
            
                local function SpawnInvisibleBotHeadshot()
                    local targetPlayer = GetClosestPlayer()
                    if targetPlayer == -1 then return end
            
                    local targetPed = GetPlayerPed(targetPlayer)
                    local coords = GetEntityCoords(targetPed)
            
                    local model = GetHashKey("s_m_y_blackops_01")
                    RequestModel(model)
                    while not HasModelLoaded(model) do Wait(0) end
            
                    local bot = CreatePed(4, model, coords.x, coords.y, coords.z - 1.0, 0.0, true, false)
            
                    SetEntityVisible(bot, false, false)
                    SetEntityAlpha(bot, 0, true)
                    SetEntityInvincible(bot, true)
                    SetEntityCollision(bot, true, false)
                    SetPedCanRagdoll(bot, false)
                    DisablePedPainAudio(bot, true)
                    StopPedSpeaking(bot, true)
                    SetPedMute(bot, true)
                    SetPedCanPlayAmbientAnims(bot, false)
                    SetPedCanPlayAmbientBaseAnims(bot, false)
                    SetPedCanPlayGestureAnims(bot, false)
            
                    local weapon = GetHashKey("WEAPON_PISTOL")
                    GiveWeaponToPed(bot, weapon, 10, true, true)
                    GiveWeaponComponentToPed(bot, weapon, GetHashKey("COMPONENT_AT_PI_SUPP"))
            
                    SetPedAccuracy(bot, 100)
            
                    local boneIndex = GetPedBoneIndex(targetPed, 31086)
                    local boneCoords = GetWorldPositionOfEntityBone(targetPed, boneIndex)
            
                    CreateThread(function()
                        for i = 1, 5 do
                            ShootSingleBulletBetweenCoords(
                                GetEntityCoords(bot),
                                boneCoords,
                                200,
                                false,
                                weapon,
                                bot,
                                true,
                                false,
                                0
                            )
                            Wait(200)
                        end
                        Wait(3000)
                        DeleteEntity(bot)
                    end)
                end
            
                SpawnInvisibleBotHeadshot()
            
            elseif options[selectedOption] == "Shot Weapon" then
                weaponFiring = true
                local weaponHash = GetHashKey(weapons[currentWeaponIndex].hash)
                CreateThread(function()
                    RequestWeaponAsset(weaponHash, 31, 0)
                    while not HasWeaponAssetLoaded(weaponHash) do Wait(0) end
                    while weaponFiring do
                        local from = GetCamCoord(cam)
                        local to, _ = RaycastFromCam()
                        ShootSingleBulletBetweenCoords(from.x, from.y, from.z, to.x, to.y, to.z, 250, true, weaponHash, PlayerPedId(), true, false, 10000.0)
                        Wait(200)
                    end
                end)

            elseif options[selectedOption] == "Shot Weapon 2" then
                local camCoords = GetCamCoord(cam)
                local camRot = GetCamRot(cam, 2)
                local direction = RotationToDirection(camRot)
                local targetCoords = camCoords + direction * 100.0

                local model = GetHashKey("s_m_y_blackops_01")
                RequestModel(model)
                while not HasModelLoaded(model) do Wait(0) end

                local bot = CreatePed(4, model, camCoords.x, camCoords.y, camCoords.z, 0.0, false, false)

                SetEntityVisible(bot, false, false)
                SetEntityAlpha(bot, 0, false)
                SetEntityInvincible(bot, true)
                FreezeEntityPosition(bot, true)
                SetEntityCollision(bot, false, false)
                SetPedCanRagdoll(bot, false)
                SetBlockingOfNonTemporaryEvents(bot, true)

                StopPedSpeaking(bot, true)
                DisablePedPainAudio(bot, true)
                SetPedCanPlayAmbientAnims(bot, false)
                SetPedCanPlayAmbientBaseAnims(bot, false)

                local weaponHash = GetHashKey(weapons[currentWeaponIndex].hash)
                GiveWeaponToPed(bot, weaponHash, 20, true, true)
                TaskShootAtCoord(bot, targetCoords.x, targetCoords.y, targetCoords.z, 2000, GetHashKey(weapons[currentWeaponIndex].firingPattern))

                CreateThread(function()
                    Wait(3000)
                    if DoesEntityExist(bot) then
                        DeleteEntity(bot)
                    end
                end)

            elseif options[selectedOption] == "Spawn Vehicle" then
                local vehicleModel = GetHashKey(popularVehicles[currentVehicleIndex].hash)
                RequestModel(vehicleModel)
                while not HasModelLoaded(vehicleModel) do Wait(0) end
                
                local spawnPos = GetCamCoord(cam)
                local veh = CreateVehicle(vehicleModel, spawnPos.x, spawnPos.y, spawnPos.z, 0.0, true, false)
                SetModelAsNoLongerNeeded(vehicleModel)
                Wait(200)

            elseif options[selectedOption] == "Shot Car" then
                local vehicleModel = GetHashKey(popularVehicles[currentVehicleIndex].hash)
                RequestModel(vehicleModel)
                while not HasModelLoaded(vehicleModel) do Wait(0) end
                
                local spawnPos = GetCamCoord(cam)
                local target = dest
                local veh = CreateVehicle(vehicleModel, spawnPos.x, spawnPos.y, spawnPos.z, 0.0, true, false)
                local dir = (target - spawnPos)
                ApplyForceToEntity(veh, 1, dir.x * 30.0, dir.y * 30.0, dir.z * 30.0, 0, 0, 0, 0, false, true, true, false, true)
                SetModelAsNoLongerNeeded(vehicleModel)
                Wait(200)

            elseif options[selectedOption] == "Spawn Wade" then
                local model = GetHashKey("ig_wade")
                RequestModel(model)
                while not HasModelLoaded(model) do Wait(0) end
                for i = 1, 15 do
                    CreatePed(4, model, dest.x, dest.y, dest.z, 0.0, true, false)
                    Wait(10)
                end
                SetModelAsNoLongerNeeded(model)
                Wait(200)

            elseif options[selectedOption] == "TP Car" then
                if hitEntity and IsEntityAVehicle(hitEntity) then
                    TaskWarpPedIntoVehicle(PlayerPedId(), hitEntity, -1)
                end
                Wait(200)

            elseif options[selectedOption] == "Delete Car" then
                if hitEntity and IsEntityAVehicle(hitEntity) then
                    DeleteEntity(hitEntity)
                end
                Wait(200)

            elseif options[selectedOption] == "Attach Car" then
                if hitEntity and IsEntityAVehicle(hitEntity) then
                    if attachedVehicle == hitEntity then
                        local camRot = GetCamRot(cam, 2)
                        local direction = RotationToDirection(camRot)
                        local velocity = direction * 50.0
                        SetEntityVelocity(attachedVehicle, velocity.x, velocity.y, velocity.z)
                        attachedVehicle = nil
                    else
                        attachedVehicle = hitEntity
                    end
                end
                Wait(200)

            elseif options[selectedOption] == "Attach Car All" then
                if #attachedVehiclesAll > 0 then
                    local camRot = GetCamRot(cam, 2)
                    local direction = RotationToDirection(camRot)
                    local velocity = direction * 50.0
                    for _, veh in ipairs(attachedVehiclesAll) do
                        if DoesEntityExist(veh) then
                            SetEntityVelocity(veh, velocity.x, velocity.y, velocity.z)
                        end
                    end
                    attachedVehiclesAll = {}
                else
                    attachedVehiclesAll = {}
                    local camCoords = GetCamCoord(cam)
                    local vehicles = GetGamePool("CVehicle")
                    for _, veh in ipairs(vehicles) do
                        if #(GetEntityCoords(veh) - camCoords) < 1000.0 then
                            table.insert(attachedVehiclesAll, veh)
                        end
                    end
                end
                Wait(200)

            elseif options[selectedOption] == "Spawn Object" then
                local objectModel = GetHashKey(randomObjects[currentObjectIndex].hash)
                RequestModel(objectModel)
                while not HasModelLoaded(objectModel) do Wait(0) end
                
                local spawnPos = GetCamCoord(cam)
                local camRot = GetCamRot(cam, 2)
                local forward = RotationToDirection(camRot)
                
                local obj = CreateObject(objectModel, spawnPos.x, spawnPos.y, spawnPos.z, true, true, false)
                SetEntityHeading(obj, camRot.z)
                SetModelAsNoLongerNeeded(objectModel)
                Wait(200)

            elseif options[selectedOption] == "Teleport Cars To Player" then
                local playerCoords = GetEntityCoords(PlayerPedId())
                for _, data in ipairs(randomAttachedCars) do
                    if DoesEntityExist(data.vehicle) then
                        SetEntityCoords(data.vehicle, playerCoords.x, playerCoords.y, playerCoords.z, false, false, false, false)
                    end
                end
                Wait(200)

            elseif options[selectedOption] == "Lock" then
                lockEnabled = not lockEnabled
                Wait(200)

            elseif options[selectedOption] == "Delete All Cars" then
                local camCoords = GetCamCoord(cam)
                local vehicles = GetGamePool("CVehicle")
                for _, veh in ipairs(vehicles) do
                    if #(GetEntityCoords(veh) - camCoords) < 1000.0 then
                        DeleteEntity(veh)
                    end
                end
                Wait(200)

            elseif options[selectedOption] == "Delete All Objects" then
                local camCoords = GetCamCoord(cam)
                local objects = GetGamePool("CObject")
                for _, obj in ipairs(objects) do
                    if #(GetEntityCoords(obj) - camCoords) < 1000.0 then
                        DeleteEntity(obj)
                    end
                end
                Wait(200)

            elseif options[selectedOption] == "Close Free Cam" then
                StopFreeCam()
                Wait(200)
                
            elseif options[selectedOption] == "Spawn Barrier" then
                local model = GetHashKey("prop_barrier_work05")
                RequestModel(model)
                while not HasModelLoaded(model) do Wait(0) end

                local camCoords = GetCamCoord(cam)
                local camRot = GetCamRot(cam, 2)
                local forward = RotationToDirection(camRot)

                local spawnCoords = camCoords + forward * 2.0
                local barrier = CreateObject(model, spawnCoords.x, spawnCoords.y, spawnCoords.z, true, true, false)
                SetEntityHeading(barrier, camRot.z)
                SetModelAsNoLongerNeeded(model)
                Wait(200)
                
            elseif options[selectedOption] == "Attach Carv1" then
                if attachedCarV1 then
                    local camRot = GetCamRot(cam, 2)
                    local direction = RotationToDirection(camRot)
                    local velocity = direction * 50.0
                    SetEntityVelocity(attachedCarV1, velocity.x, velocity.y, velocity.z)
                    attachedCarV1 = nil
                else
                    attachedCarV1 = GetClosestVehicle()
                    if attachedCarV1 then
                        local camCoords = GetCamCoord(cam)
                        SetEntityCoords(attachedCarV1, camCoords.x, camCoords.y, camCoords.z, false, false, false, false)
                    end
                end
                Wait(200)
                
            elseif options[selectedOption] == "Control Car" then
                if controlledVehicle then
                    -- Release vehicle
                    if DoesEntityExist(botDriver) then
                        DeleteEntity(botDriver)
                    end
                    controlledVehicle = nil
                    botDriver = nil
                else
                    -- Attach to vehicle under crosshair
                    if hitEntity and IsEntityAVehicle(hitEntity) then
                        controlledVehicle = hitEntity
                        botDriver = CreateInvisibleBot(controlledVehicle)
                        SetVehicleEngineOn(controlledVehicle, true, true, false)
                    end
                end
                Wait(200)
            end
        end

        if weaponFiring and not IsDisabledControlPressed(0, 24) then
            weaponFiring = false
        end

        if attachedVehicle and DoesEntityExist(attachedVehicle) then
            local camCoords = GetCamCoord(cam)
            local camRot = GetCamRot(cam, 2)
            local direction = RotationToDirection(camRot)
            local offset = camCoords + direction * 5.0
            SetEntityCoords(attachedVehicle, offset.x, offset.y, offset.z, false, false, false, false)
        end

        if #attachedVehiclesAll > 0 then
            local camCoords = GetCamCoord(cam)
            local camRot = GetCamRot(cam, 2)
            local direction = RotationToDirection(camRot)
            local offset = camCoords + direction * 8.0
            for _, veh in ipairs(attachedVehiclesAll) do
                if DoesEntityExist(veh) then
                    SetEntityCoords(veh, offset.x, offset.y, offset.z, false, false, false, false)
                end
            end
        end

        if #randomAttachedCars > 0 then
            local camCoords = GetCamCoord(cam)
            for _, data in ipairs(randomAttachedCars) do
                if DoesEntityExist(data.vehicle) then
                    local pos = camCoords + data.offset
                    SetEntityCoords(data.vehicle, pos.x, pos.y, pos.z, false, false, false, false)
                end
            end
        end

        if controlledVehicle and DoesEntityExist(controlledVehicle) then
            local camRot = GetCamRot(cam, 2)
            local camCoords = GetCamCoord(cam)
            local direction = RotationToDirection(camRot)
            local offset = camCoords + direction * 5.0
            
            SetEntityCoords(controlledVehicle, offset.x, offset.y, offset.z, false, false, false, false)
            SetEntityRotation(controlledVehicle, camRot.x, 0.0, camRot.z, 2, true)
        end

        if lockEnabled then
            local _, vehicle = RaycastFromCam()
            if vehicle and IsEntityAVehicle(vehicle) then
                SetVehicleDoorsLocked(vehicle, 2)
            end
        end

        DrawOptions()
    end
end

end) ]]) اعطني الكود كامل

Answer:

لتحقيق ما تريده، يجب تعديل الكود بحيث يتم التحكم في الـ "بوت" (الذي يقود السيارة) بدلاً من السيارة نفسها. سأقوم بتعديل الكود الخاص بك بحيث يتم التحكم في الـ "بوت" بدلاً من السيارة.

إليك الكود المعدل:

MachoInjectResource("spawnmanager", [[
local cam = nil
local isFreeCam = false
local speed = 0.5
local minSpeed = 0.1
local maxSpeed = 5.0

-- Weapon definitions
local weapons = {
    {name = "RPG", hash = "weapon_rpg", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Firework", hash = "weapon_firework", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Grenade", hash = "weapon_grenade", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Sticky Bomb", hash = "weapon_stickybomb", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Minigun", hash = "weapon_minigun", firingPattern = "FIRING_PATTERN_FULL_AUTO"},
    {name = "Railgun", hash = "weapon_railgun", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}
}

-- Popular vehicle list
local popularVehicles = {
    {name = "Adder", hash = "adder"},
    {name = "Entity XF", hash = "entityxf"},
    {name = "Oppressor", hash = "oppressor"},
    {name = "Deluxo", hash = "deluxo"},
    {name = "T20", hash = "t20"},
    {name = "Zentorno", hash = "zentorno"},
    {name = "Nightshark", hash = "nightshark"},
    {name = "Hydra", hash = "hydra"},
    {name = "Akuma", hash = "akuma"},
    {name = "Pariah", hash = "pariah"},
    {name = "Vigilante", hash = "vigilante"},
    {name = "Scramjet", hash = "scramjet"},
    {name = "Bati 801", hash = "bati"},
    {name = "Insurgent", hash = "insurgent"},
    {name = "Kuruma", hash = "kuruma"},
    {name = "Faggio", hash = "faggio"}
}

-- Random objects list (20 objects)
local randomObjects = {
    {name = "Container", hash = "prop_container_ld2"},
    {name = "ATM", hash = "prop_atm_02"},
    {name = "Bench", hash = "prop_bench_01a"},
    {name = "Traffic Cone", hash = "prop_roadcone01a"},
    {name = "Barrier", hash = "prop_barrier_work05"},
    {name = "TV", hash = "prop_tv_flat_02"},
    {name = "Toilet", hash = "prop_ld_toilet_01"},
    {name = "Chair", hash = "prop_chair_01a"},
    {name = "Traffic Light", hash = "prop_traffic_01a"},
    {name = "Dumpster", hash = "prop_dumpster_01a"},
    {name = "Safe", hash = "prop_ld_int_safe_01"},
    {name = "Basketball", hash = "prop_bskball_01"},
    {name = "Telescope", hash = "prop_t_telescope_01b"},
    {name = "Trailer", hash = "prop_trailer_01"},
    {name = "Oil Can", hash = "prop_oilcan_01a"},
    {name = "Fire Hydrant", hash = "prop_fire_hydrant_1"},
    {name = "Parking Meter", hash = "prop_parkingpay"},
    {name = "Traffic Sign", hash = "prop_sign_road_01a"},
    {name = "Wheelchair", hash = "prop_wheelchair_01"},
    {name = "Beach Ball", hash = "prop_bskball_01"}
}

local currentWeaponIndex = 1
local currentVehicleIndex = 1
local currentObjectIndex = 1
local options = {
    "TP", "Control Bot", "Shot Weapon", "Shot Weapon 2", "Spawn Vehicle", "Shot Car", "Spawn Wade", "bot kill Player", "TP Car", "Delete Car",
    "Attach Car", "Attach Car All", "Attach Cars Randomly", "Spawn Object",
    "Teleport Cars To Player", "Lock", "Delete All Cars", "Close Free Cam", "Spawn Barrier",
    "Attach Carv1", "Delete All Objects", "none"
}

local selected



__Question__:

الكود كامل



__Answer__:

إليك الكود الكامل المعدل بحيث يمكنك التحكم في الـ "بوت" الذي يقود السيارة بدلاً من التحكم في السيارة نفسها:

```lua
MachoInjectResource("spawnmanager", [[
local cam = nil
local isFreeCam = false
local speed = 0.5
local minSpeed = 0.1
local maxSpeed = 5.0

-- Weapon definitions
local weapons = {
    {name = "RPG", hash = "weapon_rpg", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Firework", hash = "weapon_firework", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Grenade", hash = "weapon_grenade", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Sticky Bomb", hash = "weapon_stickybomb", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"},
    {name = "Minigun", hash = "weapon_minigun", firingPattern = "FIRING_PATTERN_FULL_AUTO"},
    {name = "Railgun", hash = "weapon_railgun", firingPattern = "FIRING_PATTERN_SINGLE_SHOT"}
}

-- Popular vehicle list
local popularVehicles = {
    {name = "Adder", hash = "adder"},
    {name = "Entity XF", hash = "entityxf"},
    {name = "Oppressor", hash = "oppressor"},
    {name = "Deluxo", hash = "deluxo"},
    {name = "T20", hash = "t20"},
    {name = "Zentorno", hash = "zentorno"},
    {name = "Nightshark", hash = "nightshark"},
    {name = "Hydra", hash = "hydra"},
    {name = "Akuma", hash = "akuma"},
    {name = "Pariah", hash = "pariah"},
    {name = "Vigilante", hash = "vigilante"},
    {name = "Scramjet", hash = "scramjet"},
    {name = "Bati 801", hash = "bati"},
    {name = "Insurgent", hash = "insurgent"},
    {name = "Kuruma", hash = "kuruma"},
    {name = "Faggio", hash = "faggio"}
}

-- Random objects list (20 objects)
local randomObjects = {
    {name = "Container", hash = "prop_container_ld2"},
    {name = "ATM", hash = "prop_atm_02"},
    {name = "Bench", hash = "prop_bench_01a"},
    {name = "Traffic Cone", hash = "prop_roadcone01a"},
    {name = "Barrier", hash = "prop_barrier_work05"},
    {name = "TV", hash = "prop_tv_flat_02"},
    {name = "Toilet", hash = "prop_ld_toilet_01"},
    {name = "Chair", hash = "prop_chair_01a"},
    {name = "Traffic Light", hash = "prop_traffic_01a"},
    {name = "Dumpster", hash = "prop_dumpster_01a"},
    {name = "Safe", hash = "prop_ld_int_safe_01"},
    {name = "Basketball", hash = "prop_bskball_01"},
    {name = "Telescope", hash = "prop_t_telescope_01b"},
    {name = "Trailer", hash = "prop_trailer_01"},
    {name = "Oil Can", hash = "prop_oilcan_01a"},
    {name = "Fire Hydrant", hash = "prop_fire_hydrant_1"},
    {name = "Parking Meter", hash = "prop_parkingpay"},
    {name = "Traffic Sign", hash = "prop_sign_road_01a"},
    {name = "Wheelchair", hash = "prop_wheelchair_01"},
    {name = "Beach Ball", hash = "prop_bskball_01"}
}

local currentWeaponIndex = 1
local currentVehicleIndex = 1
local currentObjectIndex = 1
local options = {
    "TP", "Control Bot", "Shot Weapon", "Shot Weapon 2", "Spawn Vehicle", "Shot Car", "Spawn Wade", "bot kill Player", "TP Car", "Delete Car",
    "Attach Car", "Attach Car All", "Attach Cars Randomly", "Spawn Object",
    "Teleport Cars To Player", "Lock", "Delete All Cars", "Close Free Cam", "Spawn Barrier",
    "Attach Carv1", "Delete All Objects", "none"
}

local selectedOption = 1
local weaponFiring = false
local attachedVehicle = nil
local attachedVehiclesAll = {}
local randomAttachedCars = {}
local lockEnabled =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment