Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: FarisDon on Jul 16, 2015, 03:14 PM

Title: Ban
Post by: FarisDon on Jul 16, 2015, 03:14 PM
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.
Title: Re: Ban
Post by: DizzasTeR on Jul 16, 2015, 03:18 PM
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 );
Title: Re: Ban
Post by: FarisDon on Jul 16, 2015, 03:35 PM
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.
Title: Re: Ban
Post by: [VSS]Shawn on Jul 16, 2015, 03:48 PM
try remove from db bam and try and eid mubarak FarisDon :)
Title: Re: Ban
Post by: FarisDon on Jul 16, 2015, 04:42 PM
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????
Title: Re: Ban
Post by: . on Jul 16, 2015, 04:44 PM
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.
Title: Re: Ban
Post by: Thijn on Jul 16, 2015, 04:53 PM
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.
Title: Re: Ban
Post by: FarisDon 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 re-write it like ?
Title: Re: Ban
Post by: Thijn on Jul 16, 2015, 05:13 PM
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 ;)
Title: Re: Ban
Post by: DizzasTeR on Jul 16, 2015, 05:35 PM
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.
Title: Re: Ban
Post by: Thijn on Jul 16, 2015, 06:03 PM
Removed 2 useless replies. The solution has been posted.
Title: Re: Ban
Post by: FarisDon on Jul 16, 2015, 08:25 PM
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 :).