2021-04-22, 04:47 PM
(This post was last modified: 2021-04-22, 04:50 PM by TheAnimalKa.)
(2021-04-22, 11:59 AM)Ambarita Wrote:(2021-04-22, 11:27 AM)TheAnimalKa Wrote: You can use mysql for making ban logs.
Is there no way to store it locally?
Code:
stock WriteLog(const path[], const str[], {Float,_}:...) // Credit Emmet
{
static
args,
start,
end,
File:file,
string[1024]
;
if ((start = strfind(path, "/")) != -1) {
strmid(string, path, 0, start 1);
if (!fexist(string))
return printf("** Warning: Directory \"%s\" doesn't exist.", string);
}
#emit LOAD.S.pri 8
#emit STOR.pri args
file = fopen(path, io_append);
if (!file)
return 0;
if (args > 8)
{
#emit ADDR.pri str
#emit STOR.pri start
for (end = start (args - 8); end > start; end -= 4)
{
#emit LREF.pri end
#emit PUSH.pri
}
#emit PUSH.S str
#emit PUSH.C 1024
#emit PUSH.C string
#emit PUSH.C args
#emit SYSREQ.C format
fwrite(file, string);
fwrite(file, "\r\n");
fclose(file);
#emit LCTRL 5
#emit SCTRL 4
#emit RETN
}
fwrite(file, str);
fwrite(file, "\r\n");
fclose(file);
return 1;
}
And you use it like this
CMD:ban(playerid, params[])
{
if(sscanf(params, "us[128]", playerb, reason))
return SendClientMessage(playerid, -1, "/ban [playerid/PartofName] [reason]");
WriteLog("ban_logs/ban.txt", "%s has banned?%s?for?%s.",? ReturnName(playerid), ReturnName(playerb), reason);
return 1;
}
if no log will show in your scriptfiles I think you have to manual create a folder named ban_logs and inside it is ban.txt.