rendered paste body#include <a_samp>
#include <file>
const COLOR_white = 0xFFFFFFAA;
static fileLength;
static isTimer = 0;
static timerID;
new KickTime[100];
public OnFilterScriptInit()
{
new string[256];
string = "4Echo filterscript loaded...";
print(" ");
print(" ========================================================");
print(" <Echo filterscript created by Tommy4, modified by w1z13>");
print(" ========================================================");
print(" ");
save(string);
fremove("echo/irc.txt");
fileLength = 0;
new File:irc = fopen("echo/irc.txt", io_write);
fclose(irc);
return 1;
}
public CheckFile()
{
SetTimer("IRCKick",995,1);
new command[256];
new nick[MAX_PLAYER_NAME];
new msg[1024];
new string[1024];
new File:irc = fopen("echo/irc.txt", io_read);
fseek(irc, fileLength, seek_start);
while(fread(irc, string, sizeof(string), false))
{
strmid(command, string, 0, strfind(string, " ", false, 1), sizeof(command));
if(strcmp(command, "/say", true) == 0)
{
strmid(string, string, strfind(string, " ", false, 1), strlen(string), sizeof(string));
SendClientMessageToAll(COLOR_white, string);
strmid(nick, string, strfind(string, " ", false, 1)+1, strfind(string, ":", false, 1), sizeof(nick));
strmid(msg, string, strfind(string, ":", false, 1)+1, strlen(string)-1, sizeof(msg));
format(string, sizeof(string), "*[%s]: %s", nick, msg);
save(string);
}
if(strcmp(command, "/kick", true) == 0)
{
new k = strval(string);
SendClientMessage(k, 0xFFFF00AA, "You have been kicked from IRC");
strmid(string, string, strfind(string, " ", false, 1), strlen(string), sizeof(string));
if(IsPlayerConnected(k))
{
KickTime[k] = 2;
}
}
if(strcmp(command, "/ban", true) == 0)
{
new b = strval(string);
SendClientMessage(b, 0xFFFF00AA, "You have been banned from IRC");
strmid(string, string, strfind(string, " ", false, 1), strlen(string), sizeof(string));
if (IsPlayerConnected(b))
{
Ban(b);
}
}
}
fileLength = flength(irc);
fclose(irc);
return 0;
}
public IRCKick()
{
for(new i=0;i<100;i++)
{
switch(KickTime[i])
{
case 1..2:
{
KickTime[i]--;}
case 0:
{
KickTime[i]--;
Kick(i);}
}
}
}
public OnFilterScriptExit()
{
new string[256];
string = "Echo filterscript unloaded...";
save(string);
return 1;
}
public OnPlayerText(playerid, text[])
{
new playerName[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "2[%d] 13%s: 1%s", playerid, playerName, text);
save(string);
return 1;
}
public OnPlayerConnect(playerid)
{
if(isTimer == 1)
{
KillTimer(timerID);
}
KickTime[playerid] = -1;
timerID = SetTimer("CheckFile", 1000, 1);
isTimer = 1;
new playerName[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "2[%d] 3%s has joined the server", playerid, playerName);
save(string);
return 1;
}
public OnPlayerDisconnect(playerid)
{
new playerName[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "2[%d] 3%s has left the server", playerid, playerName);
save(string);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new playerName[MAX_PLAYER_NAME];
new killerName[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
if(killerid != INVALID_PLAYER_ID)
{
GetPlayerName(killerid, killerName, MAX_PLAYER_NAME);
format(string, sizeof(string), "3%s 1has killed 4%s", killerName, playerName);
}
else
{
format(string, sizeof(string), "2[%d] 4%s died", playerid, playerName);
}
save(string);
return 1;
}
save(text[])
{
new File:log = fopen("echo/echo.txt", io_append);
new string[256];
format(string, sizeof(string), "%s\r\n", text);
fwrite(log, string);
fclose(log);
return 1;
}