How to Make Jobs Donator Only?

How would I go about making certain jobs donator only? It is the last that needs to be done for my server and would really appreciate some help. I am using DarkRP of course.

DarkRP has a player change team hook, if you goto that function you can add a part to check if the player has a different usergroup and if so allow, else dont allow.

How are you checking if the player has VIP?

IsUserGroup?

Shit double post

Abit hacky, but it should work. It basicly checks if a guy has switched his team to team donator, if he has, but he ain’t a donator, then don’t allow him, and change his job back.
[lua]

function GM:OnPlayerChangedTeam(ply, OldTeam, NewTeam)
if NewTeam == TEAM_DONATORONLY then
if not ply:IsUserGroup(“Donator”) then
ply:ChangeTeam(OldTeam, true)
end
end
end
[/lua]

[lua]
function GM:OnPlayerChangedTeam(ply, OldTeam, NewTeam)
if NewTeam == TEAM_VIP or TEAM_VIP2 then
if !ply:IsUserGroup(“VIP”) then
return false
end
end
end
[/lua]
This should work.

So you took Donkies code and changed abit of it?

Put this is meta:ChangeTeam() in player.lua:
[lua]
vipteams = {TEAM_HOBO}
if table.HasValue( vipteams, t ) and !force and !self:IsUserGroup(“vip”) and !self:IsSuperAdmin() then
Notify(self, 1, 4, string.format(“That class is VIP only! To become a vip class, ask an admin about donations.”))
return
end
[/lua]

[editline]3rd March 2011[/editline]

I couldn’t make it work using this hook

[editline]3rd March 2011[/editline]

No, he made it so that you wouldn’t change teams, instead, nothing would happen, theoretically, I couldn’t make it work this way, like I said before

EDIT: This works well with ULX’s usergroups

Use andriko’s code, the rest won’t work. It’s at around line 200 in player.lua btw.

Hate to bump this but where in meta:ChangeTeam()…cause i put it in and around there and it didnt work.

Post the function please.

Sorry to bump but it seems at least 2 people were confused reading this… so here is a complete step by step guide…

  1. Go to your DarkRP gamemodes folder, most likely “(gmodroot)/gamemodes/DarkRP/gamemode/”
  2. Open up player.lua
  3. Press Ctrl+F, this should open up a window that lets you search for text, search for “changeteam” without the brackets
  4. It should lead you to a function named meta:ChangeTeam(), the line it is on looks like this:
    [lua]function meta:ChangeTeam(t, force)[/lua]
  5. Under that line, put this in and follow the comments on what to customize:
    [lua]
    vipteams = {TEAM_HOBO, TEAM_CP} //Put the teams that you want to be restricted to a specific user group in this table like I did
    if table.HasValue( vipteams, t ) and !force and !self:IsUserGroup(“vip”) and !self:IsSuperAdmin() then //Change THISHERE where it says !self:IsUserGroup(“THISHERE”) to the name of the usergroup you want to restrict the jobs to, I kept it in the actual code as vip because… people like vip I dunno
    Notify(self, 1, 4, string.format(“That class is VIP only! To become a vip class, ask an admin about donations.”)) // You can change the message inside those quotes (“the stuff in between these brackets and text are called quotes”)
    return //Please don’t touch this unless you know what you’re doing
    end // Or this
    [/lua]
  6. ???
  7. PROFIT!

Ok… guys, after this I do hope that I’m not getting any more pm’s about this

Sorry for the bump, but I was asked

EDIT: gustavgr you gotta be shitting me, ok this guy has to have a dumb rating bot… that has to be bannable