ULX

Author Topic: AutoPromote  (Read 106015 times)

0 Members and 1 Guest are viewing this topic.

Offline Botman

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: AutoPromote
« Reply #120 on: January 02, 2011, 07:37:01 PM »
I got it to work now. However, now it doesn't take notice of my excludes at all and keeps promoting them all the time.

Help.

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 = 1, group = "player", name = "Player" },
{ hours = 5, group = "regular", name = "Regular" },
{ hours = 16, group = "respected", name = "Respected" },
{ hours = 25, group = "dedicated", name = "Dedicated" },
{ hours = 90, group = "silver_member", name = "Silver Member" },
{ hours = 130, group = "gold_member", name = "Gold Member" }
}

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

---------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
            end
else
exclude = true
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

return false
end
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
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 )

Offline sweetone

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 2
Re: AutoPromote
« Reply #121 on: January 03, 2011, 06:34:01 AM »
Could you tell what modifications you actually made there? Or how you got it work, mine isnt even working!

BUT! Might the problem be that your first group is "player" it's not the default "user" group and your autopromote don't know which group to start on and it just keep promoting?

Thats how I have it:
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 = 1, group = "user", name = "Guest" },
{ hours = 2, group = "player", name = "Player" },
{ hours = 3, group = "silverplayer", name = "Silverplayer" },
{ hours = 10, group = "goldplayer", name = "Goldplayer" },
{ hours = 15, group = "platinaplayer", name = "Platinaplayer" },
{ hours = 20, group = "member", name = "Member" },
{ hours = 25, group = "silvermember", name = "Silvermember" },
{ hours = 30, group = "goldmember", name = "Goldmember" },
{ hours = 35, group = "platinamember", name = "Platinamember" },
{ hours = 40, group = "", name = "" },
{ hours = 45, group = "bitcher", name = "Bitcher" },
{ hours = 50, group = "bitchest", name = "Bichest" },
{ hours = 75, group = "halfrespected", name = "HalfRespected" },
{ hours = 100, group = "respected", name = "Respected" }
}

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

---------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 )

