[FilterScript] Server Whitelist [MySQL Support][Logging]
#7

I used DeAMX to decomile the script

Code:
#include <a_samp>
#include <core>
#include <float>


public OnFilterScriptInit()
{
	print("Whitelist loaded.");
	if(!fexist("whitelist.txt"))
	{
		print("Whitelist file created.");
		new File:var0 = fopen("whitelist.txt", 1);
		fwrite(var0, " ");
		fclose(var0);
	}
	else
	{
		print("Whitelist file loaded.");
	}
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	new var0 = 0;
	new var1[120], var2[20], var3[16];
	GetPlayerName(playerid, var2, 20);
	GetPlayerIp(playerid, var3, 16);
	new File:var4 = fopen("whitelist.txt", 0);
	while(fread(var4, var1, 120))
	{
		if(!strcmp(var2, var1, true) || !strcmp(var3, var1, true))
		{
			printf("User %s (%s) has connected to the server successfully.", var2, var3);
			var0 = 1;
			return 1;
		}
	}
	fclose(var4);
	if(!var0)
	{
		SendClientMessage(playerid, 0xE8E1E3FF, "You are not on the server whitelist.");
		printf("User %s (%s) has connected while not on the whitelist.", var2, var3);
		Kick(playerid);
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext)
{
	if(!IsPlayerAdmin(playerid))
	{
		return SendClientMessage(playerid, 0xE8E1E3FF, "ERROR: Only admins can edit the whitelist.");
	}
	if(!strcmp(cmdtext, "/whiteadd", true, 9))
	{
		if(!(cmdtext + 40))
		{
			return SendClientMessage(playerid, 0xE8E1E3FF, "USAGE: /whiteadd [entry]");
		}
		strdel(cmdtext, 10, strlen(cmdtext));
		new var0[32];
		new File:var1 = fopen("whitelist.txt", 3);
		format(var0, 32, "\r\n%s", cmdtext);
		fwrite(var1, var0);
		fclose(var1);
		SendClientMessage(playerid, 0xE8E1E3FF, "Entry added.");
		return 1;
	}
	if(!strcmp(cmdtext, "/whiteremove", true, 12))
	{
		if(!(cmdtext + 52))
		{
			return SendClientMessage(playerid, 0xE8E1E3FF, "USAGE: /whiteremove [entry]");
		}
		strdel(cmdtext, 12, strlen(cmdtext));
		new var0[32], var1 = 0, var2 = 0;
		new File:var3 = fopen("whitelist.txt", 0);
		while(fread(var3, var0, 32))
		{
			var1++;
			if(!strcmp(cmdtext, var0, true))
			{
				var2 = var1;
				return 1;
			}
		}
		fclose(var3);
		functionA18("whitelist.txt", var2);
		SendClientMessage(playerid, 0xE8E1E3FF, "Entry removed.");
		return 1;
	}
	return 0;
}

functionA18(arg0, arg1)
{
	new var0 = 0, var1[128], File:var2 = 0, File:var3 = 0;
	var2 = fopen(arg0, 0);
	var3 = fopen("tmpfile.txt", 1);
	while(fread(var2, var1, 128))
	{
		if(++var0 != arg1)
		{
			fwrite(var3, var1);
		}
	}
	fclose(var2);
	fclose(var3);
	var2 = fopen(arg0, 1);
	var3 = fopen("tmpfile.txt", 0);
	while(fread(var3, var1, 128))
	{
		fwrite(var2, var1);
	}
	fclose(var2);
	fclose(var3);
	fremove("tmpfile.txt");
	return 1;
}
Gives a few error's though
Reply


Messages In This Thread
Server Whitelist [MySQL Support][Logging] - by lolumadd_ - 06.08.2011, 06:36
Re: Server Whitelist [MySQL Support][Logging] - by [HiC]TheKiller - 06.08.2011, 06:44
Re: Server Whitelist [MySQL Support][Logging] - by Sergei - 06.08.2011, 07:54
Re: Server Whitelist [MySQL Support][Logging] - by dreamboxxl - 22.12.2011, 11:58
Re: Server Whitelist [MySQL Support][Logging] - by Astralis - 22.12.2011, 13:31
Re: Server Whitelist [MySQL Support][Logging] - by dreamboxxl - 22.12.2011, 18:39
Re: Server Whitelist [MySQL Support][Logging] - by nickbouwhuis - 29.10.2012, 05:51
Re: Server Whitelist [MySQL Support][Logging] - by elhanan - 30.04.2016, 17:26

Forum Jump:


Users browsing this thread: 1 Guest(s)