First person shooting from all vehicles (cars, bikes, boats, etc)
Looking for a script to force players to use first person when shooting from all vehicles? Look no further! This is a great script for RP servers.
This was very helpful for us to stop players from driving around backwards unrealistically during gunfights since third person shooting lets you shoot in a 360 degree angle without obstruction and often times the vehicle will block any bullets from the rear
It is also helpful to make aiming a bit more difficult and realistic than it is in 3rd person when in a vehicle
Screenshot
Features
Standalone
Works on all vehicles (cars, bikes, boats, etc)
Resets camera mode properly after forcing first person
local shot = false
local check = false
local check2 = false
local count = 0
CreateThread(function()
while true do
SetBlackout(false)
Wait(1)
if IsPlayerFreeAiming(PlayerId()) then
if GetFollowPedCamViewMode() == 4 and check == false then
check = false
else
SetFollowVehicleCamViewMode(4)
check = true
end
else
if check == true then
SetFollowVehicleCamViewMode(1)
check = false
end
end
end
end)
CreateThread(function()
while true do
SetBlackout(false)
Wait(1)
if IsPedShooting(PlayerPedId()) and shot == false and GetFollowPedCamViewMode() ~= 4 then
check2 = true
shot = true
SetFollowVehicleCamViewMode(4)
end
if IsPedShooting(PlayerPedId()) and shot == true and GetFollowPedCamViewMode() == 4 then
count = 0
end
if not IsPedShooting(PlayerPedId()) and shot == true then
count = count + 1
end
if not IsPedShooting(PlayerPedId()) and shot == true then
if not IsPedShooting(PlayerPedId()) and shot == true and count > 20 then
if check2 == true then
check2 = false
shot = false
SetFollowVehicleCamViewMode(1)
end
end
end
end
local Infos = {
["InCar"] = {Value = false, LastTime = 0},
["Player"] = {Handel = -1, HandelId = -1, LastTime = 0},
["Cam"] = {LastCam = -1, CamChanged = false, LastTime = 0},
["Aimed"] = {Value = false, LastTime = 0},
}
IsPlayerFreeAimed = function(PedHandel,PedId)
if IsPlayerFreeAiming(PedId) or IsPedShooting(PedHandel) or IsAimCamActive() or IsAimCamThirdPersonActive() then
return true
else
return false
end
end
SetCam = function(CamId)
Citizen.CreateThreadNow(function()
SetFollowPedCamViewMode(CamId)
SetFollowVehicleCamViewMode(CamId)
for i = 0, 7 do
SetCamViewModeForContext(i, CamId)
end
end)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local Now = GetGameTimer()
if Infos["Player"].Handel == -1 or Infos["Player"].LastTime + 1000 < Now then
Infos["Player"].Handel = PlayerPedId()
Infos["Player"].HandelId = PlayerId()
Infos["Player"].LastTime = Now
end
if Infos["Cam"].LastTime + 100 < Now then
if not Infos["Cam"].CamChanged then
Infos["Cam"].LastCam = GetFollowVehicleCamViewMode()
end
Infos["Cam"].LastTime = Now
end
if Infos["InCar"].LastTime + 100 < Now then
Infos["InCar"].Value = IsPedInAnyVehicle(Infos["Player"].Handel, false)
Infos["InCar"].LastTime = Now
end
if Infos["InCar"].Value then
-- if Infos["Aimed"].LastTime + 50 < Now then
-- Infos["Aimed"].Value = IsPedArmed(Infos["Player"].Handel, 4) and IsPlayerFreeAimed(Infos["Player"].Hande, Infos["Player"].HandelId)
-- Infos["Aimed"].LastTime = Now
-- end
-- if Infos["Aimed"].Value then -- somehow this get bug and dont show well
if IsControlJustPressed(0,68) then
SetCam(4)
Infos["Cam"].CamChanged = true
elseif not Infos["Aimed"].Value and Infos["Cam"].CamChanged then
SetCam(Infos["Cam"].LastCam)
Infos["Cam"].CamChanged = false
end
elseif not Infos["InCar"] and Infos["Cam"].CamChanged then
SetCam(Infos["Cam"].LastCam)
Infos["Cam"].CamChanged = false
end
end
end)
edited i just place logic in like 2 or 3 min didnt tested but now edited and working on all vehicle just need read SetCamViewModeForContext native for set cam in anything like foot car bike boat
btw
its not something to be one post btw just some little code i just wonder why this need be as paid thing
hey, thanks for tagging me. I already made a script that does this, it also makes the player keep the third person animations while on FP on foot. You can download, modify and use the way you want. Check it out. Leave a star on the repository so more people can reach it.
Feel free to ask me anything if theres any doubts.
Edit: I have not tested the script for 2 years now, and I cant now, you may have to modify it.
I’ve been using this code and it works great. However you can currently exploit it if you hold right click while pulling a gun out while in a vehicle. It stays in third person until you release right click and press again.
hey bro, to fix this exploit, at the bottom of the code (if IsControlJustPressed(0,68) then)
change IsControlJustPressed to IsControlPressed
remove (Just) from it and it will work
-------------------------------------------
---------- Force FPS when shoting ---------
-------------------------------------------
CreateThread(function()
while true do
sleep = 1000
local _, weapon = GetCurrentPedWeapon(PlayerPedId())
local unarmed = `WEAPON_UNARMED`
if weapon == unarmed then
sleep = 1000
else
local ped = PlayerPedId()
local veh = GetVehiclePedIsIn(ped, false)
local vehentity = GetEntityModel(veh)
local onfoot = IsPedOnFoot(ped)
local incar = IsThisModelACar(vehentity)
local onbike = IsThisModelABike(vehentity)
sleep = 1
-- if onfoot then
-- if IsPlayerFreeAiming(PlayerId()) then
-- SetFollowPedCamViewMode(4)
-- else
-- SetFollowPedCamViewMode(0)
-- end
-- end
if incar then
if IsPlayerFreeAiming(PlayerId()) then
SetFollowVehicleCamViewMode(4)
else
SetFollowVehicleCamViewMode(0)
end
end
if onbike then
if IsPlayerFreeAiming(PlayerId()) then
SetCamViewModeForContext(2, 4)
else
SetCamViewModeForContext(2, 0)
end
end
end
Wait(sleep)
end
end)