and that's how I set the groups:
Code: [Select]
"silverplayer"
{
"team"
{
"health" 300
"color_red" 86
"index" 27
"order" 7
"name" "Silverplayer"
"color_blue" 89
"color_green" 86
}
"allow"
{
}
"inherit_from" "player"
}
"bitcher"
{
"team"
{
"health" 1100
"color_red" 247
"index" 35
"order" 15
"name" "Bitcher"
"color_blue" 13
"color_green" 13
}
"allow"
{
}
"inherit_from" ""
}
"goldmember"
{
"team"
{
"health" 800
"color_red" 147
"index" 32
"order" 12
"name" "Goldmember"
"color_blue" 5
"color_green" 113
}
"allow"
{
}
"inherit_from" "silvermember"
}
"bitchest"
{
"team"
{
"health" 1200
"color_red" 249
"index" 36
"order" 16
"name" "Bitchest"
"color_blue" 13
"color_green" 37
}
"allow"
{
}
"inherit_from" "user"
}
"halfrespected"
{
"team"
{
"health" 1250
"color_red" 7
"index" 37
"order" 17
"name" "Halfrespected"
"color_blue" 211
"color_green" 126
}
"allow"
{
}
"inherit_from" "bitcher"
}
"superadmin"
{
"team"
{
"index" 22
"runSpeed" 600
"order" 2
"color_blue" 10
"name" "Superadmin"
"health" 5000
"color_red" 4
"walkSpeed" 400
"color_green" 178
}
"allow"
{
"ulx adduser"
"ulx adduserid"
"ulx blind"
"ulx cloak"
"ulx god"
"ulx hiddenecho"
"ulx logchat"
"ulx logdir"
"ulx logecho"
"ulx logevents"
"ulx logfile"
"ulx logspawns"
"ulx logspawnsecho"
"ulx maul"
"ulx removeuser"
"ulx removeuserid"
"ulx setgroupcantarget"
"ulx userallow"
"ulx userallowid"
"ulx userdeny"
"ulx userdenyid"
"ulx voteecho"
"xgui_gmsettings"
"xgui_managebans"
"xgui_svsettings"
}
"inherit_from" "admin"
}
"user"
{
"team"
{
"color_red" 6
"index" 26
"order" 6
"name" "Guest"
"color_blue" 244
"color_green" 18
}
"allow"
{
"ulx asay"
"ulx clientmenu"
"ulx help"
"ulx menu"
"ulx motd"
"ulx psay"
"ulx thetime"
"ulx usermanagementhelp"
"ulx votemap"
"ulx who"
}
}
"platinamember"
{
"team"
{
"health" 900
"color_red" 166
"index" 33
"order" 13
"name" "Platinamember"
"color_blue" 219
"color_green" 234
}
"allow"
{
}
"inherit_from" "goldmember"
}
""
{
"team"
{
"health" 1000
"color_red" 249
"index" 34
"order" 14
"name" ""
"color_blue" 20
"color_green" 20
}
"allow"
{
}
"inherit_from" "platinamember"
}
"platinaplayer"
{
"team"
{
"health" 500
"color_red" 166
"index" 29
"order" 9
"name" "Platinaplayer"
"color_blue" 219
"color_green" 234
}
"allow"
{
}
"inherit_from" "goldplayer"
}
"silvermember"
{
"team"
{
"health" 700
"color_red" 166
"index" 31
"order" 11
"name" "Silvermember"
"color_blue" 219
"color_green" 234
}
"allow"
{
}
"inherit_from" "member"
}
"player"
{
"team"
{
"health" 200
"color_red" 51
"name" "Player"
"order" 5
"index" 25
"color_blue" 186
"color_green" 6
}
"allow"
{
}
"inherit_from" "user"
}
"admin"
{
"can_target" "!%superadmin"
"team"
{
"health" 3000
"color_red" 153
"name" "Admin"
"order" 3
"index" 23
"color_blue" 244
"color_green" 8
}
"allow"
{
"ulx adminmenu"
"ulx ban"
"ulx banid"
"ulx banmenu"
"ulx bring"
"ulx chattime"
"ulx csay"
"ulx freeze"
"ulx gag"
"ulx gimp"
"ulx goto"
"ulx ignite"
"ulx jail"
"ulx kick"
"ulx map"
"ulx mapsmenu"
"ulx mute"
"ulx noclip"
"ulx physgunplayer"
"ulx playsound"
"ulx ragdoll"
"ulx resetspawn"
"ulx rslots"
"ulx rslotsmode"
"ulx rslotsvisible"
"ulx send"
"ulx setspawn"
"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 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"
"urestrict allowspawn"
"urestrict denyspawn"
"urestrict npcs"
"urestrict props"
"urestrict ragdolls"
"urestrict sents"
"urestrict vehicles"
"xgui_managebans"
}
"inherit_from" "operator"
}
"goldplayer"
{
"team"
{
"health" 400
"color_red" 163
"index" 28
"order" 8
"name" "Goldplayer"
"color_blue" 5
"color_green" 105
}
"allow"
{
}
"inherit_from" "silverplayer"
}
"respected"
{
"team"
{
"health" 1337
"color_red" 12
"name" "Respected"
"order" 4
"index" 24
"color_blue" 255
"color_green" 242
}
"allow"
{
"ulx csay"
"ulx gag"
"ulx gimp"
"ulx mute"
"ulx tsay"
"ulx ungag"
"ulx ungimp"
"ulx unmute"
"ulx votekick"
}
"inherit_from" "user"
}
"member"
{
"team"
{
"health" 600
"color_red" 166
"index" 30
"order" 10
"name" "Member"
"color_blue" 219
"color_green" 234
}
"allow"
{
}
"inherit_from" "platinaplayer"
}
"operator"
{
"can_target" "!%admin"
"allow"
{
"ulx seeasay"
}
"inherit_from" "user"
}
"owner"
{
"team"
{
"index" 21
"runSpeed" 5000
"order" 1
"color_blue" 169
"color_red" 247
"health" 10000
"name" "Owner"
"jumpPower" 552
"walkSpeed" 680
"color_green" 13
}
"allow"
{
"ulx addgroup"
"ulx adduser"
"ulx adduserid"
"ulx adminmenu"
"ulx armor"
"ulx ban"
"ulx banid"
"ulx banmenu"
"ulx blind"
"ulx bring"
"ulx cexec"
"ulx chattime"
"ulx cloak"
"ulx csay"
"ulx ent"
"ulx exec"
"ulx freeze"
"ulx gag"
"ulx gimp"
"ulx god"
"ulx goto"
"ulx groupallow"
"ulx groupdeny"
"ulx hiddenecho"
"ulx hp"
"ulx ignite"
"ulx jail"
"ulx kick"
"ulx logchat"
"ulx logdir"
"ulx logecho"
"ulx logevents"
"ulx logfile"
"ulx logspawns"
"ulx logspawnsecho"
"ulx luarun"
"ulx map"
"ulx mapsmenu"
"ulx maul"
"ulx mute"
"ulx noclip"
"ulx physgunplayer"
"ulx playsound"
"ulx ragdoll"
"ulx rcon"
"ulx removegroup"
"ulx removeuser"
"ulx removeuserid"
"ulx renamegroup"
"ulx reservedslots"
"ulx resetspawn"
"ulx rslots"
"ulx rslotsmode"
"ulx rslotsvisible"
"ulx seeasay"
"ulx send"
"ulx setgroupcantarget"
"ulx setspawn"
"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 userallow"
"ulx userallowid"
"ulx userdeny"
"ulx userdenyid"
"ulx veto"
"ulx vote"
"ulx voteban"
"ulx votebanminvotes"
"ulx votebansuccessratio"
"ulx voteecho"
"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"
"urestrict allowspawn"
"urestrict denyspawn"
"urestrict npcs"
"urestrict props"
"urestrict ragdolls"
"urestrict sents"
"urestrict vehicles"
"xgui_gmsettings"
"xgui_managebans"
"xgui_managegroups"
"xgui_svsettings"
}
"inherit_from" "superadmin"
}
« Last Edit: January 03, 2011, 06:43:17 AM by sweetone »

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #122 on: January 03, 2011, 10:11:58 AM »
Try these.  If they don't work, I don't know what is going wrong.

@sweetone
Code: [Select]
if not SERVER then return end

--[[
CREDIT FOR THIS VERSION OF AUTOPROMOTE GOES TO:
HOLOGRAPHICpizza
Major_Pain
Smithy
Jay209015
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 = "player", name = "Player" },
{ hours = 3, group = "silverplayer", name = "Silverplayer" },
{ hours = 10, group = "goldplayer", name = "Goldplayer" },
{ hours = 15, group = "platinaplayer", name = "Platinaplayer" },
{ hours = 20, group = "member", name = "Member" },
{ hours = 25, group = "silvermember", name = "Silvermember" },
{ hours = 30, group = "goldmember", name = "Goldmember" },
{ hours = 35, group = "platinamember", name = "Platinamember" },
{ hours = 45, group = "bitcher", name = "Bitcher" },
{ hours = 50, group = "bitchest", name = "Bichest" },
{ hours = 75, group = "halfrespected", name = "HalfRespected" },
{ hours = 100, group = "respected", name = "Respected" }
}
---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "admin", "superadmin", "owner"}

---------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



function checkExcludes( ply )
   for id, eX in pairs (excludes) do
      if ply:IsUserGroup(eX) then
         return true
      end
   end
   return false
end

function hoursToPromote( group )
   for id,_ in ipairs( promotes ) do
      if group == promotes[id]["group"] then
         return promotes[id]["hours"]
      end
   end
end

function getPromoteName( group )
   for id,_ in ipairs( promotes ) do
      if group == promotes[id]["group"] then
         return promotes[id]["name"]
      end
   end
end
function groupSet( ply )
   ply.plhrs = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
   ply.promote = promotes[1]["group"]
   for id,_ in ipairs(promotes) do
      if ply:IsUserGroup(promotes[id]["group"]) and id < table.Count(promotes) then
         ply.promote = promotes[id + 1]["group"]
      end
   end
   if not(ply:IsUserGroup(ply.promote)) and (ply.plhrs >= hoursToPromote( ply.promote )) then
      return true
   end
   return false
end

function promotePlayer( ply )
   if not checkExcludes( ply ) then
      if  groupSet( ply ) then
         if settings[1].msgOn then
            for ud, blank in pairs( player.GetAll()) do
               ULib.tsayColor(player.GetAll()[ud],false,settings[1].msgcol,ply:Nick().." has been promoted to '"..getPromoteName(ply.promote).."'.")
            end
         end
         if settings[1].effOn then
            effectS( ply )
            WorldSound( "autopromote/promote.wav", ply:GetPos( 0, 0, 0 ), 160, 100 )
         end
         ulx.adduser(nil, ply, ply.promote)
      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 )

