Skip to content

Commit

Permalink
Prevent starting the vehicle engine if we deny the player
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Jun 23, 2024
1 parent 502e857 commit 55febfc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gamemode/sh_vehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ if SERVER then
-- Check if the vehicle is owned by someone else.
if IsValid(vehicleOwner) and vehicleOwner ~= ply then
DbgPrint("Player not allowed to enter vehicle, owned by: " .. tostring(vehicleOwner))
-- If this is true it will start the engine and release the handbrake despite
-- the player not being able to enter the vehicle.
vehicle:SetVehicleEntryAnim(false)
return false
end

Expand All @@ -341,7 +344,8 @@ if SERVER then
local playerVehicle = self:PlayerGetVehicleOwned(ply)
if IsValid(playerVehicle) and playerVehicle ~= vehicle then
DbgPrint("Player already owns a vehicle")
ply:EmitSound("common/wpn_denyselect.wav")
ply:EmitSound("HL2Player.UseDeny")
vehicle:SetVehicleEntryAnim(false)
return false
end
else
Expand Down

0 comments on commit 55febfc

Please sign in to comment.