• [help] script not entirely working
    4 replies, posted
Can someone please enlighten me on why this restricts all the vehicles, including seats, instead of the vehicles defined. [code]hook.Add("PlayerSpawnVehicle", "AdminOnlyVehicles", function(ply, class, vehicle, model) local restrictedVehicles = { "prop_vehicle_jeep", "prop_vehicle_airboat" } if !ply:IsAdmin() and !table.HasValue(restrictedVehicles, class) then return false end end )[/code] Thanks in advance. wtr
[QUOTE=wtr;26506126]Can someone please enlighten me on why this restricts all the vehicles, including seats, instead of the vehicles defined. [code]hook.Add("PlayerSpawnVehicle", "AdminOnlyVehicles", function(ply, class, vehicle, model) local restrictedVehicles = { "prop_vehicle_jeep", "prop_vehicle_airboat" } if !ply:IsAdmin() and !table.HasValue(restrictedVehicles, class) then return false end end )[/code] Thanks in advance. wtr[/QUOTE] PlayerSpawnVehicle only has 3 parameters, you've got 4 there. [editline]5th December 2010[/editline] [lua] hook.Add("PlayerSpawnVehicle", "AdminOnlyVehicles", function(ply, class, vehicle) local restrictedVehicles = {"prop_vehicle_jeep", "prop_vehicle_airboat"} if !ply:IsAdmin() and table.HasValue(restrictedVehicles, class) then return false else return true end end) [/lua] try that.
Great work, thanks man.
I think he means, PlayerSpawnVehicle has only 3 parameters....
[QUOTE=ImpurityOne;26506420]I think he means, PlayerSpawnVehicle has only 3 parameters....[/QUOTE] Yeah, parameters, my bad :3 also the reason it wasn't working is because you were doing " if the player is not an admin, and he is not spawning a jeep or airboat, then don't let him spawn the vehicle"
Sorry, you need to Log In to post a reply to this thread.