20.09.2018, 22:28
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:
That's all you need for the second method!
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);
}