ULX

Author Topic: AutoPromote  (Read 106032 times)

0 Members and 4 Guests are viewing this topic.

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #45 on: November 20, 2009, 08:41:42 PM »
Ok, I'm gonna do some testing and fix whatever is necessary and release a 1.1. MajorPain's looks like a complete rewrite with none of my code, but it has the same name...
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 #46 on: November 20, 2009, 08:50:52 PM »
Ah, ok. I'd not compared.
Make sure you're aware of the new command structure being used in SVN now.
Adduser hasn't changed too much, but it no longer allows immunity like the old (0/1) method.
I don't know if you did that automatically in any way in v1. See the SVN area of the forums. There's a sticky for how immunity is handled now.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline smithy

  • Newbie
  • *
  • Posts: 7
  • Karma: 1
Re: AutoPromote
« Reply #47 on: December 27, 2009, 10:00:56 PM »
I'm not sure if this was actually broken or not from the posts(I didn't test Major_pains), but I optimised some of the code and added a chat announcement when people get promoted. I made this I wanted a version I know works and something that was exactly what i want.
Instructions:
As before in previous versions, pretty simple configuration - but its a bit different in this version.
Default settings:
Quote
Pretty self explanatory. Hours are when the promotion will take place. Group is the usergroup it will promote to. Name is what will be printed in chat when it says PLAYER has been promoted to name.
promotes = {
      { hours = 1, group = "player", name = "Player" },
      { hours = 2, group = "regular", name = "Regular" },
      { hours = 5, group = "respected", name = "Respected" },
      { hours = 10, group = "highrespected", name = "Highly Respected" },
      { hours = 25, group = "silverplayer", name = "Silver Player" },
      { hours = 50, group = "goldplayer", name = "Gold Player" }
}
Excludes work the same as previous versions, but are layed out differently.
excludes = { "donator", "moderator", "admin", "superadmin" }
Change msgOn to false if you want chat announcements disabled.
Change the below to change the color of the chat announcements.(Default is yellow)
Change effOn to false if you want effects/sound disabled.
settings = {
    { msgOn = true, msgcol = Color(255,225,0), effOn = true }
}

EDIT: Also, first post for me. xD
EDIT#2: Removed the links, download 3.1 in HOLO's post.
« Last Edit: December 30, 2009, 02:53:15 PM by smithy »

Offline smithy

  • Newbie
  • *
  • Posts: 7
  • Karma: 1
Re: AutoPromote
« Reply #48 on: December 28, 2009, 08:14:44 PM »
Edited my last post with newer version, this is kinda a bump post. Anyway new stuff includes:
*Almost entirely recoded, simplified/optimised - can add as many groups as you like now, instead of Major_pains 10 alotted ones
*Chat announcement "Player has been promoted to 'Group name'." - Can disable if you don't like it, or change color of it.
*Effects and sound, when a player is promoted confetti appears and a sound is played. - Can disable if you don't like it.
*Easier configuration
*Works with SVN version of ULX
*Added awesomeness

If anyone can think of anything that would be good to include to AutoPromote I will gladly add it for you(granted its not too much hassle), also I will tell HOLOGRAPHICpizza that i posted here as he frequents a community I am in.
« Last Edit: December 28, 2009, 11:32:39 PM by smithy »

Offline Ploo

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
AutoPromote
« Reply #49 on: December 30, 2009, 12:04:45 PM »
I am using HoloGraphic Pizza's AutoPromote but having a problem.

Code: [Select]
local promoteGroups = {
-- Groups must be listed in decending order.
-- ["hours"] = "group",
["100"] = "platinum",
["50"] = "gold",
["20"] = "silver",
["5"] = "bronze",
["2"] = "member"
}

local excludeGroups = {
"dj",
"donator",
"mod",
"admin",
"superadmin"
}

It will promote up until bronze, but it fails to promote to silver (yes, past 20h). If I manually promote to silver it will demote to bronze. Yay.

Anyone know why? I'm certain my syntax is correct.

Offline HOLOGRAPHICpizza

  • Newbie
  • *
  • Posts: 9
  • Karma: 4
    • GmodPlanet.com
Re: AutoPromote
« Reply #50 on: December 30, 2009, 02:35:40 PM »
I made a few changes to Smithy's version and uploaded it to garrymod.org and updated the post.

v3.1 Changelog:
  • Now loads as a ULX module.
  • Calls ULX promote function directly, instead of through a console command.

