Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if ( cmd == "ban")
- {
- if ( status[ player.ID ].Registered == false ) ErrorMessage( "[#FFFFFF]You need to be a part of our community to use this command.", player );
- else if ( status[ player.ID ].Logged == false ) ErrorMessage( "[#FFFFFF]You need to be identified to use this command.", player );
- else if ( GetLevel( player ) < 5 ) MessagePlayer("[Error] You don't have access to use this Command.", player );
- else if ( !text ) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason>", player );
- else
- {
- local args = split( text, " " );
- local plr = GetPlayer(args[0]), duration = args[1], reason = GetTok( text, " ", 3, NumTok( text, " " ) );
- if ( !plr ) ErrorMessage( "Invalid player", player );
- else if (!duration) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason> ", player );
- else if(!reason) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason> ", player );
- else
- {
- Ban( plr, duration, reason, player );
- }
- }
- }
- 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();
- }
Add Comment
Please, Sign In to add comment