Ulysses Stuff > Ulysses Release Archives

AutoPromote

<< < (17/29) > >>

Aaron113:
Sure I'll take it.

someone920:

--- 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 = 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 )
--- End code ---

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.

Aaron113:

--- Quote from: someone920 on April 04, 2010, 06:55:17 PM ---
--- 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 = 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 )
--- End code ---

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.

--- End quote ---

Thanks that strangely worked perfectly. ;D

Simple:
Is this compatible with ULX and ULIB SVN?

JamminR:

--- Quote from: Simple on May 08, 2010, 05:20:38 AM ---Is this compatible with ULX and ULIB SVN?

--- End quote ---
Read the last three posts before yours.
Aaron says he's using SVN, Someone920 provides working code.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version