Jump to content
  • Advertisement
Sign in to follow this  

Making a Guild: Getting Started

This topic is 3590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a multi-player game in development and would like to add a guild feature to it. I want the guild leader to have all the major functions such as add new members and choose generals and lieutenants. The generals and lieutenants will have whatever feature the guild leader decides they will have access too. The game will be adding new features such as alliances and guild wars and things, but right now, all I really want is just for people to join the guild and chat with each other. I'm using MySQL as my database. I have no clue how to do this. Any ideas?

Share this post

Link to post
Share on other sites
On a very simple design, you could have a column such as: enum position{Leader | Lieutenant | General | Regular) and then based on that position, you can allow a general set of actions to that group, like user permissions.

Taking it one step further, you can list out specific actions in the DB and override the values even if the group isn't normally allowed to have such permissions. vBulletin has a setup like this.

So for your game have cols such as

bool canInvite
bool canStartWar
bool canAllyGuild
bool canKickMember
bool canKickGeneral

and by default, fill them in based on the general pattern from the position enum, and then you can allow for the leader to set individual permissions.

You would also need to store some unique ID that identifies a player to a particular guild so people can't double up. If you were to implement a guild chat, this would make life easier since you would just find all the players that have the same guild ID and forward the messages to them.

Just some starting ideas, good luck!

Share this post

Link to post
Share on other sites
Is the problem with the database schema, or with the implementation?

You will need at least one table for guilds, for sure. You probably already have one table for players. I would add another table for player/guild membership (which allows players to be members of zero or more guilds). Permissions could either be part of the player/guild table, with flags like suggested above, or it could be another table, with a row per player/guild/permission entry. In fact, "isMember" could be a permission, so your membership in a guild is determined by that permission existing.

In that case, assuming you have:

table player
int playerid (unique, primary key)
string name

table guild
int guildid (unique, primary key)
string name

table player_guild_permissions
int playerid
int guildid
int permissionid
(primary key is all three together, sorted by player first)

Assume there's a fixed enum for what the permissions are, like enum { PermissionMember, PermissionCanAddMember, PermissionCanKickMember, PermissionCanPromoteMember, PermissionCanRepresentGuildToCustomerService, ... }. You would then find the guild/guilds that a player is member of by a simple join:

 select g.name, g.guildid from guild g, player_guild_permissions pgp 
where g.guildid = pgp.guildid and pgp.playerid = MY_PLAYER_ID and
pgp.permissionid = PermissionMember

The nice thing with this is that you can add new kinds of permissions without changing the table. The draw-back is that there are many rows per player, but typically you only select the set of permissions for player once, when he logs in, and perhaps re-select whenever a "big event" happens (like player getting kicked).

As for implementation, I would do it something like:

1. When player logs in, check what guild/s he is member of.
2. For each such guild, find the guild object instance on the server. If there is no such instance, create one and populate it from the guilds table.
3. When player guild-chats, send the text to the guild object. The guild object then echoes it to all logged-on players that are members of that guild.
4. When players disconnect, remove them from the guild object/s they were connected to.
5. When a guild object is empty (no players connected), it deletes itself.

[Edited by - hplus0603 on September 21, 2008 11:34:21 AM]

Share this post

Link to post
Share on other sites
Thanks everyone! This is good information to get me started. Yes, the main problem I'm having now is trying to figure out the database part and how to also make it expandable.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!