Right - I whipped up a small SQLite system for you. This will store member names and levels. I have omitted the commands/registration as I feel it would be beneficial for you to code this yourself.
If you get stuck let me know.
The titles of each function explain in good detail what they actually do.
pawn Code:
/*
This script stores member names and levels. I've provided you
With this framework so you may build your own commands based around
Them. All stock names are self explanitory. I have written what each returns
Next to the functions themselves.
Rob Butler (RobThugz/Rob_Maate)
*/
new DB:ClanDB;
stock IsPlayerInOfficialClan(playerid) //Returns TRUE if yes, FALSE if no
{
new Query[128];
new Name[MAX_PLAYER_NAME];
new DBResult:Result;
GetPlayerName(playerid, Name, sizeof(Name));
format(Query, sizeof(Query), "SELECT * FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
Result = db_query(ClanDB, Query);
if(db_num_rows(Result)) return true;
return false;
}
stock AddPlayerToOfficialClan(playerid, level)
{
new Query[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(Query, sizeof(Query), "INSERT INTO `MEMBERS` (`NAME`, `LEVEL`) VALUES ('%s', '%d')", Name, level);
db_query(ClanDB, Query);
return 1;
}
stock RemovePlayerFromOfficialClan(playerid)
{
new Query[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(Query, sizeof(Query), "DELETE FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
db_query(ClanDB, Query);
return 1;
}
stock UpdatePlayerOfficialClanInfo(playerid, level)
{
new Query[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(Query, sizeof(Query), "UPDATE `MEMBERS` SET (`NAME`, `LEVEL`) VALUES ('%s', '%d') WHERE `NAME` = '%s'", Name, level, Name);
db_query(ClanDB, Query);
return 1;
}
stock GetPlayerOfficialClanLevel(playerid) //There are easier ways to do this, but for the sake of education i'll use db_get_field_assoc
{ //This returns the player's clan level
new Query[128];
new Name[MAX_PLAYER_NAME];
new DBResult:Result;
new Field[30];
new Level = 0;
GetPlayerName(playerid, Name, sizeof(Name));
format(Query, sizeof(Query), "SELECT * FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
if(db_num_rows(Result))
{
db_get_field_assoc(Result, "LEVEL", Field, sizeof(Field));
Level = strval(Field);
}
return Level;
}
public OnGameModeInit()
{
ClanDB = db_open("ClanDatabase.db");
db_query(ClanDB, "CREATE TABLE IF NOT EXISTS `MEMBERS` (`NAME`, `LEVEL`)");
return 1;
}
public OnGameModeExit()
{
db_close(ClanDB);
return 1;
}
public OnPlayerConnect(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
if(strfind(Name, "[TAG]", true) != -1)
{
if(!IsPlayerInOfficialClan(playerid))
{
SendClientMessage(playerid, 0xFFFFFFFF, "You are not a member of the [TAG] clan. Please remove the clantag.");
Kick(playerid);
}
}
return 1;
}
EDIT: This is untested as balls, I literally just wrote this down. If it doesn't compile after you've integrated it with your gamemode just lemme know and i'll fix it for you