• Restricting Commands to jobs ?
    6 replies, posted
Okay so what I'm not sure how to do is to be able to restrict ULX Commands so that they can only be used when they are on the job so like for someone who has the permission to use the command has to be in a required job. Below is just an example of 3 Jobs 1 job that wont be able to use commands and the other two that will be able to. TEAM_UNTRAINED = DarkRP.createJob("Military Trainee", { color = Color(204, 204, 204, 255), model = {"models/player/summermilitary/male_02.mdl", "models/player/summermilitary/male_04.mdl", "models/player/summermilitary/male_05.mdl", "models/player/summermilitary/male_06.mdl", "models/player/summermilitary/male_08.mdl", "models/player/summermilitary/male_09.mdl"}, description = [[You are a Military Trainee!]], weapons = {"pocket"}, command = "trainee", max = 0,  salary = 0, admin = 0, vote = false, hasLicense = false, candemote = false, category = "Training", sortOrder = 101, PlayerLoadout = function(ply)  ply:SetRunSpeed(190) end, }) TEAM_STAFF = DarkRP.createJob("Staff On Duty", { color = Color(109, 109, 109, 109), model = {"models/player/combine_super_soldier.mdl"}, description = [[Staff On Duty of the server. Not involved in roleplay.]], weapons = {"pocket", "gmod_tool", "weapon_physgun"}, command = "staffonduty", max = 0,  salary = 0, admin = 0, vote = false, hasLicense = false, candemote = false, category = "Staff", sortOrder = 1, PlayerLoadout = function(ply)  ply:SetHealth(150000) end, BWhitelist_customCheck = function(ply) return CLIENT or         table.HasValue({"tmod", "mod", "seniormod", "tadmin", "admin", "senioradmin", "superadmin"}, ply:GetNWString("usergroup"))     end, }) TEAM_EP = DarkRP.createJob("Event Planner On Duty", { color = Color(109, 109, 109, 109), model = {"models/player/combine_super_soldier.mdl"}, description = [[Event On Duty for the server.]], weapons = {"pocket", "gmod_tool", "weapon_physgun"}, command = "eventonduty", max = 0,  salary = 0, admin = 0, vote = false, hasLicense = false, candemote = false, category = "Staff", sortOrder = 1, PlayerLoadout = function(ply)  ply:SetHealth(150000) end, BWhitelist_customCheck = function(ply) return CLIENT or         table.HasValue({"eventplanner", "eventmanager", "headevent", "superadmin"}, ply:GetNWString("usergroup"))     end,})
if SERVER then local ULXCommands = { ["/goto"] = {"admin", "superadmin"} } function checkRank( ply, ranks ) local hasValue = table.HasValue( k, ply:GetNWString("usergroup") ) return hasValue end hook.Add("PlayerSay", "ULXCheck", function( ply, text ) local split = string.Explode( " ", text ) local cmd = split[1] for k, v in pairs(ULXCommands) do if cmd == k and !( checkRank( ply ), v ) then local message = {Color(230, 126, 34, 255), "[Warning]", Color( 255, 255, 255, 255), "You cannot use the ULX command: " .. k} net.Start("SendMessage") net.WriteTable(message) net.Send(ply) return "" end end end) elseif CLIENT then net.Receive("SendMessage", function( len, ply ) local message = unpack( net.ReadTable() ) chat.AddText(message) end) end I haven't tested this and somebody will find a better way of doing this but i guess this can be a start for you. Apologies if it doesn't work.
I don't have any experience in DarkRP, so I am not sure if you can do something in the custom check, but why not just check for the job inside of the ULX command?
I was just thinking in the long term if he needed to restrict different commands to different jobs i suppose. im just being dumb i guess lol
How would I do that
Sorry, you need to Log In to post a reply to this thread.