|
@@ -14,6 +14,8 @@ function spawn(NPC)
|
|
|
|
|
|
local charID = GetShardCharID(NPC)
|
|
|
SetAccessToEntityCommandByCharID(NPC, charID, "recovershard", true)
|
|
|
+
|
|
|
+ CheckShardExpired(NPC) -- update 4/22/2023 to remove long standing shards
|
|
|
end
|
|
|
|
|
|
function recovershard(NPC, Spawn)
|
|
@@ -37,4 +39,25 @@ function recovershard(NPC, Spawn)
|
|
|
DeleteDBShardID(shardid)
|
|
|
Despawn(NPC)
|
|
|
end
|
|
|
+end
|
|
|
+
|
|
|
+function CheckShardExpired(NPC)
|
|
|
+ local creationStamp = GetShardCreatedTimestamp(NPC)
|
|
|
+ local year_ = string.sub(creationStamp, 0, 4)
|
|
|
+ local month_ = string.sub(creationStamp, 5, 6)
|
|
|
+ local day_ = string.sub(creationStamp, 7, 8)
|
|
|
+ local hour_ = string.sub(creationStamp, 9, 10)
|
|
|
+ local min_ = string.sub(creationStamp, 11, 12)
|
|
|
+ local sec_ = string.sub(creationStamp, 13, 14)
|
|
|
+ local currentUTCTime = os.time(os.date('!*t'))
|
|
|
+ local creationTime = os.time{year=year_, month=month_, day=day_, hour=hour_, min=min_,sec=sec_}
|
|
|
+
|
|
|
+ local resultDiff = currentUTCTime - creationTime;
|
|
|
+ local shardLifeTime = GetRuleFlagFloat("R_Combat", "ShardLifetime")
|
|
|
+
|
|
|
+ if shardLifeTime > 0 and resultDiff > shardLifeTime then
|
|
|
+ local shardid = GetShardID(NPC)
|
|
|
+ DeleteDBShardID(shardid) -- you could alternatively choose to not delete from DB, but for now it only holds XP debt recovery not items
|
|
|
+ Despawn(NPC)
|
|
|
+ end
|
|
|
end
|