WIP full rework of LFS' framework to be more universal for later projects allowing for more unique vehicle types and hopefully more reliable handling even on low tickrate environments
28
stars
16
forks
source link
New hooks to determine if a player could drive #34
Hello, added new hooks to determine if a player could drive a vehicle:
LVS.CanPlayerDrive
LVS.OnPlayerCannotDrive
This could be useful for driver license systems and etc., I personally use these hooks to limit the ability to use vehicles for untrained soldiers on the Star Wars RP server.
Example:
local function canPlayerControlVehicle(ply, vehicle)
if (not IsValid(vehicle)) then return false end
local class = vehicle:GetClass()
local isAir = mopp.cfg.AirVehicles[class]
local isLand = mopp.cfg.LandVehicles[class]
local allowed
if (isAir) then
allowed = ply:HasRight("air")
else
allowed = ply:HasRight("land")
end
return allowed
end
hook.Add('LVS.CanPlayerDrive', 'Whitelist', function(ply, vehicle)
if (not IsValid(vehicle)) then return end
if (not canPlayerControlVehicle(ply, vehicle)) then
return false
end
end)
hook.Add('LVS.OnPlayerCannotDrive', 'Whitelist', function(ply, vehicle)
doNotify(ply, vehicle)
end)
Hello, added new hooks to determine if a player could drive a vehicle:
This could be useful for driver license systems and etc., I personally use these hooks to limit the ability to use vehicles for untrained soldiers on the Star Wars RP server.
Example: