General > Developers Corner
Set player rank through function()
(1/1)
AustinH:
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: ---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 )
--- End code ---
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
AustinH:
Didn't know it belonged here. Sorry :/
JamminR:
Austin, the Gmod wiki has some nice functions to search.
SetUserGroup
AustinH:
Thanks bud. :)
JamminR:
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'.
Navigation
[0] Message Index
Go to full version