Gito Baloch

  • Full Member
  • Posts: 143
Delete this.
«  »Last edited
I request you admins to delete this topic.

OreoT

  • New Member
  • Posts: 2
Developer of DeathMatch Samshing Z0nE | Venture DeathMatch.

MRSK143

  • Jr. Member
  • Posts: 55
Re: ( Simple ) Ban System.
« Reply #2,  »
Hey You Should Add One More THing That Should if the player is not in game then the admin would be able to ban the player

gta

  • Newbie
  • Posts: 8
Re: ( Simple ) Ban System.
« Reply #3,  »Last edited
Quote from Gito Baloch on July 11th, 07:40 AM
Ban System (DURATION)


Creating Database
Code: [Select]
DataBase <- ConnectSQL("Databases/BanSys.db");   
QuerySQL(DataBase, "create table if not exists Bans ( Name TEXT, UID TEXT, UID2 TEXT, Admin TEXT, Reason TEXT, Time INTEGER, IP REAL)");


onPlayer Join
Code: [Select]
CheckBan( player );


OnPlayer Command
Code: [Select]
else if (cmd == "ban")
{
if (!stats[player.ID].Registered) return MessagePlayer("[#ff0000]Error: [#ffffff]You don't have permission to use this command.",player);
else if (!stats[player.ID].Logged) return MessagePlayer("[#FF0000]You're Not Logged in.", player);
else if ( stats[ player.ID ].Level < 3 ) return MessagePlayer("[#FF0000]You don't have Authorization to to use this command.", player);
else if ( !text ) PrivMessage( player, format( "Error: Use /%s <player> Days Hours Reason", cmd ) );
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( plr )
{
local d = GetTok( text, " ", 2 ), h = GetTok( text, " ", 3 );
local reason = GetTok( text, " ", 4 NumTok( text, " " ) );
if (!IsNum(d)) return MessagePlayer("[#FF0000]Error: Days Must be in integers.",player);
else if (!IsNum(h)) return MessagePlayer("[#FF0000]Error: Hours Must be in integers.",player);
else if (!reason) return MessagePlayer("[#FF0000]ERROR: Reason is Missing.",player);
else if ( reason && d && h && IsNum( d ) && IsNum( h ) ) Ban( plr, player.Name, reason, d.tointeger(), h.tointeger() );
}
else MessagePlayer("Invalid Player.",player);
}
        return 0;
}


else if (cmd == "unban")
{
        if(stats[player.ID].Level < 3) MessagePlayer("[#ff0000]Error: [#ffffff]You don't have permission to use this command.",player);
        else if (!text) MessagePlayer("Correct syntax - /"+cmd+" Full player name",player);
else
{
DelBan( player.Name, text );
Message("[#ffffff]"+player.Name + "[#25A5F9] has unbanned[#ffffff] ( " + text + " ) ");
}
        return 0;
}


Functions
Code: [Select]
function Ban( player, admin, reason, d, h )
{
local name = player.Name.tolower(), Time = time() + d * 86400 + h * 3600;
QuerySQL( DataBase, "INSERT INTO Bans ( Name, UID, UID2, Admin, Reason, Time, IP ) VALUES ( '" + name + "', '" + player.UniqueID + "', '" + player.UniqueID2 + "', '" + admin + "', '" + reason + "', '" + Time.tointeger() + "', '" + player.IP + "')" );
Message( admin + " banned " + name + ", reason:[ " + reason + " ] time: [ " + d + " days, " + h + " hours ]." );
KickPlayer( player );
}
function GetLastDay( t1, t2 )
{
    local time = t2 - t1, min = ( time / 60 ).tointeger(), week = 0, hour = 0, day = 0;
while( min >= 60 ) { hour += 1; min -= 60; }
while( hour >= 24 ) { day += 1; hour -= 24; }
while( day >= 7 ) { week += 1; day -= 7; }
return ( week == 0 ? day + " days " + hour + " hours " + min + " minutes" : week + " weeks " + day + " days" );
}
function CheckBan( plr )
{
local q = QuerySQL( DataBase, "SELECT * FROM Bans WHERE UID='" + plr.UniqueID + "'" ), q2, q3;
if ( q )
{
local time1 = GetSQLColumnData( q, 5 ).tointeger();
if ( time1 && time() >= time1 )
{
QuerySQL( DataBase, "DELETE FROM Bans WHERE UID='" + plr.UniqueID + "'" );
FreeSQLQuery(q);
return false;
}
    local admin = GetSQLColumnData( q, 3 ), reason = GetSQLColumnData( q, 4 ), relname = GetSQLColumnData( q, 0 );

Message( "Player-Banned [ " + plr.Name + " ], Admin:[ " + admin + " ], Reason:[ " + reason + " ], Time Left:[ " + GetLastDay( time(), time1 ) + " ]." );
    KickPlayer( plr );
FreeSQLQuery( q );
return true;
}
else
{
q2 = QuerySQL( DataBase, "SELECT * FROM Bans WHERE IP='" + plr.IP + "'" );
if ( q2 )
{
local time1 = GetSQLColumnData( q2, 5 ).tointeger();
if ( time1 && time() >= time1 )
{
QuerySQL( DataBase, "DELETE FROM Bans WHERE IP='" + plr.IP + "'" );
FreeSQLQuery(q2);
return false;
}
      local admin = GetSQLColumnData( q2, 3 ), reason = GetSQLColumnData( q2, 4 ), relname = GetSQLColumnData( q2, 0 );

Message( "Player-Banned [ " + plr.Name + " ], Admin:[ " + admin + " ], Reason:[ " + reason + " ], Time Left:[ " + GetLastDay( time(), time1 ) + " ]." );
    KickPlayer( plr );
FreeSQLQuery( q2 );
return true;
}
else
{
q3 = QuerySQL( DataBase, "SELECT * FROM Bans WHERE LOWER(Name)='" + plr.Name.tolower() + "'" );
if ( q3 )
{
local time1 = GetSQLColumnData( q3, 5 ).tointeger();
if ( time1 && time() >= time1 )
{
QuerySQL( DataBase, "DELETE FROM Bans WHERE LOWER(Name)='" + plr.Name + "'" );
FreeSQLQuery(q3);
return false;
}
      local admin = GetSQLColumnData( q3, 3 ), reason = GetSQLColumnData( q3, 4 ), relname = GetSQLColumnData( q3, 0 );

Message( "Player-Banned [ " + plr.Name + " ], Admin:[ " + admin + " ], Reason:[ " + reason + " ], Time Left:[ " + GetLastDay( time(), time1 ) + " ]." );
    KickPlayer( plr );
FreeSQLQuery( q3 );
return true;
}
}
}
try
{
FreeSQLQuery( q );
if ( q2 ) FreeSQLQuery( q2 );
if ( q3 ) FreeSQLQuery( q3 );
}
catch(e)
return false;
}

function DelBan( admin, banned )
{
QuerySQL( DataBase, "DELETE FROM Bans WHERE Name='" + banned.tolower() + "'" );
Message( "done." );
}
https://forum.vc-mp.org/?topic=6136.0
same script ^^
**  Last edited on August 5th, 2018, 09:57 AM **

Athanatos

  • Hero Member
  • Posts: 1,002
Re: Delete this.
« Reply #4,  »Last edited
Quote from Gito Baloch on July 11th, 07:40 AM
I request you admins to delete this topic.
You can delete it yourself duh - see the attachement file
Developer of RCNR, Zombie Survival, VLSM(C++) and Infected City Survival