Author Topic: AutoPromote  (Read 111878 times)

0 Members and 2 Guests are viewing this topic.

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
AutoPromote
« on: January 14, 2009, 07:51:18 PM »
AutoPromote is a lightweight UTime-integrated alternative to other promotion systems such as APromotion.

UTime and ULX are requred for this addon to operate.
To install, extract the AutoPromote folder to C:\Program Files\Steam\steamapps\<username>\garrysmod\garrysmod\addons\

Configuration options are at the top of AutoPromote/lua/ulx/modules/AutoPromote.lua

This addon is realeased under the MIT license, which gives you the right to use, distribute, and modify as long as you give me credit.

Version 3.1 includes a variety of bugfixes and improvements by me, Major_Pain, and Smithy.

« Last Edit: December 30, 2009, 03:28:13 PM by HOLOGRAPHICpizza »
Quote from: Jeremy S. Anderson
There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
Open SourceNet NeutralityUbuntuFirefoxSumatra PDF

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: AutoPromote
« Reply #1 on: January 14, 2009, 07:55:20 PM »
Very cool work! Interesting that you chose to build it off UTime, but it does seem like the two go hand-in-hand. :)
Experiencing God's grace one day at a time.

Offline ASpeidell

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: AutoPromote
« Reply #2 on: January 15, 2009, 06:01:44 PM »
it won't promote my users after they have passed the three hours mark, what am i doing wrong?

Quote

if not SERVER then return end

--AutoPromote 1.0
--Automaticly promotes players to different groups based on UTime.
--By HOLOGRAPHICpizza. Released under the MIT license.

local promoteGroups = {
--   Groups must be listed in decending order.
--   ["hours"] = "group",
        ["72"] = "member",
        ["48"] = "vip",
        ["24"] = "highlyrespected",
   ["12"] = "respected",
   ["6"] = "regular",
   ["3"] = "builder",
        ["0"] = "user",
}

local excludeGroups = {
   "owner",
   "admin",
   "superadmin",
}

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #3 on: January 16, 2009, 01:10:10 PM »
Make sure you have UTime and ULX installed and properly configured.
Make sure the group you want to promote to actually exists and it is possible to promote users to the group manualy.
Make sure you have completely restarted the server after installing the addon.
Make sure the user is not in an excluded group.
Remember that the script only checks hours when the player dies, and users are not promoted as soon as they hit the hour mark, they need to die first.
Try changing the config section to look like this:
Code: [Select]
local promoteGroups = {
--   Groups must be listed in decending order.
--   ["hours"] = "group",
["72"] = "member",
["48"] = "vip",
["24"] = "highlyrespected",
["12"] = "respected",
["6"] = "regular",
["3"] = "builder"
}
Note the lack of the users group and the lack of a comma after the last entry.
Also, please post any error messages you get.
« Last Edit: January 16, 2009, 02:01:00 PM by HOLOGRAPHICpizza »
Quote from: Jeremy S. Anderson
There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
Open SourceNet NeutralityUbuntuFirefoxSumatra PDF

Offline ASpeidell

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: AutoPromote
« Reply #4 on: January 17, 2009, 04:56:33 PM »
That seemed to fix it...thanks, dude

you da man
« Last Edit: January 17, 2009, 07:36:34 PM by ASpeidell »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: AutoPromote
« Reply #5 on: January 18, 2009, 08:06:54 PM »
Congrats on the release!
 
Something I'd like to see is a simple gui that shows remaining time until next promotion, and what group you will be promoted to :D

Another not, if you'd be interested, I'd like to see this script merged into APromotion as an addon that will promote with/without UTime.
Would only take me about five minutes to merge them if you are interested, you will get full credit for your work of course. I make this offer,
because you've done what I've planned on, but not had time to do.

Feelings wont be hurt if you choose not to, just trying to make things simple. One addon multiple solutions :D

EDIT:
    - You can choose name :D
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline Cephalexin

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
Re: AutoPromote
« Reply #6 on: January 27, 2009, 01:55:46 AM »
if you accepted the offer that would be cool :D

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #7 on: January 28, 2009, 12:02:05 PM »
Hey, this is why I chose an open-source license. You can go ahead and merge it into APromotion, just give me credit. I'm still going to keep AutoPromote up for people who know for sure they only want it with UTime and they want it to be as lightweight as possible, like me. But this is why I chose the MIT license. You are free to do whatever the heck you want with the code, just make sure I get credit.  :)
« Last Edit: January 28, 2009, 12:11:30 PM by HOLOGRAPHICpizza »
Quote from: Jeremy S. Anderson
There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
Open SourceNet NeutralityUbuntuFirefoxSumatra PDF

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #8 on: January 28, 2009, 08:42:12 PM »
Hey, this is why I chose an open-source license.<clip>
just give me credit.
* JamminR claps.
I've used code from others before, then basically ended up totally rewriting the code to do the same function but more efficiently.
I still put in comments 'loosely based on idea by <author>'

I love collaboration and learning from others.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline XbabyX

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: AutoPromote
« Reply #9 on: February 15, 2009, 10:16:56 AM »
Hey guys i got some problems too, i hope i can get some help here, its just not working.

