SA-MP Forums Archive
Making auto reading a file? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making auto reading a file? (/showthread.php?tid=190710)



Making auto reading a file? - Face9000 - 16.11.2010

Hai all,i need little help.

I've this small anti cheat:

Код:
#include <a_samp>

//AntiCheat
new timer1;

public OnGameModeInit()
{
    timer1 = SetTimer("AntiCheat",5000,true);
    return 1;
}

forward AntiCheat();
public AntiCheat()
{
    new weap, ammo;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerWeaponData(i, 7, weap, ammo);
            if(weap == 38)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "%s has been banned. (Reason: AUTO BAN Minigun Cheat)", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "Auto Ban - Minigun");
                break;
            }
            GetPlayerWeaponData(i, 7, weap, ammo);
            if(weap == 35)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "%s has been banned (Reason: AUTO BAN Rocket launcher Cheat)", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "Auto Ban - Rocket Launcher");
                break;
            }
        }
    }
    return 1;
}

public OnGameModeExit()
{
    KillTimer(timer1);
    return 1;
}
I need to write this AUTOBANS in a autobans.log file

Is there any way?


Re: Making auto reading a file? - Patrik356b - 16.11.2010

Check this: https://sampwiki.blast.hk/wiki/File_Functions


Re: Making auto reading a file? - Face9000 - 16.11.2010

Umh yes i know that,but u can say me how to do it?


Re: Making auto reading a file? - Grim_ - 16.11.2010

You could add this code to it after it bans someone.
pawn Код:
new File:bFile = fopen("autobans.log", io_append);
if(bFile)
{
   fwrite(bFile, "AUTOBANS");
}
fclose(bFile);
Make sure the file exists on start of the server or it will crash.


Re: Making auto reading a file? - Face9000 - 16.11.2010

Thank u!