Thanks Major_Pain and Smithy!

« Last Edit: December 30, 2009, 03:28:37 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 Ploo

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: AutoPromote
« Reply #51 on: December 30, 2009, 03:49:06 PM »
So wait, this is the new version, and I should disregard my problem and download this?

A new version released the very day I need it, how perfect. :D

Does not seem to work, the old one worked some-what... :S

Code: [Select]
if not SERVER then return end

--AutoPromote 2.0
--Automaticly promotes players to different groups based on UTime.

--[[
CREDIT FOR THIS VERSION OF AUTOPROMOTE GOES TO:
HOLOGRAPHICpizza
Major_Pain
Smithy
PRETTY SELF EXLANATORY
HOURS  IS THE POINT OF WHERE THE PLAYER WILL GET PROMOTED TO THE GROUP
NAME IS THE NAME THAT WILL GET DISPLAYED WHEN SOMEONE GETS PROMOTED
]]
promotes = {
{ hours = 2, group = "member", name = "Member" },
{ hours = 5, group = "bronze", name = "Bronze Member" },
{ hours = 20, group = "silver", name = "Silver Member" },
{ hours = 50, group = "gold", name = "Gold Member" },
{ hours = 100, group = "platinum", name = "Platinum Member" }
}

---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "dj", "donator", "mod", "admin", "superadmin" }

---------Chat announcement settings, msgOn  - if true then it will announce promotions(false if you want it disabled), msgcol - color of the chat announcements
settings = {
{ msgOn = true, msgcol = Color(255,225,0), effOn = true }
}

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------- DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING---------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
if settings[1].effOn then
resource.AddFile( "sound/autopromote/promote.wav" )
end

local cID = 1

function checkExcludes( ply )
for id, eX in pairs (excludes) do
if not ply:IsUserGroup(excludes[id]) then
exclude = false
else
exclude = true
end
end
return exclude
end

function groupSet( ply )
local plhrs = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
while plhrs >= promotes[cID].hours and cID < table.Count(promotes) do
cID = cID + 1
groupTS = promotes[cID-1].group
end
if cID == table.Count(promotes) then
groupTS = promotes[table.Count(promotes)].group
return true
else
if cID <= 2 then
if plhrs >= promotes[1].hours then
return true
end
else
if plhrs >= promotes[cID-1].hours then
return true
end
end
end
return false
end

function promotePlayer( ply )
if not checkExcludes( ply ) then
cID = 1
if  groupSet( ply ) and not ply:IsUserGroup(groupTS) then
if settings[1].msgOn then
for ud, blank in pairs( player.GetAll()) do
if cID == table.Count(promotes) then
cID = table.Count(promotes) + 1
return true
else
ULib.tsayColor(player.GetAll()[ud],false,settings[1].msgcol,ply:Nick().." has been promoted to '"..promotes[cID-1].name.."'.")
end
end
cID = 1
if settings[1].effOn then
effectS( ply )
WorldSound( "autopromote/promote.wav", ply:GetPos( 0, 0, 0 ), 160, 100 )
end
ulx.adduser(nil, ply, groupTS)
--game.ConsoleCommand("ulx adduser "..string.format("%q", ply:Nick() ).." "..groupTS.."\n")
end
end
if not timer.IsTimer("Promotion-" ..tostring(ply:SteamID())) then
timer.Create("Promotion-" ..tostring(ply:SteamID()), 10, 0, promotePlayer, ply)
end
end

function effectS( ply )
local ed = EffectData()
ed:SetEntity(ply)
util.Effect("autopromotion",ed, true, true)
local vPoint = ply:GetPos()
local effectdata = EffectData()
local r = math.random(20, 255)
local g = math.random(20, 255)
local b = math.random(20, 255)
effectdata:SetStart( Vector( r, g, b ) )
effectdata:SetOrigin( vPoint )
effectdata:SetScale( 1 )
util.Effect( "autopromotion2", effectdata )
timer.Simple( 1, function()
r = math.random(20, 255)
g = math.random(20, 255)
b = math.random(20, 255)
effectdata:SetStart( Vector( r, g, b ) )
local vPoint = ply:GetPos()
effectdata:SetOrigin( vPoint )
util.Effect( "autopromotion2", effectdata )
end)
timer.Simple( 2, function()
r = math.random(20, 255)
g = math.random(20, 255)
b = math.random(20, 255)
effectdata:SetStart( Vector( r, g, b ) )
local vPoint = ply:GetPos()
effectdata:SetOrigin( vPoint )
util.Effect( "autopromotion2", effectdata )
end)
timer.Simple( 3, function()
r = math.random(20, 255)
g = math.random(20, 255)
b = math.random(20, 255)
effectdata:SetStart( Vector( r, g, b ) )
local vPoint = ply:GetPos()
effectdata:SetOrigin( vPoint )
util.Effect( "autopromotion2", effectdata )
end)
timer.Simple( 4, function()
r = math.random(20, 255)
g = math.random(20, 255)
b = math.random(20, 255)
effectdata:SetStart( Vector( r, g, b ) )
local vPoint = ply:GetPos()
effectdata:SetOrigin( vPoint )
util.Effect( "autopromotion2", effectdata )
end)

