local fakeFirstPerson = false local rat = nil local cam = nil local lastY = 1.0 local offX = 1.0 local offY = 1.0 local YADD = 0.0 RegisterCommand(commandName, function(source, args, rawCommand) if not fakeFirstPerson then SetFollowPedCamViewMode(1) SetFollowVehicleCamViewMode(1) fakeFirstPerson = true else SetFollowPedCamViewMode(0) SetFollowVehicleCamViewMode(0) fakeFirstPerson = false end end) RegisterNetEvent('setRatInvisible') AddEventHandler('setRatInvisible', function(netid) if (NetworkDoesEntityExistWithNetworkId(netid)) then local thisRat = NetworkGetEntityFromNetworkId(netid) SetEntityInvincible(thisRat, true) SetEntityCollision(thisRat, false, false) SetEntityVisible(thisRat, false, 0) end end) Citizen.CreateThread(function() while true do if fakeFirstPerson then local ped = GetPlayerPed(-1) if cam == nil then local hash = GetHashKey("a_c_rat") while not HasModelLoaded(hash) do RequestModel(hash) Wait(20) end rat = CreatePed("PED_TYPE_ANIMAL", hash, 0, 0, 0, 0, true, true) AttachEntityToEntity(rat, GetPlayerPed(-1), GetPedBoneIndex(GetPlayerPed(-1), 31086), 0.2, 0.04, 0, 0, 270.0, 60.0, true, true, false, true, 1, true) SetEntityInvincible(rat, true) SetEntityCollision(rat, false, false) SetEntityVisible(rat, false, 0) TriggerServerEvent("makeRatInvisible", NetworkGetNetworkIdFromEntity(rat)) cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) local bone = GetPedBoneIndex(ped, 12844) SetCamFov(cam, camFOV) AttachCamToEntity(cam, rat, camOffsetX, camOffsetY, camOffsetZ, true) RenderScriptCams(true, false, 0, 1, 0) SetCamNearClip(cam, 0.09) end SetEntityInvincible(rat, true) SetEntityCollision(rat, false, false) SetEntityVisible(rat, false, 0) CheckInputRotation() local bx = GetEntityRotation(rat) local b = GetEntityRotation(ped) local zAdd = (offY - lastY) if IsPlayerFreeAiming(PlayerId()) then if YADD <= (offX / 2) * -1 - 0.5 then YADD = YADD + 0.5 elseif YADD >= (offX / 2) * -1 + 0.5 then YADD = YADD - 0.5 end elseif IsPedSprinting(PlayerPedId()) then if YADD >= 12.5 then YADD = YADD - 0.5 elseif YADD <= 11.5 then YADD = YADD + 0.5 end elseif IsPedWalking(PlayerPedId()) then if YADD >= 3.5 then YADD = YADD - 0.5 elseif YADD <= 2.5 then YADD = YADD + 0.5 end else if YADD >= 0.5 then YADD = YADD - 0.5 elseif YADD <= -0.5 then YADD = YADD + 0.5 end end if GetVehiclePedIsIn(ped, false) == 0 then SetCamRot(cam, bx.x + offX - 180.0, bx.y - YADD - 5.0, b.z + zAdd, 2) SetEntityHeading(PlayerPedId(), b.z + zAdd) SetEntityRotation( PlayerPedId(), --[[ Entity ]] b.x, -- + offX --[[ number ]], b.y, -- YADD - 5.0 --[[ number ]], b.z + zAdd, --[[ number ]] 2 --[[ integer ]], true --[[ boolean ]] ) SetGameplayCamRelativeRotation( b.x, -- + offX --[[ number ]], b.y, -- YADD - 5.0 --[[ number ]], b.z + zAdd --[[ number ]] ) else if IsControlPressed(0, 26) then AttachCamToEntity(cam, rat, reverseCamOffsetX, reverseCamOffsetY, reverseCamOffsetZ, true) SetCamRot(cam, bx.x + offX - 180.0, bx.y - YADD - 5.0, b.z + offY + 180.0, 2) else AttachCamToEntity(cam, rat, camOffsetX, camOffsetY, camOffsetZ, true) SetCamRot(cam, bx.x + offX - 180.0, bx.y - YADD - 5.0, b.z + offY, 2) end end lastY = offY else if cam ~= nil then RenderScriptCams(false, false, 0, 1, 0) DestroyCam(cam, true) TriggerServerEvent("deleteRat", NetworkGetNetworkIdFromEntity(rat)) DeleteEntity(rat) rat = nil cam = nil end end Wait(0) end end) function CheckInputRotation() local rightAxisX = GetDisabledControlNormal(0, 220) local rightAxisY = GetDisabledControlNormal(0, 221) offX = offX + rightAxisY * -5 offY = offY + rightAxisX * -5 if (offX > 70.0) then offX = 70.0 elseif (offX < -70.0) then offX = -70.0 end if (GetVehiclePedIsIn(PlayerPedId(), false) ~= 0) then if (offY > 60.0) then offY = 60.0 elseif (offY < -60.0) then offY = -60.0 end end end