pugamoline
uint32_t patch_mem(char *
- Joined
- Nov 15, 2011
- Messages
- 189
- Reaction score
- 19
hi
this script remove inactive players from guild at 7 days.
Rep me ++
this script remove inactive players from guild at 7 days.
Lua:
-- [[> Automated Remove Inactive Players From Guild //PUGAMOLINE <]] --
function getLastLoginDiff(name)
if type(name) ~= "string" then
return name
end
local res = db.getResult("SELECT `lastlogin` FROM `players` WHERE `name` = '"..name.."';")
if res:getID() ~= -1 then
return os.time()-res:getDataInt('lastlogin')
end
end
local days = 7
function onStartup()
local guild = db.getResult("SELECT `id`, `ownerid` FROM `guilds`;")
if guild:getID() == -1 then
return true
end
repeat
local id, owner = guild:getDataInt("id"), guild:getDataInt("ownerid")
local diff = getLastLoginDiff(getPlayerNameByGUID(owner))
if diff >= 7*24*60*60 then
db.executeQuery("DELETE FROM `guilds` WHERE `id` = "..id..";")
end
until not(guild:next())
guild:free()
return true
end
<globalevent name="guildclean" type="start" event="script" value="guildclean.lua"/>
Rep me ++