Factions will now get disbanded after a week
This commit is contained in:
parent
296aeb5cc3
commit
417bbeee60
12
factions.lua
12
factions.lua
|
@ -35,6 +35,7 @@ factions.tick_time = 60.
|
||||||
factions.power_per_attack = 10.
|
factions.power_per_attack = 10.
|
||||||
factions.faction_name_max_length = 50
|
factions.faction_name_max_length = 50
|
||||||
factions.rank_name_max_length = 25
|
factions.rank_name_max_length = 25
|
||||||
|
factions.maximum_faction_inactivity = 604800 -- 1 week
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
--! @brief returns whether a faction can be created or not (allows for implementation of blacklists and the like)
|
--! @brief returns whether a faction can be created or not (allows for implementation of blacklists and the like)
|
||||||
|
@ -112,7 +113,9 @@ function factions.Faction:new(faction)
|
||||||
--! @brief banner texture string
|
--! @brief banner texture string
|
||||||
banner = "bg_white.png",
|
banner = "bg_white.png",
|
||||||
--! @brief gives certain privileges
|
--! @brief gives certain privileges
|
||||||
is_admin = false
|
is_admin = false,
|
||||||
|
--! @brief last time anyone logged on
|
||||||
|
last_logon = os.time(),
|
||||||
} or faction
|
} or faction
|
||||||
setmetatable(faction, self)
|
setmetatable(faction, self)
|
||||||
return faction
|
return faction
|
||||||
|
@ -641,6 +644,9 @@ function factions.load()
|
||||||
if #faction.name > factions.faction_name_max_length then
|
if #faction.name > factions.faction_name_max_length then
|
||||||
faction:disband()
|
faction:disband()
|
||||||
end
|
end
|
||||||
|
if not faction.last_logon then
|
||||||
|
faction.last_logon = os.time()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
@ -695,10 +701,14 @@ end
|
||||||
|
|
||||||
|
|
||||||
factions.faction_tick = function()
|
factions.faction_tick = function()
|
||||||
|
local now = os.time()
|
||||||
for facname, faction in pairs(factions.factions) do
|
for facname, faction in pairs(factions.factions) do
|
||||||
if faction:is_online() then
|
if faction:is_online() then
|
||||||
faction:increase_power(factions.power_per_tick)
|
faction:increase_power(factions.power_per_tick)
|
||||||
end
|
end
|
||||||
|
if faction.last_logon > factions.maximum_faction_inactivity then
|
||||||
|
faction:disband()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user