Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BanPlayer(playerid, time, period[], reason[])
- {
- new
- second,
- minute,
- hour,
- day,
- month,
- year;
- gettime( hour, minute, second );
- getdate( year, month, day );
- new
- INI:banFile = INI_Open( "banlist.ini" );
- INI_SetTag( banFile, PlayerName( playerid ));
- if( time == 0 )
- {
- INI_WriteInt( banFile, "year", 0 );
- INI_WriteInt( banFile, "month", 0 );
- INI_WriteInt( banFile, "day", 0 );
- INI_WriteInt( banFile, "hour", 0 );
- INI_WriteInt( banFile, "minute", 0 );
- INI_WriteString( banFile, "reason", reason );
- INI_Close( banFile );
- goto BAN_FUNC_END;
- }
- switch( YHash( period, false ))
- {
- case _I<minutes>:
- {
- while(( minute + time ) > 60 )
- {
- hour ++;
- minute -= 60;
- if(( hour ) > 24 )
- {
- day ++;
- hour -= 24;
- if(( day ) > 28 )
- {
- switch( month )
- {
- case 1, 3, 5, 7, 8, 10, 12:
- {
- if(( day ) > 31 )
- {
- month ++;
- day -= 31;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 4, 6, 9, 11:
- {
- if(( day ) > 30 )
- {
- month ++;
- day -= 30;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 2:
- {
- if(( year % 4 ) == 0 && ( year % 100 ) != 0 )
- {
- if(( day ) > 29 )
- {
- month ++;
- day -= 29;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- else
- {
- if(( day ) > 28 )
- {
- month ++;
- day -= 28;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- }
- }
- }
- }
- }
- INI_WriteInt( banFile, "year", year );
- INI_WriteInt( banFile, "month", month );
- INI_WriteInt( banFile, "day", day );
- INI_WriteInt( banFile, "hour", hour );
- INI_WriteInt( banFile, "minute", ( minute + time ));
- }
- case _I<hours>:
- {
- while(( hour + time ) > 24 )
- {
- day ++;
- hour -= 24;
- if(( day ) > 28 )
- {
- switch( month )
- {
- case 1, 3, 5, 7, 8, 10, 12:
- {
- if(( day ) > 31 )
- {
- month ++;
- day -= 31;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 4, 6, 9, 11:
- {
- if(( day ) > 30 )
- {
- month ++;
- day -= 30;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 2:
- {
- if(( year % 4 ) == 0 && ( year % 100 ) != 0 )
- {
- if(( day ) > 29 )
- {
- month ++;
- day -= 29;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- else
- {
- if(( day ) > 28 )
- {
- month ++;
- day -= 28;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- }
- }
- }
- }
- INI_WriteInt( banFile, "year", year );
- INI_WriteInt( banFile, "month", month );
- INI_WriteInt( banFile, "day", day );
- INI_WriteInt( banFile, "hour", ( hour + time ));
- INI_WriteInt( banFile, "minute", minute );
- }
- case _I<days>:
- {
- while(( day + time ) > 28 )
- {
- switch( month )
- {
- case 1, 3, 5, 7, 8, 10, 12:
- {
- if(( day + time ) > 31 )
- {
- month ++;
- day -= 31;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 4, 6, 9, 11:
- {
- if(( day + time ) > 30 )
- {
- month ++;
- day -= 30;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- case 2:
- {
- if(( year % 4 ) == 0 && ( year % 100 ) != 0 )
- {
- if(( day + time ) > 29 )
- {
- month ++;
- day -= 29;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- else
- {
- if(( day + time ) > 28 )
- {
- month ++;
- day -= 28;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- }
- }
- }
- INI_WriteInt( banFile, "year", year );
- INI_WriteInt( banFile, "month", month );
- INI_WriteInt( banFile, "day", ( day + time ));
- INI_WriteInt( banFile, "hour", hour );
- INI_WriteInt( banFile, "minute", minute );
- }
- case _I<months>:
- {
- while(( month + time ) > 12 )
- {
- year ++;
- month -= 12;
- switch( month )
- {
- case 2:
- {
- if(( year % 4 ) == 0 && ( year % 100 ) != 0 )
- {
- if( day > 29 )
- {
- month ++;
- day -= 29;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- else
- {
- if( day > 28 )
- {
- month ++;
- day -= 28;
- if( month > 12 )
- {
- year ++;
- month -= 12;
- }
- }
- }
- }
- case 4, 6, 9, 11:
- {
- if( day == 31 )
- {
- month ++;
- day = 1;
- }
- }
- }
- }
- INI_WriteInt( banFile, "year", year );
- INI_WriteInt( banFile, "month", ( month + time ));
- INI_WriteInt( banFile, "day", day );
- INI_WriteInt( banFile, "hour", hour );
- INI_WriteInt( banFile, "minute", minute );
- }
- case _I<years>:
- {
- if((( year % 4 ) == 0 && ( year % 100 ) != 0 ) && ((( year + time ) % 4 ) != 0 ))
- {
- if( month > 2 )
- {
- day --;
- if( day < 1 )
- {
- month --;
- switch( month )
- {
- case 1, 3, 5, 7, 8, 10, 12:
- day = 31;
- case 4, 6, 9, 11:
- day = 30;
- case 2:
- day = 28;
- }
- }
- }
- }
- else if(((( year + time ) % 4 ) != 0 ) && (( year % 4 ) == 0 && ( year % 100 ) != 0 ))
- {
- if( month > 2 )
- {
- day ++;
- switch( month )
- {
- case 3, 5, 7, 8, 10, 12:
- {
- if( day > 31 )
- {
- month ++;
- day = 1;
- }
- }
- case 4, 6, 9, 11:
- {
- if( day > 30 )
- {
- month ++;
- day = 1;
- }
- }
- }
- }
- }
- INI_WriteInt( banFile, "year", ( year + time ));
- INI_WriteInt( banFile, "month", month );
- INI_WriteInt( banFile, "day", day );
- INI_WriteInt( banFile, "hour", hour );
- INI_WriteInt( banFile, "minute", minute );
- }
- }
- INI_WriteString( banFile, "reason", reason );
- INI_Close( banFile );
- BAN_FUNC_END:
- PlayerInfo[ playerid ][ pBanned ] = true;
- Kick( playerid );
- }
Advertisement
Add Comment
Please, Sign In to add comment