Ancak ben ayrıca listeye eklenen uid'ye sahip (4 haneli sayı) oyuncularında sunucuya girebilmesini istiyorum.
Nasıl yapılabilir?
Uid native: native nGetUidByID(id);
Kod:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "check whitelist"
#define VERSION "1.0"
#define AUTHOR "bugsy"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
}
public client_authorized(id)
{
if( !IsWhiteListed(id) )
server_cmd("kick #%d ^"%s^"", get_user_userid(id), "Sunucumuz bakimdadir.")
}
public IsWhiteListed(id)
{
new szAdminFile[64]
new szItem[35]
new szAuthID[35]
new iItems
new iLen
get_user_authid( id , szAuthID , 34)
get_configsdir(szAdminFile, 63)
format( szAdminFile , 63 , "%s/whitelist.txt" , szAdminFile )
iItems = file_size( szAdminFile , 1 )
if( iItems == -1 )
{
return 0
}
else
{
if( file_size( szAdminFile , 2 ) == 1)
iItems--
for( new i = 0; i < iItems ; i++)
{
read_file( szAdminFile , i , szItem , 34 , iLen );
if ( equal( szAuthID, szItem , strlen(szAuthID) ) )
return 1
}
}
return 0
}