• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Add to guild system active and inactive status (and delete if inactive from startup.lua)

Terotrificy

Well-Known Member
Joined
Oct 18, 2020
Messages
219
Solutions
9
Reaction score
67
Location
Santiago, Chile.
I just noticed the servers doesn't have the guild system working as it worked in rl tibia, so i created 2 tables into guilds (int expirationdate and boolean int status), so basically expirationdate have a value of time() + 3 days when you create the guild, and status is set to 1 (false).

My objective is to "disband" a guild (like the button from the guild manager website, otherwise the rest of characters will have array bug in guild rank and unable to join other guild) if it's inactive (and expirationdate < time.os), and if it's active then set the expirationdate to time() + 14 days, all this after every server save from the init.lua.

According to rl tibia, a guild is active only when 1 leader and 4 vice leaders are premium account players, otherwise it turns to inactive.

There is any way to check it from init.lua for Othire? I feel it is a good implementation for any distro because this is how it worked back in the days (idk nowadays) and also helps to maintain the database as clean as possible.

Hope if someone have time can give me a hand :p

guilds table:


guild_ranks table:


accounts table:


players table:

Lua:
CREATE TABLE `players` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `account_id` int(10) unsigned NOT NULL,
  `group_id` int(10) unsigned NOT NULL COMMENT 'users group',
  `sex` int(10) unsigned NOT NULL DEFAULT '0',
  `vocation` int(10) unsigned NOT NULL DEFAULT '0',
  `experience` bigint(20) unsigned NOT NULL DEFAULT '0',
  `level` int(10) unsigned NOT NULL DEFAULT '1',
  `maglevel` int(10) unsigned NOT NULL DEFAULT '0',
  `health` int(11) NOT NULL DEFAULT '100',
  `healthmax` int(11) NOT NULL DEFAULT '100',
  `mana` int(11) NOT NULL DEFAULT '100',
  `manamax` int(11) NOT NULL DEFAULT '100',
  `manaspent` int(10) unsigned NOT NULL DEFAULT '0',
  `soul` int(10) unsigned NOT NULL DEFAULT '0',
  `direction` int(10) unsigned NOT NULL DEFAULT '0',
  `lookbody` int(10) unsigned NOT NULL DEFAULT '10',
  `lookfeet` int(10) unsigned NOT NULL DEFAULT '10',
  `lookhead` int(10) unsigned NOT NULL DEFAULT '10',
  `looklegs` int(10) unsigned NOT NULL DEFAULT '10',
  `looktype` int(10) unsigned NOT NULL DEFAULT '136',
  `posx` int(11) NOT NULL DEFAULT '0',
  `posy` int(11) NOT NULL DEFAULT '0',
  `posz` int(11) NOT NULL DEFAULT '0',
  `cap` int(11) NOT NULL DEFAULT '0',
  `lastlogin` int(10) unsigned NOT NULL DEFAULT '0',
  `lastlogout` int(10) unsigned NOT NULL DEFAULT '0',
  `lastip` int(10) unsigned NOT NULL DEFAULT '0',
  `save` tinyint(1) NOT NULL DEFAULT '1',
  `conditions` blob NOT NULL COMMENT 'drunk, poisoned etc',
  `skull_type` int(11) NOT NULL DEFAULT '0',
  `skull_time` int(10) unsigned NOT NULL DEFAULT '0',
  `loss_experience` int(11) NOT NULL DEFAULT '100',
  `loss_mana` int(11) NOT NULL DEFAULT '100',
  `loss_skills` int(11) NOT NULL DEFAULT '100',
  `loss_items` int(11) NOT NULL DEFAULT '10',
  `loss_containers` int(11) NOT NULL DEFAULT '100',
  `town_id` int(11) NOT NULL COMMENT 'old masterpos, temple spawn point position',
  `balance` int(11) NOT NULL DEFAULT '0' COMMENT 'money balance of the player for houses paying',
  `online` tinyint(1) NOT NULL DEFAULT '0',
  `rank_id` int(11) NOT NULL COMMENT 'only if you use __OLD_GUILD_SYSTEM__',
  `guildnick` varchar(255) NOT NULL COMMENT 'only if you use __OLD_GUILD_SYSTEM__',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `online` (`online`),
  KEY `account_id` (`account_id`),
  KEY `group_id` (`group_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=25 ;

--
-- RELATIONS FOR TABLE `players`:
--   `account_id`
--       `accounts` -> `id`
--   `group_id`
--       `groups` -> `id`

Pd: Keep in mind that 'premend' value might be != 0 and still be free account because the value is never deleted when it "expires", so you need to compare with os.time to know if it's actually expired.
 
Last edited:

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
i want it too
my guild page was a hell when i had a server
 
Top