Checking if player is banned
#1

Hello.
i wanna make a system that checks if the player is banned.
this is what I got now, but it doesn't work.

pawn Код:
public OnPlayerConnect(playerid)
{
 //Login / Register
 new name[MAX_PLAYER_NAME],query[128],query2[128],nome[ MAX_STRING ], playerserial[128],playerip[32];
 format(query2,sizeof(query2),"SELECT * FROM `suspended` WHERE username='%s'",name);
 mysql_function_query(dbhandle,query2,true,"SuspendCheck","i",playerid);
 GetPlayerName(playerid, name, sizeof(name));
 format(query,sizeof(query),"SELECT id FROM user WHERE username='%s'",name);
 mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
 
    gpci(playerid,playerserial,sizeof(playerserial));
    GetPlayerIp(playerid,playerip,32);
    format( nome, sizeof(nome), "14[JOIN] %s[%d] has joined Syndicate Roleplay. (IP: %s) (GPCI: %s ) | Online: %d",PlayerName(playerid), playerid, playerip,playerserial, ConnectedPlayers());
    iEcho( nome );
 return 1;
}
public SuspendCheck(playerid)
{
   new num_rows,num_fields;
   cache_get_data(num_rows,num_fields,dbhandle);
   if(num_rows==0)
   {
return 1;
   }
   else
   {
   Kick (playerid);
   }
   return 1;
}

If you are banned you are inside a table which is called "Suspended".
If you are not banned, you are not in that table at all.

Can someone help me?
Reply
#2

PHP код:
public OnGameModeInit()
{
    
db mysql_connect(M_HostM_UserM_DataM_Pass);
    return 
1;

PHP код:
public OnPlayerConnect(playerid)
{
    
mysql_format(dbquerysizeof(query), "SELECT * FROM `suspended` WHERE username = BINARY('%s') LIMIT 1"GetpName(playerid));
    
mysql_pquery(dbquery"CheckIfBanned""d"playerid);

somewhere at the bottom of your script:
PHP код:
forward CheckIfBanned(playerid);
public 
CheckIfBanned(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsdb);
    if (
rows) {
        
SendClientMessage(playerid, -1"You are banned from this server!");
        
Kick(playerid);
    }
    else  {
        
mysql_format(dbquerysizeof(query), "SELECT `Password` FROM `players` WHERE `Username` = BINARY('%s') LIMIT 1"GetpName(playerid));
        
mysql_pquery(dbquery"CheckAccount""d"playerid);
    }
    return 
1;

PHP код:
forward CheckAccount(playerid);
public 
CheckAccount(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsdb);
    if (
rows) {
         
//do login
    
}
    else  {
        
//do registration
    
}
    return 
1;

P.S: you need the newest version of MySQL
Reply
#3

Quote:
Originally Posted by luke49
Посмотреть сообщение
PHP код:
public OnGameModeInit()
{
    
db mysql_connect(M_HostM_UserM_DataM_Pass);
    return 
1;

PHP код:
public OnPlayerConnect(playerid)
{
    
mysql_format(dbquerysizeof(query), "SELECT * FROM `suspended` WHERE username = BINARY('%s') LIMIT 1"GetpName(playerid));
    
mysql_pquery(dbquery"CheckIfBanned""d"playerid);

somewhere at the bottom of your script:
PHP код:
forward CheckIfBanned(playerid);
public 
CheckIfBanned(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsdb);
    if (
rows) {
        
SendClientMessage(playerid, -1"You are banned from this server!");
        
Kick(playerid);
    }
    else  {
        
mysql_format(dbquerysizeof(query), "SELECT `Password` FROM `players` WHERE `Username` = BINARY('%s') LIMIT 1"GetpName(playerid));
        
mysql_pquery(dbquery"CheckAccount""d"playerid);
    }
    return 
1;

PHP код:
forward CheckAccount(playerid);
public 
CheckAccount(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsdb);
    if (
rows) {
         
//do login
    
}
    else  {
        
//do registration
    
}
    return 
1;

P.S: you need the newest version of MySQL
thanks btw; i'm using a older version of mysql
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)