Try these. If they don't work, I don't know what is going wrong.
@sweetone
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
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 )