Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:ban(playerid, params[])
- {
- new
- id,
- reason[ 87 ],
- time,
- period[ 8 ];
- if( PlayerInfo[ playerid ][ pAdmin ] < 3 )
- return SendClientMessage( playerid, COLOR_RED, "[ERROR] Permission denied - Admin level 3 or higher required" );
- if( sscanf( params, "ris[8]s[87]", id, time, period, reason ))
- {
- SendClientMessage( playerid, COLOR_YELLOW, "[USAGE] /ban [playerid] [time] [period] [reason]" );
- SendClientMessage( playerid, COLOR_WHITE, "* [playerid] = Chosen Player ID or Name");
- SendClientMessage( playerid, COLOR_WHITE, "* [time] = Number of [period] - example 4 [days] (0 = Permanent)");
- SendClientMessage( playerid, COLOR_WHITE, "* [period] = Years/Months/Days/Hours/Minutes (If time = 0 - put days as period)");
- SendClientMessage( playerid, COLOR_WHITE, "* [reason] = Reason for ban (Min: 1 letters - Max 87 letters)");
- return SendClientMessage( playerid, COLOR_YELLOW, "[/USAGE]" );
- }
- if( !IsPlayerConnected( id ))
- return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid player ID or name" );
- if( time < 0 )
- return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid time - Be sure to enter an integer over 0" );
- if( strcmp( period, "years", true ) && strcmp( period, "months", true ) && strcmp( period, "days", true ) && strcmp( period, "hours", true ) && strcmp( period, "minutes", true ))
- return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid period - only years, months, days, hours or minutes allowed as input" );
- if( strlen( reason ) > 87 || strlen( reason ) < 2 )
- return SendClientMessage( playerid, COLOR_RED, "[ERROR] Reason must be at least 2 letters long, and maximum 86 letters long" );
- new
- banString[ 128 ];
- format( banString, sizeof( banString ), "[WARNING] You have been banned. Reason: %s", reason );
- SendClientMessage( id, COLOR_RED, banString );
- if( !time )
- format( banString, sizeof( banString ), "The ban will never be lifted (Permanent ban)" );
- else
- format( banString, sizeof( banString ), "The ban will be lifted in %i %s", time, period );
- SendClientMessage( id, COLOR_RED, banString );
- printf( "%s (%i) was banned - see banlist.ini for details", PlayerName( id ), id );
- BanPlayer( id, time, period, reason );
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment