Any way to adminlog? -
Zeus666 - 20.09.2018
I have created an admin log for each admincommand
ex: slap, /goto, /getcar etc.
via
But if 5-10 admins would type one cmd, there would be immense spam of mysql_Tquery.
Any ideea how to make logs without lag / spam?
Re: Any way to adminlog? -
solstice_ - 20.09.2018
If you insert the query to the database once an admin uses the commands, I don't think there is a way to reduce the spam.
Re: Any way to adminlog? -
Zeus666 - 20.09.2018
Quote:
Originally Posted by willbedie
If you insert the query to the database once an admin uses the commands, I don't think there is a way to reduce the spam.
|
So I should stick with logs to important commands?
Re: Any way to adminlog? -
solstice_ - 20.09.2018
Yeah, like for example /setadmin, /givemoney, /setmoney, /createvehicle etc.. Only for the commands that could be abused.
Re: Any way to adminlog? -
KinderClans - 20.09.2018
Exactly.
P.S Do you mind showing me your full adminlog system? I want to make something similar, i just made server stats for now.
Re: Any way to adminlog? -
Zeus666 - 20.09.2018
Quote:
Originally Posted by KinderClans
Exactly.
P.S Do you mind showing me your full adminlog system? I want to make something similar, i just made server stats for now.
|
PHP код:
format(jQuery, MAX_QUERY_LENGTH, "INSERT INTO `"#adminlog"` (Username, Command, Targetname, Value, Data) VALUES ('%s', 'HEREMODIFYWITHCMDNAME', '%s', '%i', CURRENT_TIMESTAMP)", PlayerName(playerid), PlayerName(targetid), score);
mysql_tquery(handle, jQuery, "", "");
just create a table with those rows and add that php code inside your admin cmd. Change the "heremodify" with CMD: name
good luck
Re: Any way to adminlog? -
KinderClans - 20.09.2018
Got the sql file for the table? Also, wouldn't be better to create a stock instead of pasting that code for every cmd wanted to log?
Re: Any way to adminlog? -
Zeus666 - 20.09.2018
Quote:
Originally Posted by KinderClans
Got the sql file for the table? Also, wouldn't be better to create a stock instead of pasting that code for every cmd wanted to log?
|
create
Username (varchar 24)
Command (varchar 24)
Targetname (varchar 24)
Value (varchar 24)
Date (Timestamp)
then alter the table by adding "ID". use the A_I function and it's done
about the stock, it is easier, but sometimes I prefere hard things to complicate myself, idk.
but no, I don't recomand you to use stocks because you need to modify the "command" area. I find it easier to put manually instead of creating stock
Re: Any way to adminlog? -
Gammix - 20.09.2018
It won't cause you any harm if you run 5-10 queries every second.
Another smart way can be using a 2D array and fill it up with admin log until it gets full. Once the array is full, you save the log from array to database and then empty it and do the process again.
A rough look at what i mean:
PHP код:
#define MAX_ADMIN_LOGS 1000 // how many logs can the array hold
#define MAX_ADMIN_LOG_STRING 144 // max length of log string
new adminLogs[MAX_ADMIN_LOGS][MAX_ADMIN_LOG_STRING];
new adminLogCount; // this var is to keep track of number of logs
// create a function to write admin log
WriteAdminLog(const text[]) {
if (adminLogCount == MAX_ADMIN_LOGS) {
// array is full
// we loop through 1000 logs (or whatever you set the limit) and run 1000 queries to save into database
for (new i = 0; i < MAX_ADMIN_LOGS; i++) {
// write query to save log for "adminLogs[i]"
}
// clear the count
adminLogCount = 0;
}
// here we fill the array
format(adminLogs[adminLogCount++], MAX_ADMIN_LOG_STRING, text);
}
That's all you need for the second method!