end

function timerStart( ply )
timer.Create("Promotion-" ..tostring(ply:SteamID()), 10, 0, promotePlayer, ply)
end
hook.Add( "PlayerInitialSpawn", "timerstarting", timerStart)

function destroyTimers(ply)
if timer.IsTimer("Promotion-" ..tostring(ply:SteamID())) then
timer.Stop("Promotion-" ..tostring(ply:SteamID()))
timer.Destroy("Promotion-" ..tostring(ply:SteamID()))
end
end
hook.Add( "PlayerDisconnected", "PromotionCleanUP", destroyTimers )
« Last Edit: December 30, 2009, 05:01:43 PM by Ploo »

Offline smithy

  • Newbie
  • *
  • Posts: 7
  • Karma: 1
Re: AutoPromote
« Reply #52 on: December 30, 2009, 06:18:10 PM »
Add me on steam Ploo and I'll try and help you. :)
« Last Edit: May 30, 2011, 02:09:29 PM by smithy »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #53 on: December 30, 2009, 08:32:50 PM »
Smithy released a version of his own within holographic pizza's.
Prob should have made his own release - Smithy's Autopromote or something similar.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline smithy

  • Newbie
  • *
  • Posts: 7
  • Karma: 1
Re: AutoPromote
« Reply #54 on: December 30, 2009, 09:01:56 PM »
It's not a new script though, its based from HOLO's.
Version 3.1 that HOLO released is just my v3 version in modular form, with slight fixes. We worked together on 3.1.
There is no need for a new thread for the same addon, am I right?
Anyway Ploo if you are still having problems add me on steam, like I said it has been tested and works fine - so its probably misconfiguration somewhere.

Offline Ploo

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: AutoPromote
« Reply #55 on: December 31, 2009, 03:34:12 AM »
Added you.

Offline smithy

  • Newbie
  • *
  • Posts: 7
  • Karma: 1
Re: AutoPromote
« Reply #56 on: January 03, 2010, 10:19:14 PM »
I realised a major flaw in my code so here is 3.2. I will ask HOLO to reupload to garrysmod.org, but for now here is a temp mirror.

DOWNLOAD

Version 3.2 changes:
*Fixed the exclude group code, it was only excluding the last group in the excludes table. - Fixed in V3.2
« Last Edit: January 03, 2010, 10:21:42 PM by smithy »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: AutoPromote
« Reply #57 on: January 04, 2010, 01:30:39 AM »
Code: [Select]
*Fixed the exclude group code, it was only excluding the last group in the excludes table. - Fixed in V3.2     - Nice find! :)
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 TweaK

  • Jr. Member
  • **
  • Posts: 80
  • Karma: 14
    • Garry's Mod Engineers
Re: AutoPromote
« Reply #58 on: January 08, 2010, 01:32:34 AM »
So I am trying to get this thing to work... first here is what i have for a config:
Code: [Select]
promotes = {
{ hours = 2, group = "player", name = "Player" },
{ hours = 10, group = "regular", name = "Regular" },
{ hours = 25, group = "pro", name = "Pro" },
{ hours = 45, group = "vip", name = "VIP" },
{ hours = 75, group = "respected", name = "Respected" }
}

---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "respected", "admin", "admin2", "superadmin" }
and what is happening is it will promote to player, regular, pro...but when a player hits 45 hours it jumps to respected and skips vip... or whatever the second to last group defined is in any case...
any ideas? ??? or am i just crazy

edit: i dont think having respected in the excludes makes a difference but im not 100% on that


Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: AutoPromote
« Reply #59 on: March 06, 2010, 06:23:34 AM »
I have the same problem as TweaK..