Code: [Select]
if not SERVER then return end

--AutoPromote 1.0
--Automaticly promotes players to different groups based on UTime.
--By HOLOGRAPHICpizza. Released under the MIT license.

local promoteGroups = {
-- Groups must be listed in decending order.
-- ["hours"] = "group",
["100"] = "msergeant",
["50"] = "sergeant",
["25"] = "1337",
["15"] = "respected",
        ["10"] = "VIP",
["5"] = "private",
["2"] = "builder"
}

local excludeGroups = {
"member",
"moderator",
"admin",
"superadmin"
}

--DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING--

--Checks if they are ready to be promoted.
function deathCheck(ply)
if not excludeCheck(ply) then
local newGroup = promoteCheck(ply)
promote(ply, newGroup)
end
end
hook.Add( "PlayerDeath", "deathCheck", deathCheck )

--Check if they are in an excluded group.
function excludeCheck(ply)
local excluded = false

for k, v in ipairs(excludeGroups) do
if ply:IsUserGroup(v) then
excluded = true
end
end

return excluded
end

--Check what group they fall in.
function promoteCheck(ply)
local hours = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
local newGroup = "user"

for k, v in pairs(promoteGroups) do
if hours >= tonumber(k) then
newGroup = v
end
end

return newGroup
end

--Promote the player to the group.
function promote(ply, newGroup)
if not ply:IsUserGroup(newGroup) then --Make sure we don't promote them tho their current group.
game.ConsoleCommand("ulx adduser " ..string.format("%q", ply:Nick() ).. " " ..string.format("%q", newGroup).. " \n")
end
end

Is that correct?

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #10 on: February 15, 2009, 10:55:18 AM »
What specific problem are you having? The config looks good to me...

Make sure you have UTime and ULX installed and properly configured.
Make sure the group you want to promote to actually exists and it is possible to promote users to the group manualy.
Make sure you have completely restarted the server after installing the addon.
Make sure the user is not in an excluded group.
Remember that the script only checks hours when the player dies, and users are not promoted as soon as they hit the hour mark, they need to die first.
Post any error messages you encounter.
Quote from: Jeremy S. Anderson
There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
Open SourceNet NeutralityUbuntuFirefoxSumatra PDF

Offline XbabyX

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: AutoPromote
« Reply #11 on: February 15, 2009, 11:09:51 AM »
lol my fault, he didnt get promoted because he was alive. He had to die. But thanks anyway

Offline DiscoBiscuit

  • Full Member
  • ***
  • Posts: 112
  • Karma: 1
    • DiscoBuild
Re: AutoPromote
« Reply #12 on: February 22, 2009, 12:25:35 PM »
It won't promote players for my server either...
I have ULIB and ULX installed properly, and UTime, and I made each group in ULIB's groups.txt but it still won't promote them, even after death. Here's the code:


Code: [Select]
if not SERVER then return end

--AutoPromote 1.0
--Automaticly promotes players to different groups based on UTime.
--By HOLOGRAPHICpizza. Released under the MIT license.

local promoteGroups = {
-- Groups must be listed in decending order.
-- ["hours"] = "group",
["24"] = "senior"
["15"] = "legendary"
["12"] = "awesome"
["10"] = "respected"
["8"] = "1337",
["6"] = "pro",
["4"] = "builder",
["1"] = "experienced"
}

local excludeGroups = {
"moderator",
"vip",
"admin",
"superadmin"
}

--DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING--

--Checks if they are ready to be promoted.
function deathCheck(ply)
if not excludeCheck(ply) then
local newGroup = promoteCheck(ply)
promote(ply, newGroup)
end
end
hook.Add( "PlayerDeath", "deathCheck", deathCheck )

--Check if they are in an excluded group.
function excludeCheck(ply)
local excluded = false

for k, v in ipairs(excludeGroups) do
if ply:IsUserGroup(v) then
excluded = true
end
end

return excluded
end

--Check what group they fall in.
function promoteCheck(ply)
local hours = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
local newGroup = "user"

for k, v in pairs(promoteGroups) do
if hours >= tonumber(k) then
newGroup = v
end
end

return newGroup
end

--Promote the player to the group.
function promote(ply, newGroup)
if not ply:IsUserGroup(newGroup) then --Make sure we don't promote them tho their current group.
game.ConsoleCommand("ulx adduser " ..string.format("%q", ply:Nick() ).. " " ..string.format("%q", newGroup).. " \n")
end
end

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #13 on: February 22, 2009, 12:47:02 PM »
Sorry, I don't know what to tell you, the code looks good...

Make sure that you can promote users to the group manually.
Make sure you have completely restarted the server after installing the addon.
Make sure the user is not in an excluded group.
Post any error messages you encounter.
Quote from: Jeremy S. Anderson
There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
Open SourceNet NeutralityUbuntuFirefoxSumatra PDF

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #14 on: February 22, 2009, 04:39:49 PM »
Also, make sure the player has died. Suicide works, fun "slay" initiation would work too. :)
Don't know if HolographicPizza has added any other check events, but they specifically mention death in first post.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming