Author Topic: Set player rank through function()  (Read 1914 times)

0 Members and 1 Guest are viewing this topic.

Offline AustinH

  • Newbie
  • *
  • Posts: 4
  • Karma: -1
Set player rank through function()
« on: February 15, 2015, 06:28:41 AM »
Hey guys (It's not nicole. Memes...)
I have a new mod called levelup from Neth off of ScriptFodder which allows players to gain levels over time. Those levels contribute to perks. Those perks allow users to get an advantage such as faster running or 25 Armour when you spawn. I want there to be a perk that allows a player to become a "regular" User group on my server.
Here is the code for the perk.
Code: [Select]
local perk = {}
perk.name = "Good nutrition"
perk.description = "Increases health by 20 points"
perk.icon = "heart.png"
perk.level = 2
perk.passive = function( ply ) ply:SetHealth( ply:Health() + 20 ) end
levelup.config.addPerk( perk )
As you can see it does perk.passive = then a function
Is there away to set a user group with a function? If so please help me! Thank you :D

Offline AustinH

  • Newbie
  • *
  • Posts: 4
  • Karma: -1
Re: Set player rank through function()
« Reply #1 on: February 15, 2015, 06:57:41 AM »
Didn't know it belonged here. Sorry :/

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Set player rank through function()
« Reply #2 on: February 15, 2015, 06:59:00 AM »
Austin, the Gmod wiki has some nice functions to search.
SetUserGroup
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline AustinH

  • Newbie
  • *
  • Posts: 4
  • Karma: -1
Re: Set player rank through function()
« Reply #3 on: February 15, 2015, 07:01:09 AM »
Thanks bud. :)

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Set player rank through function()
« Reply #4 on: February 15, 2015, 11:04:40 AM »
Welcome.
I've no idea if you know how, but, you'll want to program in some 'checks' to make sure it's not going to 'demote' someone that's in a higher rank.
I could imagine you promoting a friend to a non 'regular' group, they join server for first time, and then when that time check kicks in, they get placed into regular.
Just one thing to watch for (as is true for any time based level system.

Also, if using ULX, make sure the time is HIGH to become regular.
Spending an hour or two on a build server is easy, and can quickly grow your users file to a size that actually slows down the server.
I'd say 24+ hours of play time at the LEAST to become anything besides 'user'.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming