I was thinking of restricting certain classes in DarkRP, such as hobo, and other custom classes, I tried making it, but it didn't work...the things I did were:
-Use with ulx
-Test in singleplayer and removed my access rights, didn't help...
-I put it in lua/autorun/server
Heres the code:
vipclasses = {
TEAM_HOBO,
TEAM_PGUN,
TEAM_FGUN
}
local function ChangeBackWhenNotVip( ply, oldteam, newteam )
if table.HasValue(vipclasses, newteam) and !ply:IsUserGroup("vip") and not ply:IsSuperAdmin() then
ply:ChangeTeam(TEAM_CITIZEN, true)
Notify(ply, 1, 4, string.format("That class is VIP only!"))
end
end
hook.Add("OnPlayerChangedTeam", "vipclass", ChangeBackWhenNotVip)
If someone can tell me if I did something wrong or if it only works on servers or something dumb like that...please tell me
DarkRP teams are changed differently and so OnPlayerChangedTeam hook would not be called.
[QUOTE=sintwin;22634001]DarkRP teams are changed differently and so OnPlayerChangedTeam hook would not be called.[/QUOTE]
Thanks, do you know another hook? =S
You could go into the player.lua which is where job switching is handled in DarkRP. E.G on line 231 you could put...
[lua]
if t == TEAM_HOBO or t == TEAM_PGUN or t == TEAM_FGUN
and !ply:IsUserGroup("vip") and not ply:IsSuperAdmin()
then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "This job is VIP only!"))
return
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.