Guest User

Untitled

a guest
Dec 13th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CMD:ban(playerid, params[])
  2. {
  3.     new
  4.         id,
  5.         reason[ 87 ],
  6.         time,
  7.         period[ 8 ];
  8.  
  9.     if( PlayerInfo[ playerid ][ pAdmin ] < 3 )
  10.         return SendClientMessage( playerid, COLOR_RED, "[ERROR] Permission denied - Admin level 3 or higher required" );
  11.  
  12.     if( sscanf( params, "ris[8]s[87]", id, time, period, reason ))
  13.     {
  14.         SendClientMessage( playerid, COLOR_YELLOW, "[USAGE] /ban [playerid] [time] [period] [reason]" );
  15.         SendClientMessage( playerid, COLOR_WHITE, "* [playerid] = Chosen Player ID or Name");
  16.         SendClientMessage( playerid, COLOR_WHITE, "* [time] = Number of [period] - example 4 [days] (0 = Permanent)");
  17.         SendClientMessage( playerid, COLOR_WHITE, "* [period] = Years/Months/Days/Hours/Minutes (If time = 0 - put days as period)");
  18.         SendClientMessage( playerid, COLOR_WHITE, "* [reason] = Reason for ban (Min: 1 letters - Max 87 letters)");
  19.         return SendClientMessage( playerid, COLOR_YELLOW, "[/USAGE]" );
  20.     }
  21.  
  22.     if( !IsPlayerConnected( id ))
  23.         return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid player ID or name" );
  24.  
  25.     if( time < 0 )
  26.         return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid time - Be sure to enter an integer over 0" );
  27.  
  28.     if( strcmp( period, "years", true ) && strcmp( period, "months", true ) && strcmp( period, "days", true ) && strcmp( period, "hours", true ) && strcmp( period, "minutes", true ))
  29.         return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid period - only years, months, days, hours or minutes allowed as input" );
  30.  
  31.     if( strlen( reason ) > 87 || strlen( reason ) < 2 )
  32.         return SendClientMessage( playerid, COLOR_RED, "[ERROR] Reason must be at least 2 letters long, and maximum 86 letters long" );
  33.  
  34.     new
  35.         banString[ 128 ];
  36.  
  37.     format( banString, sizeof( banString ), "[WARNING] You have been banned. Reason: %s", reason );
  38.     SendClientMessage( id, COLOR_RED, banString );
  39.  
  40.     if( !time )
  41.         format( banString, sizeof( banString ), "The ban will never be lifted (Permanent ban)" );
  42.     else
  43.         format( banString, sizeof( banString ), "The ban will be lifted in %i %s", time, period );
  44.  
  45.     SendClientMessage( id, COLOR_RED, banString );
  46.     printf( "%s (%i) was banned - see banlist.ini for details", PlayerName( id ), id );
  47.     BanPlayer( id, time, period, reason );
  48.     return true;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment