ULX

Author Topic: AutoPromote  (Read 111884 times)

0 Members and 4 Guests are viewing this topic.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #75 on: April 03, 2010, 09:16:27 AM »
K I'll try reversing it later, people in server right now.  I'll let you know if it worked.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #76 on: April 03, 2010, 05:23:05 PM »
Seems I was wrong. Jay's correction from a few posts above yours, shows in order least to greatest.
Code: [Select]
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 = 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" }
}

But, it could depend on which version you're using. Several fixes/enhancements/versions exist within these pages.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #77 on: April 03, 2010, 07:42:53 PM »
I have no idea which I should use.  I am using the latest SVNed version of ULX if that has anything to do with it.  I also just downloaded UTime just a couple days ago.  So maybe there was a change that broke it?

Offline phoenixf129

  • Newbie
  • *
  • Posts: 11
  • Karma: 1
Re: AutoPromote
« Reply #78 on: April 04, 2010, 05:06:28 AM »
I keep getting a re-occuring error:

 ulx\modules/AutoPromote.lua:65: 'then' expected near '='

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: AutoPromote
« Reply #79 on: April 04, 2010, 08:52:34 AM »
If you guys want, I'll add mine, it's working perfectly. Only thing you have to do is add the last group to the list that won't be promoted... ever.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #80 on: April 04, 2010, 03:41:28 PM »
Sure I'll take it.

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: AutoPromote
« Reply #81 on: April 04, 2010, 06:55:17 PM »
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 = 3, group = "member", name = "Member" },
{ hours = 10, group = "b_member", name = "Bronze Member" },
{ hours = 30, group = "s_member", name = "Silver Member" },
{ hours = 60, group = "g_member", name = "Gold Member" },
{ hours = 120, group = "p_member", name = "Platinum Member" }
}

---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "supporter", "moderator", "administrator", "superadmin", "vip", "s_admin", "p_member", "storm" }

---------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 = false }
}

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

So just see that p_member is the last group players get promoted to but they are also in the excluded, if you don't do that with your last group, it's going to go in a loop.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #82 on: April 06, 2010, 07:43:05 PM »
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 = 3, group = "member", name = "Member" },
{ hours = 10, group = "b_member", name = "Bronze Member" },
{ hours = 30, group = "s_member", name = "Silver Member" },
{ hours = 60, group = "g_member", name = "Gold Member" },
{ hours = 120, group = "p_member", name = "Platinum Member" }
}

---------IF A PLAYER IS A MEMBER OF THESE GROUPS THEY WONT GET PROMOTED.......EVER
excludes = { "supporter", "moderator", "administrator", "superadmin", "vip", "s_admin", "p_member", "storm" }

---------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 = false }
}

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

So just see that p_member is the last group players get promoted to but they are also in the excluded, if you don't do that with your last group, it's going to go in a loop.

Thanks that strangely worked perfectly. ;D

Offline Simple

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: AutoPromote
« Reply #83 on: May 08, 2010, 05:20:38 AM »
Is this compatible with ULX and ULIB SVN?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #84 on: May 08, 2010, 09:38:15 AM »
Is this compatible with ULX and ULIB SVN?
Read the last three posts before yours.
Aaron says he's using SVN, Someone920 provides working code.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Tucker

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: AutoPromote
« Reply #85 on: June 17, 2010, 12:29:49 PM »
For some reason I can't get it to work. Here's my code.
]]
local promoteGroups = {
--   Groups must be listed in decending order.
--   ["hours"] = "group",
   ["100"] = "dedicatedmember",
   ["60"] = "highlyrespected",
   ["40"] = "moderatlyrespected",
   ["20"] = "lightlyrespected",
   ["10"] = "regular",
   ["2"] = "builder"
   ["0"] = "user"
}

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: AutoPromote
« Reply #86 on: June 17, 2010, 01:17:49 PM »
Unless there was an update on it, that is not even close to how your suppose to do it.


Code: [Select]
promotes = {
{ hours =2, group = "builder", name = "Builder" },
{ hours = 10, group = "regular", name = "Regular" },
{ hours = 20, group = "lightlyrespected", name = "Lightly Respected" },
{ hours = 40, group = "moderatlyrespected", name = "Moderately Respected" },
{ hours = 60, group = "highlyrespected", name = "Highly Respected" },
{ hours = 100, group = "dedicatedmember", name = "Dedicated Member" }
}
And make sure you use the working code that someone920 gave me.

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: AutoPromote
« Reply #87 on: July 09, 2010, 02:24:55 PM »
it seems Garry's last update broke my autopromote, anyone else have the same problem?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AutoPromote
« Reply #88 on: July 09, 2010, 03:19:18 PM »
<clip>anyone else have the same problem?

For those that might be, what, other than it not promoting, is the problem?
Errors? Symptoms?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: AutoPromote
« Reply #89 on: July 09, 2010, 03:55:46 PM »
I've been watching it all day, but there are no errors so far, but i just remembered, I don't have a cl_utime.lua for my utime, could that cause the problem?