How Can I Stop People Spawning Vehicles?

Hey guys I know this is stupid and theres probably an easy fix but
how can i stop people from spawning vehicles whilst still haveing sbox_maxvehicles 3
I want to know this because in darkrp you can buy vehicles, but when max vehicles is 0 you cant buy them,
And when its not 0 then you can just spawn them :frowning:
Please Help Me :smiley:

Go to


Make a new file called “vehicleblock.lua” (Or anything you want)
Put this code in it:

function VehicleBlock( ply )
     if (!ply:IsAdmin()) then -- Makes you able to spawn vehicles if you are admin :)
          ply:PrintMessage( HUD_PRINTTALK, "Spawning vehicles has been blocked!" )
          return false
hook.Add("PlayerSpawnVehicle", "VehicleBlock", VehicleBlock )