Ban

Started by FarisDon, Jul 16, 2015, 03:14 PM

Previous topic - Next topic

FarisDon

function CheckBan( p )
{
           local q = QuerySQL( db, "SELECT Name,IP,UID FROM Bans WHERE Name='" + p + "'" );
   local  Name = GetSQLColumnData( q, 0 ), IP = GetSQLColumnData( q, 1 ) , UID = GetSQLColumnData( q, 2);
   if ( ( p.Name ) || ( p.IP)  || ( p.UID ))  return 1;
   else return 0;}
   
if ( CheckBan(player)=="1")Ban(player); // on server joins function
   
Well whenever ._. i join the server it kicks me even if my name is not in the database i had made this specially for vpn ban , and ip ban , but it always kick me.

DizzasTeR

Why are you comparing a bool value with string? it will never work, and secondly why are you re-banning a banned player? Try

if ( CheckBan( player ) ) KickPlayer( player );

FarisDon

#2
Quote from: Doom_Killer on Jul 16, 2015, 03:18 PMWhy are you comparing a bool value with string? it will never work, and secondly why are you re-banning a banned player? Try

if ( CheckBan( player ) ) KickPlayer( player );
OH Dam i seriously forgot that ; Thank you :) Doom , and Eid mubarak.
Edit:Nope still it is banning me even there is no record in the Database.

[VSS]Shawn

try remove from db bam and try and eid mubarak FarisDon :)

FarisDon

Quote from: [VSS]Shawn on Jul 16, 2015, 03:48 PMtry remove from db bam and try and eid mubarak FarisDon :)
I can't understand what you mean????

.

Quote from: [VSS]Shawn on Jul 16, 2015, 03:48 PMtry remove from db bam and try and eid mubarak FarisDon :)

Damn dude. You must be truly retarded ;D Talking with your self and making no sense overall.
.

Thijn

Well no fucking shit it's banning you. You check if p.Name exists, if it does you get banned. Of course it exists >.<
You gotta rewrite that if statement.

FarisDon

Quote from: Thijn on Jul 16, 2015, 04:53 PMWell no fucking shit it's banning you. You check if p.Name exists, if it does you get banned. Of course it exists >.<
You gotta rewrite that if statement.
._. Eh thijn Which If statement there is only one that you mean checkban statement , but to re-write it like ?

Thijn

Quote from: Axel-Blaz on Jul 16, 2015, 05:11 PM
Quote from: Thijn on Jul 16, 2015, 04:53 PMWell no fucking shit it's banning you. You check if p.Name exists, if it does you get banned. Of course it exists >.<
You gotta rewrite that if statement.
._. Eh thijn Which If statement there is only one that you mean checkban statement , but to change it like what?
You wanna check if someone is banned, not if the player has a name. You got the query, now do something with it ;)

DizzasTeR

Ah yes of-course nice catch @Thijn.

So yeah Axel, I just noticed the mistake after reading Thijn's reply, you have to change this line.

if ( ( p.Name ) || ( p.IP)  || ( p.UID ))  return 1;
to
if ( ( Name ) || ( IP)  || ( UID ))  return 1;

Because you don't need to check if the plaer's name, IP or UID exists, ofcourse they exist, you have to check the result of the query you are getting ( Name, IP, UID ) in that case, if the queries finds any of those data from the given name ( p ) then it will kick him otherwise it won't.

Thijn

Removed 2 useless replies. The solution has been posted.

FarisDon

Quote from: Thijn on Jul 16, 2015, 06:03 PMRemoved 2 useless replies. The solution has been posted.
Thijn is a mastermind guy :D he should be the one to create 0.5 :P
Quote from: Doom_Killer on Jul 16, 2015, 05:35 PMAh yes of-course nice catch @Thijn.

So yeah Axel, I just noticed the mistake after reading Thijn's reply, you have to change this line.

if ( ( p.Name ) || ( p.IP)  || ( p.UID ))  return 1;
to
if ( ( Name ) || ( IP)  || ( UID ))  return 1;

Because you don't need to check if the plaer's name, IP or UID exists, ofcourse they exist, you have to check the result of the query you are getting ( Name, IP, UID ) in that case, if the queries finds any of those data from the given name ( p ) then it will kick him otherwise it won't.
Thanks i got it :).