Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Ban( plr, duration, reason, player )
- {
- local g_bantime, duration_type;
- switch( duration.len() )
- {
- case 2: //this is for slicing the type of 1d
- g_bantime = duration.slice(0,1);
- duration_type = duration.slice(1,2);
- break;
- case 3: //this is for slicing the type of 10d,10h,10m
- g_bantime = duration.slice(0,2);
- duration_type = duration.slice(2,3);
- break;
- }
- local g_bantime_, g_duration_type_;
- switch( duration_type )
- {
- case "d":
- g_bantime_ = g_bantime.tointeger() * 86400;
- g_duration_type_ = "day(s)";
- break;
- case "m":
- g_bantime_ = g_bantime.tointeger() * 2678400;
- g_duration_type_ = "month(s)";
- break;
- case "h":
- g_bantime_ = g_bantime.tointeger() * 3600;
- g_duration_type_ = "hour(s)";
- break;
- default:
- SendMessage( "Invalid format, the format you typed is wrong", player );
- }
- local dur = g_bantime + " " + g_duration_type_;
- ServerMessage( "Admin:[ " + player + " ] Banned: [ "+ plr +" ], for Reason: [ " + reason+ " ], Duration: [ " + dur + " ]" );
- EchoMessage( "[BAN] - "+ICOL_RED+"Admin:[ " + player + " ] Banned: [ "+ plr +" ], for Reason: [ " + reason+ " ], Duration: [ " + dur + " ]" );
- EchoMessage1( "[BAN] - "+ICOL_RED+"Admin:[ " + player + " ] Banned: [ "+ plr +" ], for Reason: [ " + reason+ " ], Duration: [ " + dur + " ]" );
- QuerySQL(db, "INSERT INTO Bans ( Name, g_bantime, g_banexp, Reason, Admin, UID, IP ) VALUES ( '"+plr+"', '"+time()+"', '"+g_bantime_+"', '"+reason+"', '"+player+"', '"+plr.UniqueID+"', '"+plr.IP+"' )" );
- plr.Kick();
- }
- function CheckBan( player )
- {
- local q = QuerySQL( db, "SELECT * FROM Bans WHERE UID='" + player.UniqueID + "' COLLATE NOCASE" );
- local uid = GetSQLColumnData( q, 5 ), b_time =GetSQLColumnData( q, 1 ), b_exp = GetSQLColumnData(q, 2 );
- if ( uid )
- {
- if ( time() - b_time >= b_exp )
- {
- QuerySQL( db, "DELETE FROM Bans WHERE UID=" + player.UniqueID + "'" );
- MessagePlayer("Your ban has been expired, stick to the rules.", player );
- }
- else
- {
- local t_left = time() - b_time;
- local t_left_ = b_exp - t_left;
- ServerMessage( "Auto kicking "+player.Name+" as he is currently banned in server, Timeleft: "+Duration( t_left_ )+"." );
- EchoMessage( ICOL_RED+"Auto kicking "+player.Name+" as he is currently banned in server. Timeleft: "+Duration( t_left_ )+"." );
- EchoMessage1( ICOL_RED+"Auto kicking "+player.Name+" as he is currently banned in server. Timeleft: "+Duration( t_left_ )+"." );
- SendMessage( "Banned by: [ "+GetSQLColumnData(q, 4)+" ] Reason: [ "+GetSQLColumnData(q, 3)+" ] For unban appeals apply on forum, Forum: " +Forum+ ".", player );
- KickPlayer( player );
- }
- }
- FreeSQLQuery( q );
- }
- function Duration( secs )
- {
- local nDays, nHours, nMinutes, nMonths, nYears, nTime = "";
- nYears = secs/31536000;
- secs = secs%31536000;
- nMonths = secs/2678400;
- secs = secs%2678400;
- nDays = secs/86400;
- secs = secs%86400;
- nHours = secs/3600;
- secs = secs%3600;
- nMinutes = secs/60;
- secs = secs%60;
- if( nYears != 0 ) nTime = nTime + nYears + " Year" + (nYears > 1 ? "s":"");
- if( nMonths != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nMonths + " month" + (nMonths > 1 ? "s":"");
- if( nDays != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nDays + " day" + (nDays > 1 ? "s":"");
- if( nHours != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nHours + " hour" + (nHours > 1 ? "s":"");
- if( nMinutes != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nMinutes + " min" + (nMinutes > 1 ? "s":"");
- if( secs != 0 ) nTime = nTime + (nTime != "" ? " and ":"") + secs + " sec" + (secs > 1 ? "s":"");
- return nTime;
- }
Add Comment
Please, Sign In to add comment