ULX

Author Topic: Restrict DarkRp job class to certain ulx ranks  (Read 30299 times)

0 Members and 1 Guest are viewing this topic.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Restrict DarkRp job class to certain ulx ranks
« on: January 25, 2013, 08:52:47 PM »
Basically what i want to do is make it so you have to be in a certain group to become a job in darkrp.

I've tried using the method falco posted on the google code page for the project Ive tried editing the player.lua for darkrp nothing is working.

Is there anyone who knows how i can do this?
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Racer

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #3 on: January 26, 2013, 10:07:22 AM »
I can't believe I am able to help on here but go to: "gamemodes\darkrp\gamemode\server" and edit the file, "player.lua"

Hit ctrl + F and Search for "meta:ChangeTeam"

Once there, Do something like this:

Code: [Select]
if t == TEAM_ADMIN then
        if self:IsUserGroup("testgrouphere") then
            GAMEMODE:Notify( self, 1, 4, "You are not the proper group for this job!")
            return false
        end
end

Or if you want it to be admin AND a certain group:

Code: [Select]
if t == TEAM_ADMIN then
        if !self:IsAdmin() or !self:IsUserGroup("testgrouphere") then
            GAMEMODE:Notify( self, 1, 4, "You are not the proper group for this job!")
            return false
        end
end


So final code should look like this:

Code: [Select]
function meta:ChangeTeam(t, force)
       
    if t == TEAM_ADMIN then
        if !self:IsAdmin() or self:IsUserGroup("sergant") then
            umsg.Start("Problem", self)
            umsg.End()
            return false
        end
    end

(SS: http://puu.sh/1SYQa ) *My setup is more advanced, It responds back with a colorful Error =D*

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #4 on: January 26, 2013, 01:40:41 PM »
if i did this:

Code: [Select]
if t == TEAM_BUS then
        if !self:IsUserGroup("vip") or self:CheckGroup("superadmin") then
            GAMEMODE:Notify( self, 1, 4, "You must be a VIP to play as this job! Donate to become VIP!")
            umsg.Start("Problem", self)
            umsg.End()
            return false
        end
    end

Would it still work? I want it to be a vip only job but then i want it so all the groups superadmin and up get it.
« Last Edit: January 26, 2013, 03:11:22 PM by bender180 »
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #5 on: January 26, 2013, 03:22:38 PM »
never mind the last message got the effect i wanted using:

Code: [Select]
if t == TEAM_BUS then
        if !self:IsSuperAdmin() or self:IsUserGroup("vip") then
            GAMEMODE:Notify( self, 1, 4, "You must be a VIP to play as this job! Donate to become VIP!")
            return false
        end
    end

Well the superadmin and up part is working but vip is receiving the "You must be a VIP to play as this job! Donate to become VIP!"

Heres what my code looks like https://dl.dropbox.com/u/2418443/Capture.JPG
« Last Edit: January 26, 2013, 03:51:10 PM by bender180 »
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Racer

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #6 on: January 26, 2013, 07:53:09 PM »
the ulx group NEEDS to be EXACTLY like the name you made when you made the group, and the TEAM_W/E Needs to be the exact name in the shared.lua.

Other than that, It looks fine

Edit: Wait, nvm, I re-read the code, I see the issue:

This:
Code: [Select]
if !self:IsSuperAdmin() or self:IsUserGroup("vip") then
needs to be this:
Code: [Select]
if !self:IsSuperAdmin() or !self:IsUserGroup("vip") then
you didn't add the ! before self:IsUsergroup("VIP")

That ! means if NOT self:IsSuperAdmin(), Its easier to type ! than if not. xD
« Last Edit: January 26, 2013, 07:55:30 PM by Racer »

Offline Racer

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #7 on: March 06, 2013, 12:50:45 AM »
You are welcome BTW......

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #8 on: March 06, 2013, 09:25:36 AM »
You are welcome BTW......

Wow how did i forget to says thanks, sorry for the length of time that has passed but thaks for the help.
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline pazda

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #9 on: March 06, 2013, 12:05:27 PM »
hi, that's not working for me. Nobody can be the job :/

Edit: Never mind, fixed

Code: [Select]
if t == TEAM_SWORD then
        if !self:IsAdmin() and !self:IsUserGroup("donator") then
            GAMEMODE:Notify( self, 1, 4, "You must be a donator to play as this job! Donate to get it!")
            return false
        end
    end

After !self:IsAdmin(), it should be an and, not an or
« Last Edit: March 06, 2013, 12:10:07 PM by pazda »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #10 on: March 06, 2013, 02:48:56 PM »
pazda, the way you express it, your player wanting to be that job must be an admin and a donator.
It's difficult to be two groups at once, unless you're in a Ulib group where donator inherits admin (I _think_ that would work)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline pazda

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #11 on: March 06, 2013, 03:54:15 PM »
! in lua means not, so it's saying if you're not an admin and if you're not a donator then do that

If it weren't for the !s, you'd be right. It's been working fine on my server.

Offline AJ-

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #12 on: March 06, 2013, 04:59:05 PM »
If you took the time to have a look yourself, you would have found the article on the DarkRP wiki regarding custom jobs and that includes code to make it usergroup dependent

Offline pazda

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #13 on: March 07, 2013, 01:05:52 PM »
The page doesn't exist anymore.

Offline louietien

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Restrict DarkRp job class to certain ulx ranks
« Reply #14 on: December 09, 2013, 03:34:26 AM »
You can also do so that, only 1 ULX rank or FAdmin rank and or admins can use the job.
Use this code:


Code: [Select]
    customCheck = function(ply) return ply:CheckGroup("donator") or ply:IsAdmin() end,
If you're using FAdmin replace
Code: [Select]
ply:CheckGroup("donator")
with

Code: [Select]
ply:GetNWString("usergroup") == "donator" or ply:IsAdmin
Job Example:
Code: [Select]
TEAM_DONATORJOB = DarkRP.createJob("Swat", -- Name
    color = Color(238, 99, 99, 255), -- Team color
    model = "models/player/mossman.mdl", -- Player model
    description = [[As a cook, it is your responsibility to feed the other members of your city.
                            You can spawn a microwave and sell the food you make: /Buymicrowave]],  -- Job description
    weapons = {}, -- Additional weapons
    command = "Swat", -- Command to become the job
    max = 2, -- Maximum amount of said job
    salary = 45, -- Salary
    admin = 0, -- Requires Admin? 1 for yes, 0 for no.
    vote = false, -- Do they need to vote? true for yes, false for no.
    hasLicense = false, -- Has a license
    customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" or ply:IsAdmin() end, -- The extra check function. Enter nil or nothing to not have a restriction