SA-MP Forums Archive
files - 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: files (/showthread.php?tid=67599)



files - Schock - 02.03.2009

hey guys ... i want a code that get the name of the kicked player and add the name into a file...
and after 1 week the file get cleared that means that all name will deleted after 1 week

can someone help me?


Re: files - Danut - 02.03.2009

Use this :

pawn Код:
forward KickLog(string[]);

public KickLog(string[])
{
    new entry[256];
    format(entry, sizeof(entry), "%s\n",string);
    new File:hFile;
    hFile = fopen("KickLog.txt", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}

// Put this in your /kick command
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
KickLog(string);
format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s", giveplayer, sendername, (result));
SendClientMessageToAll(COLOR_LIGHTRED, string);
Kick(giveplayerid);



Re: files - Schock - 02.03.2009

i have this
pawn Код:
GetPlayerWeaponData(i, 7, weapon, ammo);
    if(weapon == 38 && ammo >= 1)
    {
    format(string, sizeof(string), "[Anti Weapon]: %s (id:%d) was kicked cause he is a fucking CHEATER (Minigun) [Time: %02d:%02d:%02d]", GetName(i), i, Hour, Minute, Second);
    SendClientMessageToAll(RED, string);
    Kick(i);
    KickLog(string);
    }
and i want add it here
i renamed the file to
pawn Код:
NameLog(string);



Re: files - Danut - 02.03.2009

just change KickLog with NameLog


Re: files - Schock - 02.03.2009

oh sorry ^^ i mean the string with the kicktext should alive ... and the kicklog to ...
i want that the "NameLog(string)" only get the name of the kicked player and add it to an other file


Re: files - Rks25 - 02.03.2009

edit the format().


Re: files - Schock - 02.03.2009

i addet this:
pawn Код:
new namestring[56]
                  GetPlayerWeaponData(i, 7, weapon, ammo);
                if(weapon == 38 && ammo >= 1)
                {
                format(string, sizeof(string), "[Anti Weapon]: %s (id:%d) was kicked cause he is a fucking CHEATER (Minigun) [Time: %02d:%02d:%02d]", GetName(i), i, Hour, Minute, Second);
                SendClientMessageToAll(RED, string);
                format(string, sizeof(namestring), "%s", GetName(i));
                SendClientMessageToAll(RED, namestring);
                AccountInfo[i][Jail] = 1;
                Kick(i);
                KickLog(string);
                NameLog(namestring);
pawn Код:
forward NameLog(namestring[]);

public NameLog(namestring[])
{
    new entry[256];
    format(entry, sizeof(entry), "%s\n",namestring);
    new File:hFile;
    hFile = fopen("Badnames.cfg", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
but if i get a minigun ingame the script kicks me but the server crash


Re: files - Rks25 - 02.03.2009

You need to make a new string with only name in it, because you are trying to write the string of Scm, while you only want name!


Re: files - Schock - 02.03.2009

i know but i dont tryed to make a string witk only his name?
Quote:
Originally Posted by Schock
i addet this:
pawn Код:
new namestring[56]
                  GetPlayerWeaponData(i, 7, weapon, ammo);
                if(weapon == 38 && ammo >= 1)
                {
                format(string, sizeof(string), "[Anti Weapon]: %s (id:%d) was kicked cause he is a fucking CHEATER (Minigun) [Time: %02d:%02d:%02d]", GetName(i), i, Hour, Minute, Second);
                SendClientMessageToAll(RED, string);
                format(string, sizeof(namestring), "%s", GetName(i)); // here?
                SendClientMessageToAll(RED, namestring); // here?
                AccountInfo[i][Jail] = 1;
                Kick(i);
                KickLog(string);
                NameLog(namestring);
pawn Код:
forward NameLog(namestring[]);

public NameLog(namestring[])
{
    new entry[256];
    format(entry, sizeof(entry), "%s\n",namestring);
    new File:hFile;
    hFile = fopen("Badnames.cfg", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
but if i get a minigun ingame the script kicks me but the server crash



Re: files - Rks25 - 02.03.2009

what does KickLog do?