rendered paste body#include <a_samp>
#include <file>
const COLOR_LIGHTBLUE = 0x33CCFFAA;
static fileLength;
static isTimer = 0;
static timerID;
public OnFilterScriptInit()
{
new string[256];
string = "SA:MP server started. Echo script loaded.";
print("\n----------------------------------------------------");
print(" SA:MP server started. Echo script loaded.");
print("----------------------------------------------------\n");
save(string);
fremove("echo/irc.txt");
fileLength = 0;
new File:irc = fopen("echo/irc.txt", io_write);
fclose(irc);
return 1;
}
public CheckFile()
{
new string[1024];
new commandzz[256];
new nick[MAX_PLAYER_NAME];
new msg[1024];
new File:irc = fopen("echo/irc.txt", io_read);
fseek(irc, fileLength, seek_start);
while(fread(irc, string, sizeof(string), false))
{
strmid(commandzz, string, 0, strfind(string, " ", false, 1), sizeof(commandzz));
if(strcmp(commandzz, "/tell", true) == 0)
{
strmid(string, string, strfind(string, " ", false, 1), strlen(string), sizeof(string));
SendClientMessageToAll(COLOR_LIGHTBLUE, 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)-2, sizeof(msg));
format(string, sizeof(string), "10* %s: %s", nick, msg);
save(string);
}
}
fileLength = flength(irc);
fclose(irc);
return 1;
}
public OnFilterScriptExit()
{
new string[256];
string = "SA:MP server started. Echo script loaded.";
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]7 %s: %s", playerid, playerName, text);
save(string);
return 1;
}
public OnPlayerConnect(playerid)
{
if(isTimer == 1)
{
KillTimer(timerID);
}
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 joined the game.", 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 left the game.", 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), "4*** %s killed %s.", killerName, playerName);
}
else
{
format(string, sizeof(string), "4*** %s died.", 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;
}