Ban system [ MySQL ]
#1

Well the command and everything works it just doens't load the ban somehow when the player connects

OnPlayerConnect
PHP код:
new query[200];
mysql_format(SQLquerysizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1"GetName(playerid));
mysql_pquery(SQLquery"CheckPlayerAccount""i"playerid); 
CheckPlayerAccount
PHP код:
new q[128];
mysql_formatSQLqsizeof(q), "SELECT * FROM `banned` WHERE `user_id` = '%d' LIMIT 1"PlayerInfo[playerid][pSqlID] );
mysql_pquerySQLq"CheckPlayerBan""i"playerid ); 
CheckPlayerBan

PHP код:
/*
#define FUNCTION:%0(%1) \
        forward%0(%1); \
        public%0(%1)
*/
FUNCTION: CheckPlayerBanplayerid ) {
    new 
rows;
    
cache_get_row_count(rows);
    if( !
rows ) {
        
SetTimerEx"Login"100false"d"playerid ); // the login dialog and stuff
    
}
    else {
        new 
user_id;
        
user_id cache_get_value_name_int0"user_id"user_id );
        new 
ban_reason64 ], ban_date64 ], ban_adminMAX_PLAYER_NAME ];
        
cache_get_value_name0"ban_reason"ban_reason150 );
        
cache_get_value_name0"ban_date"ban_date150 );
        
cache_get_value_name0"ban_admin"ban_admin150 );
            if( 
user_id == PlayerInfoplayerid ][ pSqlID ] ) {
            
SendClientMessageplayeridRED"BANNED");
            
AC_Kick2playerid ); 
            
/*
            stock AC_Kick2(playerid)
            {
                SetTimerEx("TrueKick", 100, false, "i", playerid);
                GameTextForPlayer(playerid, "~r~Kicked", 60000, 4);
                TogglePlayerControllable(playerid, 0);
            }
            */
            
return 1;
        }
        else 
SetTimerEx"Login"100false"d"playerid );
    }

Reply
#2

Looks like this happends only when I (ID: 0) ban someone I don't know why tho...
Reply
#3

Quote:
Originally Posted by IdonTmiss
Посмотреть сообщение
Looks like this happends only when I (ID: 0) ban someone I don't know why tho...
Show your command.
Reply
#4

Quote:
Originally Posted by DBZdabIt3Bro7
Посмотреть сообщение
Show your command.
Here you go

PHP код:
cmd:pban(playeridparams[]) {
    if(
PlayerInfo[playerid][pAdmin] < 1338) return SendClientMessage(playeridRED"Not allowed!");
    new 
idreason40 ];
    if( 
sscanfparams,"us[40]"idreason ) ) return SendClientMessageplayeridRED"USAGE: /pban [ ID ] [ Reason ]");
    if( !
IsPlayerConnectedid ) ) return SendClientMessageplayeridRED" Wrong ID");
    
sql_ban_userGetNameid ), PlayerInfoid ][ pSqlID ], 1reasonGetNameplayerid ) );
    
AC_Kick2id );
    return 
true;
}
// -- //
sql_ban_useruser_name[], user_idban_typeban_reason[], admin_name[], ban_time ) {
    new 
query512 ], ban_date64 ], tmphourtmpminutetmpsecondyearmonth,day;
    
getdateyearmonthday );
    
gettimeExtmphourtmpminutetmpsecond );
    
FixHourtmphour );
    
tmphour shifthour;
    
formatban_datesizeofban_date ), "%02d/%02d/%d - %d/%d/%d"daymonthyeartmphourtmpminutetmpsecond );
    
mysql_formatSQLquerysizeofquery ), "INSERT INTO `banned` (user_id, ban_type, ban_reason, ban_admin, ban_date, user_name) VALUES('%d', '%d', '%e', '%e', '%e', '%e')",
        
user_idban_typeban_reasonadmin_nameban_dateuser_name );
    
mysql_tquerySQLquery );
        
    return (
true);
}
    
PAdm(ZUTAporukica);
    
AC_Kick2id );
    
SS[0][ssBanovi]++;
    
SacuvajStatistiku(0);
    return 
true;

Reply
#5

Код:
user_id = cache_get_value_name_int( 0, "user_id", user_id );
This is wrong.

pawn Код:
if( user_id == PlayerInfo[ playerid ][ pSqlID ] )
This is redundant.
Reply
#6

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Код:
user_id = cache_get_value_name_int( 0, "user_id", user_id );
This is wrong.

pawn Код:
if( user_id == PlayerInfo[ playerid ][ pSqlID ] )
This is redundant.
Then what should I type instead of that?
Reply
#7

a little bump?
Reply
#8

Remove the red text. Function passes by reference to user_id and then you return the value of cache_get_value_name_int which will be either 0 or 1 and bug it.

The if statement is redundant because you pass user_id onto WHERE clause in query. Unless you want to avoid race check collisions but this is not the way to do it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)