Vehicles admin only?

I’m just wondering, is there a way or a code to make certain vehicles that only admins can spawn? I have a dedicated server and I want only admins to be able to spawn helicopters.

In the lua file included for the vehice do this:

ENT.AdminSpawnable = true
ENT.PlayerSpawnable = false

If there’s no included lua file, but has a spawn list file, you have to code the whole vehicle entity…

[lua]

hook.Add(“PlayerSpawnVehicle”, “HelicopterAdminOnly”, function(ply, model, name)
if name == “HELICOPTER_NAME” and not ply:IsAdmin() then
return false
end
return true
end)
[/lua]

[lua]

hook.Add(“PlayerSpawnVehicle”, “HelicopterAdminOnly”, function(ply, model, name)
if not xPermissions.HasPermission(ply, “vehicle”) then
return false
end
return true
end)
[/lua]

You do see what’s wrong with that right?

Thanks for the help. How would I also do it for people wiht certain Steam ID’s?

[lua]
hook.Add(“PlayerSpawnVehicle”, “HelicopterSpawn”, function(ply, model, name)
if name == “HELICOPTER_NAME” and not ply:SteamID() == “STEAM_ID_HERE” then
return false
end
return true
end)
[/lua]

Why… Just why would you put your addon in there that hardly works.
Stop trying to force it on people.

where would I put this? I placed this in the autorun/lambo.lua but it didn’t work.

Did you change the string “HELICOPTER_NAME” on line 2 to the name of the helicopter ent?

Yes, here is the full code: