• Restrict usage
    2 replies, posted
Hello, I'm back with more questions. I was wondering how to restricht my entity from being used by certain jobs. I use it for DarkRP and I'd like to only let 1 job access it, take for this example the hobo. How would I do this, right now I thought of this. function ENT:Use( ply, c) if ply:GetTeam() == TEAM_HOBO then net.Start( "ClientSide" ) net.Send(ply) end That did nothing sadly. As always any answers are appreciated and thanks for helping a noob like me
Did you define TEAM_HOBO anywhere? If not you're comparing against team == null, which is probably never true.
Those TEAM_JOB type globals are the more or less standard way of creating a darkrp job in "addons\darkrpmodification\lua\darkrp_customthings\jobs.lua". Typical example: https://files.facepunch.com/forum/upload/300167/4332f23c-a3f6-4169-84ce-5765158101bf/YMKDqGS.png The global created is simply equal to the team's respective index. Using such a global is perfectly fine (though it should be defined as a config option if it is for an addon being released to multiple servers). In the case of using it in an entity's Use function, something like this will suffice: if ply:Team() ~= TEAM_HOBO then return end // Whatever code you want to run here Something to keep in mind if you plan to use it somewhere that runs automatically at startup (like a config for example), you will need to delay your addon from loading by at least a single frame. Something I typically like doing is: // Some autorun file local function Inititate() include("file") end timer.Simple( 0, Inititate) The reason for this being that DarkRP needs to be given a chance to fully load and define these globals. Not doing this could potentially lead to your addon loading before the jobs portion of darkrp and obviously cause errors. (Also, ply:GetTeam() isn't a valid function, regarding your first little snippet of code)
Sorry, you need to Log In to post a reply to this thread.