Black List - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Black List (
/showthread.php?tid=334399)
Black List -
TyThaBomb - 14.04.2012
I'm trying to make a blacklist and I'm coming up with nothing. Anyone know of any tutorials or someone who can possibly assist me?
Re: Black List -
DarkB0y - 14.04.2012
what u mean?
Re: Black List -
TyThaBomb - 14.04.2012
Quote:
Originally Posted by X_Boy
what u mean?
|
I'm trying to make something that loads a .ini file from scriptfiles full of blacklisted names, and if someone joins with one, it kicks them.
Re: Black List -
TyThaBomb - 14.04.2012
Bump.. sorry for double post I just really need some help with this!
Re: Black List -
Kitten - 14.04.2012
https://sampforum.blast.hk/showthread.php?tid=235932
Re: Black List -
iggy1 - 14.04.2012
I was bored so i wrote you a little script (using sqlite not ini files). I didn't create commands because i thought that would be pointless as you should need to be admin to use them. Create the commands yourself and use these functions.
You can paste it into your gamemode/admin script if needed. I haven't tested it but it should work.
3 functions the names explain what they do so i wont bother.
Код:
stock AddNameToBlacklist( szPlayerName[] )
stock AddPlayerToBlacklist( playerid )
stock IsPlayerBlacklisted( playerid )
CODE:
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
new DB: dbBlacklist;
public OnFilterScriptInit()
{
if( !fexist( "blacklist.db" ) )
{
dbBlacklist = db_open( "blacklist.db" );
db_query( dbBlacklist, "CREATE TABLE blacklist (name VARCHAR(24))");
if( fexist( "blacklist.db" ) )
print("Blacklist database created");
else
print("Could not create blacklist database");
}
else
{
dbBlacklist = db_open( "blacklist.db" );
}
return 1;
}
public OnFilterScriptExit()
{
db_close( dbBlacklist );
return 1;
}
public OnPlayerConnect( playerid )
{
if( IsPlayerBlacklisted( playerid ) )//player is blacklisted
{
//send message or whatever
Kick( playerid );
}
return 1;
}
stock AddPlayerToBlacklist( playerid )
{
new
szQuery[ MAX_PLAYER_NAME + 64],
szPlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, szPlayerName, MAX_PLAYER_NAME );
format( szQuery, sizeof( szQuery ), "INSERT INTO blacklist (name) VALUES '%s'", szPlayerName );
db_query( dbBlacklist, szQuery );
}
stock AddNameToBlacklist( szPlayerName[] )
{
new szQuery[ MAX_PLAYER_NAME + 64];
format( szQuery, sizeof( szQuery ), "INSERT INTO blacklist (name) VALUES '%s'", szPlayerName );
db_query( dbBlacklist, szQuery );
}
stock IsPlayerBlacklisted( playerid )
{
new
DBResult: rResult,
szQuery[ MAX_PLAYER_NAME + 64],
szPlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, szPlayerName, MAX_PLAYER_NAME );
format( szQuery, sizeof( szQuery ), "SELECT null FROM blacklist WHERE name='%s'", szPlayerName );
rResult = db_query( dbBlacklist, szQuery );
if( db_num_rows( rResult ) )
{
db_free_result( rResult );
return 1;
}
db_free_result( rResult );
return 0;
}
You will need to edit the code for your needs but everything needed is provided, and it will be a lot better than using ini files.