@botman
Code: [Select]
if not SERVER then return end

--[[
CREDIT FOR THIS VERSION OF AUTOPROMOTE GOES TO:
HOLOGRAPHICpizza
Major_Pain
Smithy
Jay209015
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 = 1, group = "player", name = "Player" },
{ hours = 5, group = "regular", name = "Regular" },
{ hours = 16, group = "respected", name = "Respected" },
{ hours = 25, group = "dedicated", name = "Dedicated" },
{ hours = 90, group = "silver_member", name = "Silver Member" },
{ hours = 130, group = "gold_member", name = "Gold Member" }
}
---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "donator", "moderator", "administrator", "superadmin", "god", "admin", "privileged" }

---------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



function checkExcludes( ply )
   for id, eX in pairs (excludes) do
      if ply:IsUserGroup(eX) then
         return true
      end
   end
   return false
end

function hoursToPromote( group )
   for id,_ in ipairs( promotes ) do
      if group == promotes[id]["group"] then
         return promotes[id]["hours"]
      end
   end
end

function getPromoteName( group )
   for id,_ in ipairs( promotes ) do
      if group == promotes[id]["group"] then
         return promotes[id]["name"]
      end
   end
end
function groupSet( ply )
   ply.plhrs = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
   ply.promote = promotes[1]["group"]
   for id,_ in ipairs(promotes) do
      if ply:IsUserGroup(promotes[id]["group"]) and id < table.Count(promotes) then
         ply.promote = promotes[id + 1]["group"]
      end
   end
   if not(ply:IsUserGroup(ply.promote)) and (ply.plhrs >= hoursToPromote( ply.promote )) then
      return true
   end
   return false
end

function promotePlayer( ply )
   if not checkExcludes( ply ) then
      if  groupSet( ply ) then
         if settings[1].msgOn then
            for ud, blank in pairs( player.GetAll()) do
               ULib.tsayColor(player.GetAll()[ud],false,settings[1].msgcol,ply:Nick().." has been promoted to '"..getPromoteName(ply.promote).."'.")
            end
         end
         if settings[1].effOn then
            effectS( ply )
            WorldSound( "autopromote/promote.wav", ply:GetPos( 0, 0, 0 ), 160, 100 )
         end
         ulx.adduser(nil, ply, ply.promote)
      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 )

Offline sweetone

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 2
Re: AutoPromote
« Reply #123 on: January 03, 2011, 01:53:58 PM »
Thank you very much. :) it works!

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #124 on: January 03, 2011, 01:55:52 PM »
No problem.

Offline Botman

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: AutoPromote
« Reply #125 on: January 07, 2011, 02:51:29 PM »
Yes, that seems to help, thank you. I did not test your piece of code before now as I made my own fix earlier.

Offline emilhem

  • Newbie
  • *
  • Posts: 21
  • Karma: 3
Re: AutoPromote
« Reply #126 on: December 23, 2012, 12:37:46 PM »
Updated AutoPromote for GMod 13!

Tell me if there's any bugs if you end up using it!

EDIT

Forgot to remove a debug print on line 80.
I'll just leave it there.
« Last Edit: December 23, 2012, 12:46:48 PM by emilhem »

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: AutoPromote
« Reply #127 on: December 29, 2012, 10:21:45 AM »
Thanks for the 13 version  8)
My TTT server. Join the fun!

Offline Ozhar

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: AutoPromote
« Reply #128 on: January 25, 2013, 01:09:47 PM »
for some reason it stop auto promoting people how can i fix that?

Offline naBs

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: AutoPromote
« Reply #129 on: January 30, 2013, 02:47:12 PM »
for some reason it stop auto promoting people how can i fix that?

Mines also decided to just quit on me, was working fine not too long ago. Any ideas?

Offline blureh

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: AutoPromote
« Reply #130 on: February 06, 2013, 03:16:14 AM »
Where do i put this? i put it in my addons and it doesn't even load with the server?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #131 on: February 06, 2013, 02:54:41 PM »
Well, as is usual for most release posts here made before October 2012, make sure you're trying an updated version, IF one exists.
http://forums.ulyssesmod.net/index.php/topic,3826.msg27481.html#msg27481
If that doesn't work for you, try IMing the user?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline datgregofag

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: AutoPromote
« Reply #132 on: February 10, 2013, 10:30:29 AM »
I want it so it just promotes a player from user to Respected in 3 hours, can you show me how to do that? Thank You.

