Hey, I have been trying to find a way to make in my script block all Player Use except doors. Does anyone know how to change this script?
Thanks
local function vehicleEnterExit(ply, ent)
local whitelistedGroups = {
["admin"] = true,
["superadmin"] = true,
["pilot"] = true
}
if not whitelistedGroups[ply:GetUserGroup()] then
return false
end
end
hook.Add("PlayerUse", "AllowPilotsEnterVehicle", vehicleEnterExit)
Please use the Code Tag from the Forum.
You should make another check to check if the Ent that the player tries to use is a door than let him.. you could use something like this:
HitFuncs = { -- Table of items that if it hits it'll create a hand.
["func_button"] = true,
["func_door"] = true, --Draws Hand over Doors
-- ["func_door_rotating"] = true, --Draws Hand over Doors
["prop_door_rotating"] = true, --Draws Hand over Doors
-- ["button_keypad"] = true, --Draws Hand over Doors
["Buttons"] = true,
["class C_BaseEntity"] = true,
}
and you could use this as a check:
if HitFuncs[LocalPlayer():GetEyeTrace().Entity:GetClass() ] then--code--end
I think that i do something wrong
local function vehicleEnterExit(ply, ent)
local HitFuncs = {
["func_button"] = true,
["func_door"] = true,
["func_door_rotating"] = true,
["prop_door_rotating"] = true,
["button_keypad"] = true,
["Buttons"] = true,
["class C_BaseEntity"] = true,
}
local whitelistedGroups = {
["admin"] = true,
["superadmin"] = true,
["pilot"] = true
}
if HitFuncs[LocalPlayer():GetEyeTrace().Entity:GetClass() ] then
if not whitelistedGroups[ply:GetUserGroup()] then
return false
end
end
hook.Add("PlayerUse", "AllowPilotsEnterVehicle", vehicleEnterExit)
You have to take a look here:
local HitFuncs = {
["func_button"] = true,
["func_door"] = true,
["func_door_rotating"] = true,
["prop_door_rotating"] = true,
["button_keypad"] = true,
["Buttons"] = true,
["class C_BaseEntity"] = true, --Clientside Buttons
}
local whitelistedGroups = {
["admin"] = true,
["superadmin"] = true,
["pilot"] = true
}
function vehicleEnterExit(ply, ent)
if !whitelistedGroups[ply:GetUserGroup()] or not HitFuncs[ply:GetEyeTrace().Entity:GetClass() ] then
return false
end
end
hook.Add("PlayerUse", "AllowPilotsEnterVehicle", vehicleEnterExit)
It's doesnt work, i tested it on client and server in my lua files. I still can't open doors.
Did you put this file in lua/autorun?
Ohh i have tested it in lua/autorun and
it's working but not in all.
Now:
If i'am superadmin i can open door and i can't use vehicles.
If i'am user i can't open doors and i can't use vehicles.
It should work like that:
If i'am superadmin i can open door and Player Use.
If i'am user i can open doors and i can't use vehicles.
you can just make the if checks another spo return the wrong false and the right true and so on just work with if statements elseif.. and or more u dont need
I can't hit in good point.
Now if i'am admin i can anything,
if i'am user i can't anything.
I think that is problem in whitelist - if i change example admin to user then i will can use everything.
local HitFuncs = {
["func_button"] = true,
["func_door"] = true,
["func_door_rotating"] = true,
["prop_door_rotating"] = true,
["button_keypad"] = true,
["Buttons"] = true,
["class C_BaseEntity"] = true, --Clientside Buttons
}
local whitelistedGroups = {
["admin"] = true,
["superadmin"] = true,
["pilot"] = true
}
function vehicleEnterExit(ply, ent)
if !whitelistedGroups[ply:GetUserGroup()] then
return false
elseif HitFuncs[ply:GetEyeTrace().Entity:GetClass()] then
return true
end
end
hook.Add("PlayerUse", "AllowPilotsEnterVehicle", vehicleEnterExit)
And so?
local HitFuncs = {
["func_button"] = true,
["func_door"] = true,
["func_door_rotating"] = true,
["prop_door_rotating"] = true,
["button_keypad"] = true,
["Buttons"] = true,
["class C_BaseEntity"] = true, --Clientside Buttons
}
local whitelistedGroups = {
["admin"] = true,
["superadmin"] = true,
["pilot"] = true
}
function vehicleEnterExit(ply, ent)
if whitelistedGroups[ply:GetUserGroup()] then
return true
elseif not whitelistedGroups[ply:GetUserGroup()] and HitFuncs[ply:GetEyeTrace().Entity:GetClass()] then
return true
else
return false
end
end
hook.Add("PlayerUse", "AllowPilotsEnterVehicle", vehicleEnterExit)
You should never return anything in a hook unless you are trying to stop the event from happening. By this I mean you shouldn't be returning true in any case.
Yeah ure right i forgot that u never return true a hook....
this causes some hooks to break the game...
Good morning, you mean that use_whitelist.lua it's another file? I don't have in my files use_whitelist.lua, i think that i deleted that yesterday instance, i can't find that file in google to download..
If i tested this in my own file pilot.lua it's doesnt work - admin can everything and again user can't everything.
I would like to user can't use all except doors.
I'm telling you to create the file, but you can put it in any file in lua/autorun/server.
Thank You for reply! Ok i done that but as i write before:
It's doesnt work - admin can everything and again user can't everything.
I think that it's working that if i'am on whitelisted i can open doors and use, but
if i'am not admin or superadmin or pilot i can't open doors and use vehicles.
I don't know why it's connected.
I would like to user can't use except doors.
Sorry, you need to Log In to post a reply to this thread.