/* «Created/Scripted by Seif» ......................................................... . X = DONE . . % = PROGRESSION . . - = CANCELED . . ----------------TO DO LIST-------------- . . X IP Banning System . . X Name Banning System . . X Range Banning System . ......................................................... */ /*x---------------------------------Important-------------------------------------x*/ //**INCLUDES**// #include //**PRAGMAS**// //**MISC**// /*x---------------------------------Defining-------------------------------------x*/ //**COLORS*// #define GREEN 0x21DD00FF #define RED 0xE60000FF #define ADMIN_RED 0xFB0000FF #define YELLOW 0xFFFF00FF #define ORANGE 0xF97804FF #define LIGHTRED 0xFF8080FF #define LIGHTBLUE 0x00C2ECFF #define PURPLE 0xB360FDFF #define PLAYER_COLOR 0xFFFFFFFF #define BLUE 0x1229FAFF #define LIGHTGREEN 0x38FF06FF #define DARKPINK 0xE100E1FF #define DARKGREEN 0x008040FF #define ANNOUNCEMENT 0x6AF7E1FF #define COLOR_SYSTEM 0xEFEFF7AA #define GRAY 0xCECECEFF #define give return //**MISC**// //**VARIABLES**// new player[24]; new ip[20]; new File:file; new filestr[128]; new lines; new ban[128]; new ban2[128]; new giveplayerid; new string[128]; //**FORWARDS**// /*x---------------------------------CallBacks-------------------------------------x*/ stock IsNumeric(const num[]) { for (new i = 0, j = strlen(num); i < j; i++) if (num[i] > '9' || num[i] < '0') return 0; return 1; } ReturnUser(text[], playerid = INVALID_PLAYER_ID) { new pos = 0; while (text[pos] < 0x21) { if (text[pos] == 0) return INVALID_PLAYER_ID; pos++; } new userid = INVALID_PLAYER_ID; if (IsNumeric(text[pos])) { userid = strval(text[pos]); if (userid >=0 && userid < MAX_PLAYERS) { if(!IsPlayerConnected(userid)) userid = INVALID_PLAYER_ID; else return userid; } } new len = strlen(text[pos]); new count = 0; new pname[MAX_PLAYER_NAME]; for (new i = 0; i < MAX_PLAYERS; i++) { if (IsPlayerConnected(i)) { GetPlayerName(i, pname, sizeof (pname)); if (strcmp(pname, text[pos], true, len) == 0) { if (len == strlen(pname)) return i; else { count++; userid = i; } } } } if (count != 1) { if (playerid != INVALID_PLAYER_ID) { if (count) SendClientMessage(playerid, COLOR_SYSTEM, "There are multiple users, enter full playername."); else SendClientMessage(playerid, COLOR_SYSTEM, "Playername not found."); } userid = INVALID_PLAYER_ID; } return userid; } stock strtok(const str[], &index,seperator=' ') { new length = strlen(str); new offset = index; new result[128]; while ((index < length) && (str[index] != seperator) && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = str[index]; index++; } result[index - offset] = EOS; if ((index < length) && (str[index] == seperator)) { index++; } return result; } stock SendClientMessageToAdmins(color, msg[]) { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if (IsPlayerAdmin(i)) { SendClientMessage(i, color, msg); printf("%s", string); } } } return 1; } public OnFilterScriptInit() { print("<|-----------------------------------------|>"); print(" |[FS] .:[ - Ban System by Seif - ]:. [FS]|"); print("<|-----------------------------------------|>"); if (fexist("Bans.txt")) return true; else fopen("Bans.txt",io_write); return true; } public OnFilterScriptExit() { if (file) fclose(file); return true; } public OnPlayerConnect(playerid) { BanCheck(playerid); return true; } public OnPlayerCommandText(playerid, cmdtext[]) { new tmp[128],idx; new cmd[128]; cmd = strtok(cmdtext,idx); if (strcmp(cmd,"/ban", true) == 0) { if (IsPlayerAdmin(playerid)) { new reason[128],str[128],namez[24],name1[24]; tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { SendClientMessage(playerid,ORANGE,"USAGE: /ban [name/ip] [reason]"); SendClientMessage(playerid,ORANGE,"FUNCTION: Will ban the player's name/IP following by a reason. !! DO NOT ENTER THE ID !!"); SendClientMessage(playerid,ORANGE,"HELP: Please enter a name or IP. If you're trying to execute a range ban..."); SendClientMessage(playerid,ORANGE,"HELP: ...then make sure you got a valid player IP( /ip ) and replace some characters by * (NOT ALL)"); return 1; } new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; while ((idx < length) && ((idx - offset) < (sizeof(reason) - 1))) { reason[idx - offset] = cmdtext[idx]; idx++; } reason[idx - offset] = EOS; if(!strlen(reason)) { SendClientMessage(playerid,ORANGE,"USAGE: /ban [name/ip] [reason]"); SendClientMessage(playerid,RED,"ERROR: You must enter a reason for the ban!"); return 1; } file = fopen("Bans.txt",io_append); if (file) { format(str,128,"%s\r\n",tmp); fwrite(file,str); fclose(file); } new count = 0; for(new i=0;i