Author Topic: Trouble with usergroup inheritance.  (Read 2169 times)

0 Members and 3 Guests are viewing this topic.

Offline Jakopus

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Trouble with usergroup inheritance.
« on: April 24, 2016, 06:04:06 AM »
I'm working on a DarkRP server and was trying to make a VIP/Donator usergroup for certain jobs. I tried multiple variations but everything seems to had a problems. I'm just here to ask if there is something I missed or didn't try.

I was using custom check with usergroups in order to make it so only the specific usergroup can be that job.

This is the code of the job:
Code: [Select]
TEAM_SPY = DarkRP.createJob("Spy", {
   color = Color(100, 100, 100, 255),
   model = {"models/player/legion/3e_soldier.mdl"},
   description = [[You are a spy.
Use your skills to infiltrate and steal info & supplies.]],
   weapons = {"prokeypadcracker","climb_swep2","pro_lockpick_update"},
   command = "spy",
   max = 4,
   salary = 60,
   admin = 0,
   vote = false,
   hasLicense = false,
   candemote = true,
   customCheck = function(ply) return ply:GetUserGroup("VIP") end,
   CustomCheckFailMsg = "You need to be VIP.",
   category = "Citizens",
})

So the usergroup is "VIP". When I make this usergroup through ulx menu I chose to inherit from "user"
The problem with this is that while the VIP group can become the job, so can the user. This kind of defeats the purpose.

Next I tried to inherit it from the next one up, operator. So now, the user can't become the job, and the VIP can. This is good, it would work, but now the VIP can also become jobs with ply:IsAdmin(). I would rather not have people be able to become Admin jobs who are not admins.

Any help is appreciated. I'm not the most fluent in coding.
« Last Edit: April 24, 2016, 06:08:46 AM by Jakopus »

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Trouble with usergroup inheritance.
« Reply #1 on: April 24, 2016, 06:24:29 AM »
Could you copy paste your groups.txt (garrysmod/data/ulib/groups.txt) and upload it to Pastebin and link it here? This way we can verify what your inheritance tree looks like.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Jakopus

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Trouble with usergroup inheritance.
« Reply #2 on: April 24, 2016, 07:24:41 AM »
Code: [Select]
"noaccess"
{
"allow"
{
}
"inherit_from" "user"
}
"admin"
{
"allow"
{
"darkrp_admincommands"
"darkrp_getadminweapons"
"darkrp_getjob_cp"
"darkrp_getjob_guard"
"darkrp_getjob_hoboking"
"darkrp_getjob_jug"
"darkrp_getjob_mayor"
"darkrp_getjob_pjug"
"darkrp_getjob_police"
"darkrp_getjob_psniper"
"darkrp_getjob_riotcontrol"
"darkrp_getjob_spy"
"darkrp_seeevents"
"darkrp_setdoorowner"
"fpp_cleanup"
"fspectate"
"fspectateteleport"
"ulx armor"
"ulx ban"
"ulx blind"
"ulx bring"
"ulx chattime"
"ulx cloak"
"ulx csay"
"ulx freeze"
"ulx gag"
"ulx gimp"
"ulx god"
"ulx goto"
"ulx hp"
"ulx ignite"
"ulx jail"
"ulx jailtp"
"ulx kick"
"ulx kickafternamechanges"
"ulx kickafternamechangescooldown"
"ulx kickafternamechangeswarning"
"ulx map"
"ulx mechatenabled"
"ulx motdfile"
"ulx motdurl"
"ulx mute"
"ulx noclip"
"ulx physgunplayer"
"ulx playsound"
"ulx ragdoll"
"ulx reservedslots"
"ulx return"
"ulx rslots"
"ulx rslotsmode"
"ulx rslotsvisible"
"ulx seeanonymousechoes"
"ulx send"
"ulx showmotd"
"ulx slap"
"ulx slay"
"ulx spawnecho"
"ulx spectate"
"ulx sslay"
"ulx strip"
"ulx teleport"
"ulx tsay"
"ulx unban"
"ulx unblind"
"ulx uncloak"
"ulx unfreeze"
"ulx ungag"
"ulx ungimp"
"ulx ungod"
"ulx unignite"
"ulx unigniteall"
"ulx unjail"
"ulx unmute"
"ulx unragdoll"
"ulx veto"
"ulx vote"
"ulx voteban"
"ulx votebanminvotes"
"ulx votebansuccessratio"
"ulx votekick"
"ulx votekickminvotes"
"ulx votekicksuccessratio"
"ulx votemap2"
"ulx votemap2minvotes"
"ulx votemap2successratio"
"ulx votemapenabled"
"ulx votemapmapmode"
"ulx votemapmintime"
"ulx votemapminvotes"
"ulx votemapsuccessratio"
"ulx votemapvetotime"
"ulx votemapwaittime"
"ulx welcomemessage"
"ulx whip"
}
"can_target" "!%superadmin"
"inherit_from" "operator"
}
"user"
{
"allow"
{
"ulx asay"
"ulx help"
"ulx motd"
"ulx psay"
"ulx thetime"
"ulx usermanagementhelp"
"ulx version"
"ulx votemap"
"ulx who"
}
}
"operator"
{
"allow"
{
"ulx seeasay"
}
"can_target" "!%admin"
"inherit_from" "user"
}
"VIP"
{
"allow"
{
}
"inherit_from" "user"
}
"superadmin"
{
"allow"
{
"darkrp_changedoorsettings"
"darkrp_setlicense"
"darkrp_setmoney"
"fpp_settings"
"ulx addgroup"
"ulx adduser"
"ulx adduserid"
"ulx banid"
"ulx cexec"
"ulx ent"
"ulx exec"
"ulx groupallow"
"ulx groupdeny"
"ulx hiddenecho"
"ulx logchat"
"ulx logdir"
"ulx logecho"
"ulx logechocolorconsole"
"ulx logechocolordefault"
"ulx logechocoloreveryone"
"ulx logechocolormisc"
"ulx logechocolorplayer"
"ulx logechocolorplayerasgroup"
"ulx logechocolors"
"ulx logechocolorself"
"ulx logevents"
"ulx logfile"
"ulx logjoinleaveecho"
"ulx logspawns"
"ulx logspawnsecho"
"ulx luarun"
"ulx maul"
"ulx rcon"
"ulx removegroup"
"ulx removeuser"
"ulx removeuserid"
"ulx renamegroup"
"ulx setgroupcantarget"
"ulx stopvote"
"ulx userallow"
"ulx userallowid"
"ulx userdeny"
"ulx userdenyid"
"ulx voteecho"
"xgui_gmsettings"
"xgui_managebans"
"xgui_managegroups"
"xgui_svsettings"
}
"inherit_from" "admin"
}

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Trouble with usergroup inheritance.
« Reply #3 on: April 24, 2016, 08:52:07 AM »
Code: [Select]
return ply:GetUserGroup("VIP")
There's your issue.
Player:GetUserGroup() returns a string containing the player's user group. Lua treats all strings as "true", so your custom check will pass every time.
Player:IsUserGroup(string groupname) is probably what you wanted, which returns "true" if the player is a member of the given group.
bw81@ulysses-forums ~ % whoami
Homepage