Offline Zevoxa

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: AutoPromote
« Reply #133 on: February 14, 2013, 06:30:20 AM »
I want it so it just promotes a player from user to Respected in 3 hours, can you show me how to do that? Thank You.

Go into C:\(Gmod Server Directory)\orangebox\garrysmod\addons\AutoPromote\lua\ulx\modules\AutoPromote.lua

And if I am correct (if I'm not, someone correct me), this should be the code for what you're trying to do.

Code: [Select]
--[[
CREDIT FOR THIS VERSION OF AUTOPROMOTE GOES TO:
HOLOGRAPHICpizza
Major_Pain
Smithy
Jay209015

Garry's Mod 13 fix by EmilHem

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 = 3, group = "Respected", name = "Respected" },

}

---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "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



function checkExcludes( ply )
for id, eX in pairs (excludes) do
if ply:IsUserGroup(eX) then
return true
end
end
return false
end

function hoursToPromote( group )
for id, blank in ipairs( promotes ) do
if group == promotes[id]["group"] then
return promotes[id]["hours"]
end
end
end

function getPromoteName( group )
for id, blank in ipairs( promotes ) do
if group == promotes[id]["group"] then
return promotes[id]["name"]
end
end
end

function loopBlock( ply )
local toMark = 0;
local fromMark = 0;
for i=1, table.Count(promotes) do
if ply.promote == promotes[i]["group"] then
toMark = i;
end
if ply:IsUserGroup( promotes[i]["group"] ) then
fromMark = i;
end
end
print("fromMark: "..tostring(fromMark).." (<) toMark: "..tostring(toMark))
if fromMark < toMark then
return true
else
return false
end
end

function groupSet( ply )
ply.plhrs = math.floor((ply:GetUTime() + CurTime() - ply:GetUTimeStart())/60/60)
ply.promote = promotes[1]["group"]
for id, blank in ipairs(promotes) do
if ply:IsUserGroup(promotes[id]["group"]) and id < table.Count(promotes) then
ply.promote = promotes[id + 1]["group"]
end
end
if not(ply:IsUserGroup(ply.promote)) and (ply.plhrs >= hoursToPromote( ply.promote )) and loopBlock(ply) then
return true
end
return false
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 promotePlayer( ply )
if not checkExcludes( ply ) then
if groupSet( ply ) then
if settings[1].msgOn then
for ud, blank in pairs( player.GetAll()) do
ULib.tsayColor(player.GetAll()[ud],false,settings[1].msgcol,ply:Nick().." has been promoted to '"..getPromoteName(ply.promote).."'.")
end
end
if settings[1].effOn then
effectS( ply )
sound.Play( "autopromote/promote.wav", ply:GetPos( 0, 0, 0 ), 160 )
end
game.ConsoleCommand( "ulx adduserid "..ply:SteamID().." "..ply.promote.."\n" ) // I'm using this since it works and logs in the console. -EmilHem
end
end
if not timer.Exists("Promotion-" ..tostring(ply:SteamID())) then
timer.Create( "Promotion-"..tostring(ply:SteamID()), 15, 0, function() if not (ply and IsValid(ply)) then return end promotePlayer( ply ) end )
end
end

function timerStart( ply )
timer.Create( "Promotion-"..tostring(ply:SteamID()), 15, 0, function() if not (ply and IsValid(ply)) then return end promotePlayer( ply ) end )
end
hook.Add( "PlayerInitialSpawn", "timerstarting", timerStart )

function destroyTimers(ply)
if timer.Exists("Promotion-" ..tostring(ply:SteamID())) then
timer.Stop("Promotion-" ..tostring(ply:SteamID()))
timer.Destroy("Promotion-" ..tostring(ply:SteamID()))
end
end
hook.Add( "PlayerDisconnected", "PromotionCleanUP", destroyTimers )

I'd suggest you also look around in there to see if you want to change anything else.

Offline datgregofag

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: AutoPromote
« Reply #134 on: February 14, 2013, 12:01:54 PM »
TY Zevoxa and i also changed the people who wont get updated to respected like respected itself and oeprator and Vip ( well those are jut the ranks in my server).