Ulysses Stuff > Ulysses Release Archives

AutoPromote

<< < (25/29) > >>

Botman:
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: ---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 )
--- End code ---

sweetone:
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: ---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 )
--- End code ---

and that's how I set the groups:

--- Code: ---"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"
}

--- End code ---

Aaron113:
Try these.  If they don't work, I don't know what is going wrong.

@sweetone

--- Code: ---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 )
--- End code ---

@botman

--- Code: ---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 )
--- End code ---

sweetone:
Thank you very much. :) it works!

Aaron113:
No problem.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version