SHOW:
|
|
- or go back to the newest paste.
1 | - | /* BANCHECK */ |
1 | + | CMD:ban(playerid, params[]) |
2 | { | |
3 | - | pBanInfo[ playerid ][ bYear ] = -1; |
3 | + | new |
4 | id, | |
5 | - | INI_ParseFile( "banlist.ini", "BannedPlayers", .bExtra = true, .extra = playerid, .bPassTag = true ); //load file |
5 | + | reason[ 87 ], |
6 | time, | |
7 | - | if( pBanInfo[ playerid ][ bYear ] == -1 ) |
7 | + | period[ 8 ]; |
8 | - | goto BANCHECK_DONE; |
8 | + | |
9 | if( PlayerInfo[ playerid ][ pAdmin ] < 3 ) | |
10 | - | new |
10 | + | return SendClientMessage( playerid, COLOR_RED, "[ERROR] Permission denied - Admin level 3 or higher required" ); |
11 | - | year, |
11 | + | |
12 | - | month, |
12 | + | if( sscanf( params, "ris[8]s[87]", id, time, period, reason )) |
13 | - | day, |
13 | + | |
14 | - | hour, |
14 | + | SendClientMessage( playerid, COLOR_YELLOW, "[USAGE] /ban [playerid] [time] [period] [reason]" ); |
15 | - | minute, |
15 | + | SendClientMessage( playerid, COLOR_WHITE, "* [playerid] = Chosen Player ID or Name"); |
16 | - | second, |
16 | + | SendClientMessage( playerid, COLOR_WHITE, "* [time] = Number of [period] - example 4 [days] (0 = Permanent)"); |
17 | - | banString[ 128 ]; |
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 | - | getdate( year, month, day ); |
19 | + | return SendClientMessage( playerid, COLOR_YELLOW, "[/USAGE]" ); |
20 | - | gettime( hour, minute, second ); |
20 | + | |
21 | ||
22 | - | if( year == pBanInfo[ playerid ][ bYear ] ) |
22 | + | if( !IsPlayerConnected( id )) |
23 | - | { |
23 | + | return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid player ID or name" ); |
24 | - | if( month == pBanInfo[ playerid ][ bMonth ] ) |
24 | + | |
25 | - | { |
25 | + | if( time < 0 ) |
26 | - | if( day == pBanInfo[ playerid ][ bDay ] ) |
26 | + | return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid time - Be sure to enter an integer over 0" ); |
27 | - | { |
27 | + | |
28 | - | if( hour == pBanInfo[ playerid ][ bHour ] ) |
28 | + | if( strcmp( period, "years", true ) && strcmp( period, "months", true ) && strcmp( period, "days", true ) && strcmp( period, "hours", true ) && strcmp( period, "minutes", true )) |
29 | - | { |
29 | + | return SendClientMessage( playerid, COLOR_RED, "[ERROR] Invalid period - only years, months, days, hours or minutes allowed as input" ); |
30 | - | if( minute >= pBanInfo[ playerid ][ bMinute ] ) |
30 | + | |
31 | - | goto NOTBANNED; |
31 | + | if( strlen( reason ) > 87 || strlen( reason ) < 2 ) |
32 | - | else |
32 | + | return SendClientMessage( playerid, COLOR_RED, "[ERROR] Reason must be at least 2 letters long, and maximum 86 letters long" ); |
33 | - | goto BANNED; |
33 | + | |
34 | - | } |
34 | + | new |
35 | - | else if( hour > pBanInfo[ playerid ][ bHour ] ) |
35 | + | banString[ 128 ]; |
36 | - | goto NOTBANNED; |
36 | + | |
37 | - | else |
37 | + | format( banString, sizeof( banString ), "[WARNING] You have been banned. Reason: %s", reason ); |
38 | - | goto BANNED; |
38 | + | SendClientMessage( id, COLOR_RED, banString ); |
39 | - | } |
39 | + | |
40 | - | else if( day > pBanInfo[ playerid ][ bDay ] ) |
40 | + | if( !time ) |
41 | - | goto NOTBANNED; |
41 | + | format( banString, sizeof( banString ), "The ban will never be lifted (Permanent ban)" ); |
42 | - | else |
42 | + | else |
43 | - | goto BANNED; |
43 | + | format( banString, sizeof( banString ), "The ban will be lifted in %i %s", time, period ); |
44 | - | } |
44 | + | |
45 | - | else if( month > pBanInfo[ playerid ][ bMonth ] ) |
45 | + | SendClientMessage( id, COLOR_RED, banString ); |
46 | - | goto NOTBANNED; |
46 | + | printf( "%s (%i) was banned - see banlist.ini for details", PlayerName( id ), id ); |
47 | - | else |
47 | + | BanPlayer( id, time, period, reason ); |
48 | - | goto BANNED; |
48 | + | return true; |
49 | - | } |
49 | + | } |