Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TABLE_BAN "BAN"
- #define ID "ID"
- #define NAME "NAME"
- #define IP "IP"
- #define DATE "DATE"
- #define BAN_BY "BAN BY"
- #define REASON "REASON"
- #define TIME "TIME"
- #define PERMANENT 0
- #define MINUTES 1
- #define HOURS 2
- #define DAYS 3
- new MyConection;
- new PlayerText:Ban_TD[MAX_PLAYERS][4];
- public OnPlayerConnect(playerid)
- {
- Ban_TD[playerid][0] = CreatePlayerTextDraw(playerid, 114.241218, 142.017349, "_");
- PlayerTextDrawLetterSize(playerid, Ban_TD[playerid][0], 0.420705, 17.037477);
- PlayerTextDrawTextSize(playerid, Ban_TD[playerid][0], 501.299957, 0.000000);
- PlayerTextDrawAlignment(playerid, Ban_TD[playerid][0], 1);
- PlayerTextDrawColor(playerid, Ban_TD[playerid][0], -1);
- PlayerTextDrawUseBox(playerid, Ban_TD[playerid][0], 1);
- PlayerTextDrawBoxColor(playerid, Ban_TD[playerid][0], 100);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][0], 0);
- PlayerTextDrawSetOutline(playerid, Ban_TD[playerid][0], 0);
- PlayerTextDrawBackgroundColor(playerid, Ban_TD[playerid][0], 77);
- PlayerTextDrawFont(playerid, Ban_TD[playerid][0], 1);
- PlayerTextDrawSetProportional(playerid, Ban_TD[playerid][0], 1);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][0], 0);
- Ban_TD[playerid][1] = CreatePlayerTextDraw(playerid, 307.847869, 123.066467, "_");
- PlayerTextDrawLetterSize(playerid, Ban_TD[playerid][1], 0.400000, 1.600000);
- PlayerTextDrawTextSize(playerid, Ban_TD[playerid][1], 0.000000, 387.000000);
- PlayerTextDrawAlignment(playerid, Ban_TD[playerid][1], 2);
- PlayerTextDrawColor(playerid, Ban_TD[playerid][1], -1744830465);
- PlayerTextDrawUseBox(playerid, Ban_TD[playerid][1], 1);
- PlayerTextDrawBoxColor(playerid, Ban_TD[playerid][1], -16777066);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][1], 0);
- PlayerTextDrawSetOutline(playerid, Ban_TD[playerid][1], 0);
- PlayerTextDrawBackgroundColor(playerid, Ban_TD[playerid][1], 1962934527);
- PlayerTextDrawFont(playerid, Ban_TD[playerid][1], 1);
- PlayerTextDrawSetProportional(playerid, Ban_TD[playerid][1], 1);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][1], 0);
- Ban_TD[playerid][2] = CreatePlayerTextDraw(playerid, 176.117904, 121.983161, "YOU_ARE_BANNED_FROM_THIS_SERVER!");
- PlayerTextDrawLetterSize(playerid, Ban_TD[playerid][2], 0.400000, 1.600000);
- PlayerTextDrawAlignment(playerid, Ban_TD[playerid][2], 1);
- PlayerTextDrawColor(playerid, Ban_TD[playerid][2], 255);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][2], 0);
- PlayerTextDrawSetOutline(playerid, Ban_TD[playerid][2], 0);
- PlayerTextDrawBackgroundColor(playerid, Ban_TD[playerid][2], 255);
- PlayerTextDrawFont(playerid, Ban_TD[playerid][2], 2);
- PlayerTextDrawSetProportional(playerid, Ban_TD[playerid][2], 1);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][2], 0);
- Ban_TD[playerid][3] = CreatePlayerTextDraw(playerid, 128.588684, 142.650985, "NAME:_XXXXXXXXXXXXXXXXXXXXXXXX~n~IP:_000.000.000.000~n~DATE:_00/00/0000_-_00:00:00~n~ADMIN:_XXXXXXXXXXXXXXXXXXXXXXXX~n~REASON:_XXXXXXXXXXXXXXXXXXXXXXXXX~n~TIME_LEFT:~n~0000_DAYS_E_00_HOURS_E_00_MINUTES_E_00_SECONDS");
- PlayerTextDrawLetterSize(playerid, Ban_TD[playerid][3], 0.337294, 2.375833);
- PlayerTextDrawAlignment(playerid, Ban_TD[playerid][3], 1);
- PlayerTextDrawColor(playerid, Ban_TD[playerid][3], -16776961);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][3], 0);
- PlayerTextDrawSetOutline(playerid, Ban_TD[playerid][3], 0);
- PlayerTextDrawBackgroundColor(playerid, Ban_TD[playerid][3], 255);
- PlayerTextDrawFont(playerid, Ban_TD[playerid][3], 2);
- PlayerTextDrawSetProportional(playerid, Ban_TD[playerid][3], 1);
- PlayerTextDrawSetShadow(playerid, Ban_TD[playerid][3], 0);
- mysql_banned_check(playerid);
- #if defined MySQL_OnPlayerConnect
- return MySQL_OnPlayerConnect(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect MySQL_OnPlayerConnect
- #if defined MySQL_OnPlayerConnect
- forward MySQL_OnPlayerConnect(playerid);
- #endif
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i = 0; i < sizeof Ban_TD; i ++) PlayerTextDrawHide(playerid, Ban_TD[playerid][i]), PlayerTextDrawDestroy(playerid, Ban_TD[playerid][i]);
- #if defined MySQL_OnPlayerDisconnect
- return MySQL_OnPlayerDisconnect(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect MySQL_OnPlayerDisconnect
- #if defined MySQL_OnPlayerDisconnect
- forward MySQL_OnPlayerDisconnect(playerid, reason);
- #endif
- stock inc_ban_connect(const Server_Host[], const Server_User[], const Server_Database[], const Server_Password[])
- {
- MyConection = mysql_connect(Server_Host, Server_User, Server_Database, Server_Password);
- new MySQL_Format[400];
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "CREATE TABLE IF NOT EXISTS `"TABLE_BAN"` ( \
- `"ID"` INT(10) PRIMARY KEY NOT NULL AUTO_INCREMENT, \
- `"NAME"` VARCHAR(24), \
- `"IP"` VARCHAR(16), \
- `"DATE"` VARCHAR(40), \
- `"BAN_BY"` VARCHAR(24), \
- `"REASON"`VARCHAR(20), \
- `"TIME"` INT(20))");
- mysql_query(MyConection, MySQL_Format);
- return 1;
- }
- stock mysql_banned_check(playerid)
- {
- new MySQL_Format[300], GetDATE[50], Format[100], Strcat[500], Cache:GetCache, TimeBanLeft;
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "SELECT * FROM `"TABLE_BAN"` WHERE `"IP"` = '%s' OR `"NAME"` = '%s'", GetIP(playerid), GetName(playerid));
- GetCache = mysql_query(MyConection, MySQL_Format);
- if(cache_num_rows())
- {
- TimeBanLeft = cache_get_field_content_int(0, TIME);
- if(TimeBanLeft <= gettime())
- {
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "DELETE FROM `"TABLE_BAN"` WHERE `"IP"` = '%s' OR `"NAME"` = '%s'", GetIP(playerid), GetName(playerid));
- mysql_query(MyConection, MySQL_Format);
- SendClientMessage(playerid, -1, "You are unbanned. Avoid being banned again!");
- }
- else
- {
- cache_get_field_content(0, NAME, GetDATE); format(Format, sizeof Format, "NAME: %s~n~", GetDATE), strcat(Strcat, Format);
- cache_get_field_content(0, IP, GetDATE); format(Format, sizeof Format, "IP: %s~n~", GetDATE), strcat(Strcat, Format);
- cache_get_field_content(0, DATE, GetDATE); format(Format, sizeof Format, "DATE: %s~n~", GetDATE), strcat(Strcat, Format);
- cache_get_field_content(0, BAN_BY, GetDATE); format(Format, sizeof Format, "ADMIN: %s~n~", GetDATE), strcat(Strcat, Format);
- cache_get_field_content(0, REASON, GetDATE); format(Format, sizeof Format, "REASON: %s~n~", GetDATE), strcat(Strcat, Format);
- TimeBanLeft = cache_get_field_content_int(0, TIME); format(Format, sizeof Format, "TIME LEFT:~n~%s", ConvertTime(TimeBanLeft - gettime())), strcat(Strcat, Format);
- PlayerTextDrawSetString(playerid, Ban_TD[playerid][3], Strcat);
- PlayerTextDrawShow(playerid, Ban_TD[playerid][0]);
- PlayerTextDrawShow(playerid, Ban_TD[playerid][1]);
- PlayerTextDrawShow(playerid, Ban_TD[playerid][2]);
- PlayerTextDrawShow(playerid, Ban_TD[playerid][3]);
- pKick(playerid);
- }
- }
- cache_delete(GetCache);
- return 1;
- }
- stock mysql_ban_remove(Banned[])
- {
- new MySQL_Format[400], Cache:GetCache_;
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "SELECT `"IP"`, `"NAME"` FROM `"TABLE_BAN"` WHERE `"IP"` = '%s' OR `"NAME"` = '%s'", Banned, Banned);
- GetCache_ = mysql_query(MyConection, MySQL_Format);
- if(cache_num_rows())
- {
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "DELETE FROM `"TABLE_BAN"` WHERE `"IP"` = '%s' OR `"NAME"` = '%s'", Banned, Banned);
- mysql_query(MyConection, MySQL_Format);
- }
- cache_delete(GetCache_);
- return 1;
- }
- stock bool:mysql_ban_remove_check(Banned[])
- {
- new MySQL_Format[400], Cache:GetCache_, bool:FindBan;
- mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "SELECT `"IP"`, `"NAME"` FROM `"TABLE_BAN"` WHERE `"IP"` = '%s' OR `"NAME"` = '%s'", Banned, Banned);
- GetCache_ = mysql_query(MyConection, MySQL_Format);
- if(cache_num_rows()) FindBan = true;
- else FindBan = false;
- cache_delete(GetCache_);
- return FindBan;
- }
- stock bool:mysql_ban_player_check(Find[])
- {
- new bool:FindPlayer;
- for(new i = 0; i < MAX_PLAYERS; i ++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(strcmp(GetName(i), Find, true) == 0) FindPlayer = true;
- if(strcmp(GetIP(i), Find, true) == 0) FindPlayer = true;
- }
- return FindPlayer;
- }
- stock mysql_ban_player(Player_Name[], Player_IP[], Ban_By[], Reason[], Ban_Type, Time)
- {
- new GetTime[3], GetDate[3], FormatTimeDate[40], MySQL_Format[400];
- gettime(GetTime[0], GetTime[1], GetTime[2]);
- getdate(GetDate[0], GetDate[1], GetDate[2]);
- format(FormatTimeDate, sizeof FormatTimeDate, "%02i/%02i/%02i - %02i:%02i:%02i", GetDate[2], GetDate[1], GetDate[0], GetTime[0], GetTime[1], GetTime[2]);
- for(new i = 0; i < MAX_PLAYERS; i ++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(strcmp(GetName(i), Player_Name, true) == 0) pKick(i);
- if(strcmp(GetIP(i), Player_IP, true) == 0) pKick(i);
- }
- switch(Ban_Type)
- {
- case PERMANENT: mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "INSERT INTO `"TABLE_BAN"` (`"NAME"`, `"IP"`, `"DATE"`, `"BAN_BY"`, `"REASON"`, `"TIME"`) VALUES ('%s', '%s', '%s', '%s', '%s', '%i')", Player_Name, Player_IP, FormatTimeDate, Ban_By, Reason, 20 * 12 * 30 * 24 * 60 * 60 + gettime());
- case MINUTES: mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "INSERT INTO `"TABLE_BAN"` (`"NAME"`, `"IP"`, `"DATE"`, `"BAN_BY"`, `"REASON"`, `"TIME"`) VALUES ('%s', '%s', '%s', '%s', '%s', '%i')", Player_Name, Player_IP, FormatTimeDate, Ban_By, Reason, Time * 60 + gettime());
- case HOURS: mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "INSERT INTO `"TABLE_BAN"` (`"NAME"`, `"IP"`, `"DATE"`, `"BAN_BY"`, `"REASON"`, `"TIME"`) VALUES ('%s', '%s', '%s', '%s', '%s', '%i')", Player_Name, Player_IP, FormatTimeDate, Ban_By, Reason, Time * 60 * 60 + gettime());
- case DAYS: mysql_format(MyConection, MySQL_Format, sizeof MySQL_Format, "INSERT INTO `"TABLE_BAN"` (`"NAME"`, `"IP"`, `"DATE"`, `"BAN_BY"`, `"REASON"`, `"TIME"`) VALUES ('%s', '%s', '%s', '%s', '%s', '%i')", Player_Name, Player_IP, FormatTimeDate, Ban_By, Reason, Time * 24 * 60 * 60 + gettime());
- }
- mysql_query(MyConection, MySQL_Format);
- return 1;
- }
- forward pKickPlayer(playerid);
- public pKickPlayer(playerid) return Kick(playerid);
- stock ppKick(playerid) return SetTimerEx("KickPlayer", 100, false, "i", playerid);
- stock ConvertTime(SECONDS_)
- {
- new MINUTES_, HOURS_, DAYS_, String[200];
- if(SECONDS_ > 59)
- {
- MINUTES_ = SECONDS_ / 60;
- SECONDS_ = SECONDS_ - MINUTES_ * 60;
- }
- if(MINUTES_ > 59)
- {
- HOURS_ = MINUTES_ / 60;
- MINUTES_ = MINUTES_ - HOURS_ * 60;
- }
- if(HOURS_ > 23)
- {
- DAYS_ = HOURS_ / 24;
- HOURS_ = HOURS_ - DAYS_ * 24;
- }
- format(String, sizeof(String), "%02d Days, %02d Hours, %02d Minutes and %02d Seconds", DAYS_, HOURS_, MINUTES_, SECONDS_);
- if(DAYS_ < 1) format(String, sizeof(String), "%02d Hours, %02d Minutes and %02d Seconds", HOURS_, MINUTES_, SECONDS_);
- if(DAYS_ < 1 && HOURS_ < 1) format(String, sizeof(String), "%02d Minutes and %02d Seconds", MINUTES_, SECONDS_);
- if(DAYS_ < 1 && HOURS_ < 1 && MINUTES_ < 1) format(String, sizeof(String), "%02d Seconds", SECONDS_);
- if(DAYS_ > 3650) format(String, sizeof(String), "PERMANENT");
- return String;
- }
- stock GetName(playerid)
- {
- new Nome_[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nome_, sizeof Nome_);
- return Nome_;
- }
- stock GetIP(playerid)
- {
- new IP_[16];
- GetPlayerIp(playerid, IP_, sizeof IP_);
- return IP_;
- }
Advertisement
Add Comment
Please, Sign In to add comment