Under the scenario of using this method for a banned library, it's OK. However; this isn't normally the method I would suggest to remove a name out of a library.
I would suggest SQLite, SQL and SQLite are kind of designed for this sort of use, here's some code for checking a table for banned users and the tables creation:
*code untested
pawn Код:
new DB:DB;
new DBResult:DBResult;
stock VerifyDatabase()
{
new bool:remake;
//Verify to see if the database exists
if(!fexist("BannedDB"))remake=true;
DB=db_open("BannedDB");
//If database does not exist, create the necessary table
if(remake)
{
print("[Database] Creating database...");
db_free_result(db_query(DB,"CREATE IF NOT EXISTS `Banned` (`ID` INTEGER PRIMARY KEY, `Name` TEXT)"));
}
print("[Database] Database opened");
}
stock IsPlayerBanned(playerid)
{
new tmpstring[64];
new name[24];
GetPlayerName(playerid,name,24);
format(tmpstring,64,"SELECT ROWID FROM Banned WHERE Name='%s'",name);
DBResult=db_query(DB,tmpstring);
if(db_num_rows(DBResult))
{
db_free_result(DBResult);
return 1;
}
return 0;
}
stock DBBan(playerid)
{
new name[24];
GetPlayerName(playerid,name,24);
if(IsPlayerBanned(playerid))
{
printf("[Database] \"%s\" already found in banned database",name);
return 0;
}
//Add name into database
new tmpstring[64];
format(tmpstring,64,"INSERT INTO Banned (Name) VALUES ('%s')",name);
db_free_result(db_query(DB,tmpstring));
printf("[Database] \"%s\" added to banned database",name);
return 1;
}
stock UnbanName(const name[])
{
new tmpstring[64];
format(tmpstring,64,"DELETE FROM Banned WHERE Name='%s'",name);
db_free_result(db_query(DB,tmpstring));
return 1;
}
VerifyDatabase() would go into OnGameModeInit()
IsPlayerBanned will tell you if the player is banned (OnPlayerConnect is a good place for this)
DBBan(playerid) to ban players
UnbanName("name") to unban
Pretty simple